Skip to content

Commit 8e08f43

Browse files
authored
HDFS-16014: Fix an issue in checking native pmdk lib by 'hadoop checknative' command (#3762)
1 parent d29f0e8 commit 8e08f43

File tree

2 files changed

+13
-4
lines changed
  • hadoop-common-project/hadoop-common/src/main

2 files changed

+13
-4
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public String getMessage() {
141141
}
142142
}
143143

144-
// Denotes the state of supporting PMDK. The value is set by JNI.
144+
// Denotes the state of supporting PMDK. The actual value is set via JNI.
145145
private static SupportState pmdkSupportState =
146146
SupportState.UNSUPPORTED;
147147

hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/pmdk_load.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@
3535
#endif
3636

3737
PmdkLibLoader * pmdkLoader;
38+
// 1 represents loaded. Otherwise, not loaded.
39+
int pmdkLoaded;
3840

3941
/**
4042
* pmdk_load.c
4143
* Utility of loading the libpmem library and the required functions.
4244
* Building of this codes won't rely on any libpmem source codes, but running
4345
* into this will rely on successfully loading of the dynamic library.
44-
*
4546
*/
4647

4748
static const char* load_functions() {
@@ -56,6 +57,10 @@ static const char* load_functions() {
5657
return NULL;
5758
}
5859

60+
/**
61+
* It should be idempotent to call this function for checking
62+
* whether PMDK lib is successfully loaded.
63+
*/
5964
void load_pmdk_lib(char* err, size_t err_len) {
6065
const char* errMsg;
6166
const char* library = NULL;
@@ -67,10 +72,13 @@ void load_pmdk_lib(char* err, size_t err_len) {
6772

6873
err[0] = '\0';
6974

70-
if (pmdkLoader != NULL) {
75+
if (pmdkLoaded == 1) {
7176
return;
7277
}
73-
pmdkLoader = calloc(1, sizeof(PmdkLibLoader));
78+
79+
if (pmdkLoader == NULL) {
80+
pmdkLoader = calloc(1, sizeof(PmdkLibLoader));
81+
}
7482

7583
// Load PMDK library
7684
#ifdef UNIX
@@ -103,4 +111,5 @@ void load_pmdk_lib(char* err, size_t err_len) {
103111
}
104112

105113
pmdkLoader->libname = strdup(library);
114+
pmdkLoaded = 1;
106115
}

0 commit comments

Comments
 (0)