|
Lines 116-127
static uint64_t debug_flags = 0;
Link Here
|
| 116 |
static pthread_mutex_t lustre_lock = PTHREAD_MUTEX_INITIALIZER; |
116 |
static pthread_mutex_t lustre_lock = PTHREAD_MUTEX_INITIALIZER; |
| 117 |
static int tres_pos = -1; |
117 |
static int tres_pos = -1; |
| 118 |
|
118 |
|
| 119 |
/* Default path to lustre stats */ |
|
|
| 120 |
const char proc_base_path[] = "/proc/fs/lustre"; |
| 121 |
|
119 |
|
| 122 |
/** |
120 |
/* |
| 123 |
* is lustre fs supported |
121 |
* _llite_path() |
| 124 |
**/ |
122 |
* |
|
|
123 |
* returns the path to Lustre clients stats (depends on Lustre version) |
| 124 |
* or NULL if none found |
| 125 |
* |
| 126 |
*/ |
| 127 |
static char *_llite_path(void) |
| 128 |
{ |
| 129 |
static char *llite_path = NULL; |
| 130 |
int i = 0; |
| 131 |
DIR *llite_dir; |
| 132 |
static char *test_paths[] = { |
| 133 |
"/proc/fs/lustre/llite", |
| 134 |
"/sys/kernel/debug/lustre/llite", |
| 135 |
NULL |
| 136 |
}; |
| 137 |
|
| 138 |
if (llite_path) |
| 139 |
return llite_path; |
| 140 |
|
| 141 |
while ((llite_path = test_paths[i++])) { |
| 142 |
if ((llite_dir = opendir(llite_path))) { |
| 143 |
closedir(llite_dir); |
| 144 |
return llite_path; |
| 145 |
} |
| 146 |
|
| 147 |
debug("%s: unable to open %s %m", __func__, llite_path); |
| 148 |
} |
| 149 |
return NULL; |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
/* |
| 154 |
* _check_lustre_fs() |
| 155 |
* |
| 156 |
* check if Lustre is supported |
| 157 |
* |
| 158 |
*/ |
| 125 |
static int _check_lustre_fs(void) |
159 |
static int _check_lustre_fs(void) |
| 126 |
{ |
160 |
{ |
| 127 |
static bool set = false; |
161 |
static bool set = false; |
|
Lines 129-151
static int _check_lustre_fs(void)
Link Here
|
| 129 |
|
163 |
|
| 130 |
if (!set) { |
164 |
if (!set) { |
| 131 |
uint32_t profile = 0; |
165 |
uint32_t profile = 0; |
| 132 |
char lustre_directory[BUFSIZ]; |
|
|
| 133 |
DIR *proc_dir; |
| 134 |
|
166 |
|
| 135 |
set = true; |
167 |
set = true; |
| 136 |
acct_gather_profile_g_get(ACCT_GATHER_PROFILE_RUNNING, |
168 |
acct_gather_profile_g_get(ACCT_GATHER_PROFILE_RUNNING, |
| 137 |
&profile); |
169 |
&profile); |
| 138 |
if ((profile & ACCT_GATHER_PROFILE_LUSTRE)) { |
170 |
if ((profile & ACCT_GATHER_PROFILE_LUSTRE)) { |
| 139 |
snprintf(lustre_directory, BUFSIZ, |
171 |
char *llite_path = _llite_path(); |
| 140 |
"%s/llite", proc_base_path); |
172 |
if (!llite_path) { |
| 141 |
proc_dir = opendir(proc_base_path); |
173 |
error("%s: can't find Lustre stats", __func__); |
| 142 |
if (!proc_dir) { |
174 |
rc = SLURM_ERROR; |
| 143 |
error("%s: not able to read %s %m", |
175 |
} else |
| 144 |
__func__, lustre_directory); |
176 |
debug("%s: using Lustre stats in %s", |
| 145 |
rc = SLURM_FAILURE; |
177 |
__func__, llite_path); |
| 146 |
} else { |
|
|
| 147 |
closedir(proc_dir); |
| 148 |
} |
| 149 |
} else |
178 |
} else |
| 150 |
rc = SLURM_ERROR; |
179 |
rc = SLURM_ERROR; |
| 151 |
} |
180 |
} |
|
Lines 154-163
static int _check_lustre_fs(void)
Link Here
|
| 154 |
} |
183 |
} |
| 155 |
|
184 |
|
| 156 |
/* _read_lustre_counters() |
185 |
/* _read_lustre_counters() |
|
|
186 |
* |
| 157 |
* Read counters from all mounted lustre fs |
187 |
* Read counters from all mounted lustre fs |
| 158 |
* from the file stats under the directories: |
188 |
* from the file stats under the directories: |
| 159 |
* |
189 |
* |
| 160 |
* /proc/fs/lustre/llite/lustre-xxxx |
190 |
* /proc/fs/lustre/llite/lustre-xxxx |
|
|
191 |
* or |
| 192 |
* /sys/kernel/debug/lustre/llite/lustre-xxxx |
| 161 |
* |
193 |
* |
| 162 |
* From the file stat we use 2 entries: |
194 |
* From the file stat we use 2 entries: |
| 163 |
* |
195 |
* |
|
Lines 167-180
static int _check_lustre_fs(void)
Link Here
|
| 167 |
*/ |
199 |
*/ |
| 168 |
static int _read_lustre_counters(void) |
200 |
static int _read_lustre_counters(void) |
| 169 |
{ |
201 |
{ |
| 170 |
char lustre_dir[PATH_MAX]; |
202 |
char *lustre_dir; |
| 171 |
DIR *proc_dir; |
203 |
DIR *proc_dir; |
| 172 |
struct dirent *entry; |
204 |
struct dirent *entry; |
| 173 |
FILE *fff; |
205 |
FILE *fff; |
| 174 |
char buffer[BUFSIZ]; |
206 |
char buffer[BUFSIZ]; |
| 175 |
|
207 |
|
| 176 |
|
208 |
lustre_dir = _llite_path(); |
| 177 |
snprintf(lustre_dir, PATH_MAX, "%s/llite", proc_base_path); |
209 |
if (!lustre_dir) { |
|
|
210 |
error("%s: can't find Lustre stats", __func__); |
| 211 |
return SLURM_ERROR; |
| 212 |
} |
| 178 |
|
213 |
|
| 179 |
proc_dir = opendir(lustre_dir); |
214 |
proc_dir = opendir(lustre_dir); |
| 180 |
if (proc_dir == NULL) { |
215 |
if (proc_dir == NULL) { |
| 181 |
- |
|
|