- /* ensure level is in the good range */
- if (level < LLAPI_MSG_OFF)
- llapi_msg_level = LLAPI_MSG_OFF;
- else if (level > LLAPI_MSG_MAX)
- llapi_msg_level = LLAPI_MSG_MAX;
- else
- llapi_msg_level = level;
+ /* ensure level is in the good range */
+ if (level < LLAPI_MSG_OFF)
+ llapi_msg_level = LLAPI_MSG_OFF;
+ else if (level > LLAPI_MSG_MAX)
+ llapi_msg_level = LLAPI_MSG_MAX;
+ else
+ llapi_msg_level = level;
* @fmt is a const string, so we can't modify it directly.
*/
if (has_nl && (newfmt = strdup(fmt)))
* @fmt is a const string, so we can't modify it directly.
*/
if (has_nl && (newfmt = strdup(fmt)))
* but check the local page size just in case. The page_size
* will not change for the lifetime of this process at least.
*/
* but check the local page size just in case. The page_size
* will not change for the lifetime of this process at least.
*/
- llapi_error(LLAPI_MSG_ERROR, rc, "error: bad stripe_size %llu, "
- "must be an even multiple of %d bytes",
- (unsigned long long)stripe_size, page_size);
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "error: bad stripe_size %llu, must be an even multiple of %d bytes",
+ (unsigned long long)stripe_size, page_size);
}
int llapi_file_open(const char *name, int flags, int mode,
}
int llapi_file_open(const char *name, int flags, int mode,
- unsigned long long stripe_size, int stripe_offset,
- int stripe_count, int stripe_pattern)
+ unsigned long long stripe_size, int stripe_offset,
+ int stripe_count, int stripe_pattern)
- return llapi_file_open_pool(name, flags, mode, stripe_size,
- stripe_offset, stripe_count,
- stripe_pattern, NULL);
+ return llapi_file_open_pool(name, flags, mode, stripe_size,
+ stripe_offset, stripe_count,
+ stripe_pattern, NULL);
}
int llapi_file_create_foreign(const char *name, mode_t mode, __u32 type,
}
int llapi_file_create_foreign(const char *name, mode_t mode, __u32 type,
- fd = llapi_file_open_pool(name, O_CREAT | O_WRONLY, 0644, stripe_size,
- stripe_offset, stripe_count, stripe_pattern,
- NULL);
- if (fd < 0)
- return fd;
+ fd = llapi_file_open_pool(name, O_CREAT | O_WRONLY, 0644, stripe_size,
+ stripe_offset, stripe_count, stripe_pattern,
+ NULL);
+ if (fd < 0)
+ return fd;
- int stripe_offset, int stripe_count,
- int stripe_pattern, char *pool_name)
+ int stripe_offset, int stripe_count,
+ int stripe_pattern, char *pool_name)
- fd = llapi_file_open_pool(name, O_CREAT | O_WRONLY, 0644, stripe_size,
- stripe_offset, stripe_count, stripe_pattern,
- pool_name);
- if (fd < 0)
- return fd;
+ fd = llapi_file_open_pool(name, O_CREAT | O_WRONLY, 0644, stripe_size,
+ stripe_offset, stripe_count, stripe_pattern,
+ pool_name);
+ if (fd < 0)
+ return fd;
rc = ioctl(fd, LL_IOC_LMV_SET_DEFAULT_STRIPE, &lmu);
if (rc < 0) {
char *errmsg = "stripe already set";
rc = ioctl(fd, LL_IOC_LMV_SET_DEFAULT_STRIPE, &lmu);
if (rc < 0) {
char *errmsg = "stripe already set";
- while (1) {
- if (getmntent_r(fp, &mnt, buf, sizeof(buf)) == NULL)
- break;
+ while (1) {
+ if (getmntent_r(fp, &mnt, buf, sizeof(buf)) == NULL)
+ break;
ptr = strchr(mnt.mnt_fsname, '/');
while (ptr && *ptr == '/')
ptr++;
ptr = strchr(mnt.mnt_fsname, '/');
while (ptr && *ptr == '/')
ptr++;
/* Check the fsname for a match, if given */
mountlen = ptr_end - ptr;
/* Check the fsname for a match, if given */
mountlen = ptr_end - ptr;
(fsnamelen = strlen(fsname)) > 0 &&
(fsnamelen != mountlen ||
(strncmp(ptr, fsname, mountlen) != 0)))
(fsnamelen = strlen(fsname)) > 0 &&
(fsnamelen != mountlen ||
(strncmp(ptr, fsname, mountlen) != 0)))
if (path == NULL || strlen(path) == 0) {
strncpy(mntdir, mnt.mnt_dir, sizeof(mntdir) - 1);
mntdir[sizeof(mntdir) - 1] = '\0';
if (path == NULL || strlen(path) == 0) {
strncpy(mntdir, mnt.mnt_dir, sizeof(mntdir) - 1);
mntdir[sizeof(mntdir) - 1] = '\0';
* See function lfs_osts in lfs.c for an example of the index use.
*/
int llapi_search_mounts(const char *pathname, int index, char *mntdir,
* See function lfs_osts in lfs.c for an example of the index use.
*/
int llapi_search_mounts(const char *pathname, int index, char *mntdir,
- if (!pathname || pathname[0] == '\0') {
- want |= WANT_INDEX;
- idx = index;
- } else
- strcpy(mntdir, pathname);
+ if (!pathname || pathname[0] == '\0') {
+ want |= WANT_INDEX;
+ idx = index;
+ } else {
+ strcpy(mntdir, pathname);
+ }
- if (fsname)
- want |= WANT_FSNAME;
- return get_root_path(want, fsname, NULL, mntdir, idx);
+ if (fsname)
+ want |= WANT_FSNAME;
+ return get_root_path(want, fsname, NULL, mntdir, idx);
}
/* Given a path, find the corresponding Lustre fsname */
int llapi_search_fsname(const char *pathname, char *fsname)
{
}
/* Given a path, find the corresponding Lustre fsname */
int llapi_search_fsname(const char *pathname, char *fsname)
{
char realpath[PATH_MAX - 1];
if (getcwd(realpath, sizeof(realpath) - 2) == NULL) {
char realpath[PATH_MAX - 1];
if (getcwd(realpath, sizeof(realpath) - 2) == NULL) {
pathname[0] = 0;
return get_root_path(WANT_PATH, (char *)fsname, NULL, pathname, -1);
}
pathname[0] = 0;
return get_root_path(WANT_PATH, (char *)fsname, NULL, pathname, -1);
}
- rc = 0;
- while (fgets(buf, sizeof(buf), fd) != NULL) {
- if (nb_entries >= list_size) {
- rc = -EOVERFLOW;
- break;
- }
+ rc = 0;
+ while (fgets(buf, sizeof(buf), fd) != NULL) {
+ if (nb_entries >= list_size) {
+ rc = -EOVERFLOW;
+ break;
+ }
- /* remove '\n' */
- tmp = strchr(buf, '\n');
- if (tmp != NULL)
- *tmp='\0';
- if (used + strlen(buf) + 1 > buffer_size) {
- rc = -EOVERFLOW;
- break;
- }
-
- strcpy(buffer + used, buf);
- members[nb_entries] = buffer + used;
- used += strlen(buf) + 1;
- nb_entries++;
- rc = nb_entries;
- }
-
- fclose(fd);
- return rc;
+ /* remove '\n' */
+ tmp = strchr(buf, '\n');
+ if (tmp != NULL)
+ *tmp = '\0';
+ if (used + strlen(buf) + 1 > buffer_size) {
+ rc = -EOVERFLOW;
+ break;
+ }
+
+ strcpy(buffer + used, buf);
+ members[nb_entries] = buffer + used;
+ used += strlen(buf) + 1;
+ nb_entries++;
+ rc = nb_entries;
+ }
+
+ fclose(fd);
+ return rc;
* \retval -error failure
*/
int llapi_get_poollist(const char *name, char **poollist, int list_size,
* \retval -error failure
*/
int llapi_get_poollist(const char *name, char **poollist, int list_size,
}
sprintf(buffer + used, "%s.%s", fsname, pool->d_name);
}
sprintf(buffer + used, "%s.%s", fsname, pool->d_name);
char **list, *buffer = NULL, *fsname = (char *)name;
char *poolname = NULL, *tmp = NULL, data[16];
enum param_filter type = FILTER_BY_PATH;
char **list, *buffer = NULL, *fsname = (char *)name;
char *poolname = NULL, *tmp = NULL, data[16];
enum param_filter type = FILTER_BY_PATH;
- /* Allocate space for each fsname-OST0000_UUID, 1 per OST,
- * and also an array to store the pointers for all that
- * allocated space. */
+ /*
+ * Allocate space for each fsname-OST0000_UUID, 1 per OST,
+ * and also an array to store the pointers for all that
+ * allocated space.
+ */
- bufsize = sizeof(struct obd_uuid) * obdcount;
- buffer = realloc(tmp, bufsize + sizeof(*list) * obdcount);
- if (buffer == NULL) {
- rc = -ENOMEM;
- goto err;
- }
- list = (char **) (buffer + bufsize);
-
- if (!poolname) {
- /* name is a path or fsname */
- nb = llapi_get_poollist(name, list, obdcount,
- buffer, bufsize);
- } else {
- /* name is a pool name (<fsname>.<poolname>) */
- nb = llapi_get_poolmembers(name, list, obdcount,
- buffer, bufsize);
- }
-
- if (nb == -EOVERFLOW) {
- obdcount *= 2;
- tmp = buffer;
- goto retry_get_pools;
- }
-
- for (i = 0; i < nb; i++)
- llapi_printf(LLAPI_MSG_NORMAL, "%s\n", list[i]);
- rc = (nb < 0 ? nb : 0);
+ bufsize = sizeof(struct obd_uuid) * obdcount;
+ buffer = realloc(tmp, bufsize + sizeof(*list) * obdcount);
+ if (buffer == NULL) {
+ rc = -ENOMEM;
+ goto err;
+ }
+ list = (char **) (buffer + bufsize);
+
+ if (!poolname) {
+ /* name is a path or fsname */
+ nb = llapi_get_poollist(name, list, obdcount,
+ buffer, bufsize);
+ } else {
+ /* name is a pool name (<fsname>.<poolname>) */
+ nb = llapi_get_poolmembers(name, list, obdcount,
+ buffer, bufsize);
+ }
+
+ if (nb == -EOVERFLOW) {
+ obdcount *= 2;
+ tmp = buffer;
+ goto retry_get_pools;
+ }
+
+ for (i = 0; i < nb; i++)
+ llapi_printf(LLAPI_MSG_NORMAL, "%s\n", list[i]);
+ rc = (nb < 0 ? nb : 0);
stripe_count = lmv_foreign_to_md_stripes(size);
} else {
llapi_error(LLAPI_MSG_ERROR, -EINVAL,
stripe_count = lmv_foreign_to_md_stripes(size);
} else {
llapi_error(LLAPI_MSG_ERROR, -EINVAL,
* and returns struct lov_user_mds_data, while
* LL_IOC_LOV_GETSTRIPE returns only struct lov_user_md.
*/
* and returns struct lov_user_mds_data, while
* LL_IOC_LOV_GETSTRIPE returns only struct lov_user_md.
*/
} else if (parent_fd >= 0) {
const char *fname = strrchr(path, '/');
} else if (parent_fd >= 0) {
const char *fname = strrchr(path, '/');
* the parent directory) and returns struct lov_user_mds_data,
* while IOC_MDC_GETFILESTRIPE returns only struct lov_user_md.
*
* the parent directory) and returns struct lov_user_mds_data,
* while IOC_MDC_GETFILESTRIPE returns only struct lov_user_md.
*
* Do the regular lstat(2) instead.
*/
ret = lstat_f(path, &st);
* Do the regular lstat(2) instead.
*/
ret = lstat_f(path, &st);
- d = opendir(path);
- if (!d && errno != ENOTDIR) {
- ret = -errno;
- llapi_error(LLAPI_MSG_ERROR, ret, "%s: Failed to open '%s'",
- __func__, path);
- return ret;
- } else if (!d && !parent) {
- /* ENOTDIR. Open the parent dir. */
- p = opendir_parent(path);
+ d = opendir(path);
+ if (!d && errno != ENOTDIR) {
+ ret = -errno;
+ llapi_error(LLAPI_MSG_ERROR, ret, "%s: Failed to open '%s'",
+ __func__, path);
+ return ret;
+ } else if (!d && !parent) {
+ /* ENOTDIR. Open the parent dir. */
+ p = opendir_parent(path);
if (sem_init && (ret = sem_init(path, parent ?: p, &d, data, de)))
goto err;
if (sem_init && (ret = sem_init(path, parent ?: p, &d, data, de)))
goto err;
- switch (dent->d_type) {
- case DT_UNKNOWN:
- llapi_err_noerrno(LLAPI_MSG_ERROR,
- "error: %s: '%s' is UNKNOWN type %d",
- __func__, dent->d_name, dent->d_type);
- break;
+ switch (dent->d_type) {
+ case DT_UNKNOWN:
+ llapi_err_noerrno(LLAPI_MSG_ERROR,
+ "error: %s: '%s' is UNKNOWN type %d",
+ __func__, dent->d_name, dent->d_type);
+ break;
case DT_DIR:
rc = llapi_semantic_traverse(path, size, d, sem_init,
sem_fini, data, dent);
case DT_DIR:
rc = llapi_semantic_traverse(path, size, d, sem_init,
sem_fini, data, dent);
}
if (sem_fini && rc == 0)
sem_fini(path, d, NULL, data, dent);
}
if (sem_fini && rc == 0)
sem_fini(path, d, NULL, data, dent);
if (sem_fini)
sem_fini(path, parent, &d, data, de);
err:
if (sem_fini)
sem_fini(path, parent, &d, data, de);
err:
- if (len > PATH_MAX) {
- ret = -EINVAL;
- llapi_error(LLAPI_MSG_ERROR, ret,
- "Path name '%s' is too long", path);
- return ret;
- }
+ if (len > PATH_MAX) {
+ ret = -EINVAL;
+ llapi_error(LLAPI_MSG_ERROR, ret,
+ "Path name '%s' is too long", path);
+ return ret;
+ }
snprintf(buf, PATH_MAX + 1, "%s", path);
snprintf(buf, PATH_MAX + 1, "%s", path);
- ret = llapi_semantic_traverse(buf, PATH_MAX + 1, NULL, sem_init,
- sem_fini, param, NULL);
+ ret = llapi_semantic_traverse(buf, PATH_MAX + 1, NULL, sem_init,
+ sem_fini, param, NULL);
- int rc = ioctl(fd, OBD_IOC_GETMDNAME, lov_name);
- if (rc) {
- rc = -errno;
- llapi_error(LLAPI_MSG_ERROR, rc, "error: can't get lmv name.");
- }
- return rc;
+ int rc = ioctl(fd, OBD_IOC_GETMDNAME, lov_name);
+
+ if (rc) {
+ rc = -errno;
+ llapi_error(LLAPI_MSG_ERROR, rc, "error: can't get lmv name.");
+ }
+ return rc;
* the ost_count set to number of available obd uuids.
*/
static int llapi_get_target_uuids(int fd, struct obd_uuid *uuidp,
* the ost_count set to number of available obd uuids.
*/
static int llapi_get_target_uuids(int fd, struct obd_uuid *uuidp,
while (fgets(buf, sizeof(buf), fp) != NULL) {
if (uuidp && (index < *ost_count)) {
if (sscanf(buf, format, &index, uuidp[index].uuid) < 2)
while (fgets(buf, sizeof(buf), fp) != NULL) {
if (uuidp && (index < *ost_count)) {
if (sscanf(buf, format, &index, uuidp[index].uuid) < 2)
- return llapi_get_target_uuids(fd, uuidp, ost_count, LOV_TYPE);
+ return llapi_get_target_uuids(fd, uuidp, ost_count, LOV_TYPE);
* -osc-4ba41334, other trailing gunk in comparison.
* @param real_uuid ends in "_UUID"
* @param search_uuid may or may not end in "_UUID"
*/
int llapi_uuid_match(char *real_uuid, char *search_uuid)
{
* -osc-4ba41334, other trailing gunk in comparison.
* @param real_uuid ends in "_UUID"
* @param search_uuid may or may not end in "_UUID"
*/
int llapi_uuid_match(char *real_uuid, char *search_uuid)
{
- if (cmplen > 5 && strcmp(real_uuid + cmplen - 5, "_UUID") == 0)
- cmplen -= 5;
- if (searchlen > 5 && strcmp(search_uuid + searchlen - 5, "_UUID") == 0)
- searchlen -= 5;
+ if (cmplen > 5 && strcmp(real_uuid + cmplen - 5, "_UUID") == 0)
+ cmplen -= 5;
+ if (searchlen > 5 && strcmp(search_uuid + searchlen - 5, "_UUID") == 0)
+ searchlen -= 5;
- /* The UUIDs may legitimately be different lengths, if
- * the system was upgraded from an older version. */
- if (cmplen != searchlen)
- return 0;
+ /*
+ * The UUIDs may legitimately be different lengths, if
+ * the system was upgraded from an older version.
+ */
+ if (cmplen != searchlen)
+ return 0;
-/* Here, param->fp_obd_uuid points to a single obduuid, the index of which is
- * returned in param->fp_obd_index */
+/*
+ * Here, param->fp_obd_uuid points to a single obduuid, the index of which is
+ * returned in param->fp_obd_index
+ */
static int setup_obd_uuid(int fd, char *dname, struct find_param *param)
{
struct obd_uuid obd_uuid;
static int setup_obd_uuid(int fd, char *dname, struct find_param *param)
{
struct obd_uuid obd_uuid;
if (param->fp_obd_uuid && (param->fp_obd_index == OBD_NOT_FOUND)) {
llapi_err_noerrno(LLAPI_MSG_ERROR,
if (param->fp_obd_uuid && (param->fp_obd_index == OBD_NOT_FOUND)) {
llapi_err_noerrno(LLAPI_MSG_ERROR,
static int setup_indexes(DIR *dir, char *path, struct obd_uuid *obduuids,
static int setup_indexes(DIR *dir, char *path, struct obd_uuid *obduuids,
- int num_obds, int **obdindexes, int *obdindex,
- enum tgt_type type)
+ int num_obds, int **obdindexes, int *obdindex,
+ enum tgt_type type)
{
int ret, obdcount, obd_valid = 0, obdnum;
long i;
{
int ret, obdcount, obd_valid = 0, obdnum;
long i;
if (type == LOV_TYPE)
ret = get_param_lov(path, "numobd", buf, sizeof(buf));
if (type == LOV_TYPE)
ret = get_param_lov(path, "numobd", buf, sizeof(buf));
- indexes = malloc(num_obds * sizeof(*obdindex));
- if (indexes == NULL) {
- ret = -ENOMEM;
- goto out_free;
- }
-
- for (obdnum = 0; obdnum < num_obds; obdnum++) {
- char *end = NULL;
-
- /* The user may have specified a simple index */
- i = strtol(obduuids[obdnum].uuid, &end, 0);
- if (end && *end == '\0' && i < obdcount) {
- indexes[obdnum] = i;
- obd_valid++;
- } else {
- for (i = 0; i < obdcount; i++) {
- if (llapi_uuid_match(uuids[i].uuid,
- obduuids[obdnum].uuid)) {
- indexes[obdnum] = i;
- obd_valid++;
- break;
- }
- }
- }
+ indexes = malloc(num_obds * sizeof(*obdindex));
+ if (indexes == NULL) {
+ ret = -ENOMEM;
+ goto out_free;
+ }
+
+ for (obdnum = 0; obdnum < num_obds; obdnum++) {
+ char *end = NULL;
+
+ /* The user may have specified a simple index */
+ i = strtol(obduuids[obdnum].uuid, &end, 0);
+ if (end && *end == '\0' && i < obdcount) {
+ indexes[obdnum] = i;
+ obd_valid++;
+ } else {
+ for (i = 0; i < obdcount; i++) {
+ if (llapi_uuid_match(uuids[i].uuid,
+ obduuids[obdnum].uuid)) {
+ indexes[obdnum] = i;
+ obd_valid++;
+ break;
+ }
+ }
+ }
if (i >= obdcount) {
indexes[obdnum] = OBD_NOT_FOUND;
llapi_err_noerrno(LLAPI_MSG_ERROR,
if (i >= obdcount) {
indexes[obdnum] = OBD_NOT_FOUND;
llapi_err_noerrno(LLAPI_MSG_ERROR,
if (param->fp_mdt_uuid) {
ret = setup_indexes(dir, path, param->fp_mdt_uuid,
if (param->fp_mdt_uuid) {
ret = setup_indexes(dir, path, param->fp_mdt_uuid,
const char *const pathname, unsigned int *scount,
unsigned int *ssize, unsigned int *soffset)
{
const char *const pathname, unsigned int *scount,
unsigned int *ssize, unsigned int *soffset)
{
- static struct {
- char fsname[PATH_MAX + 1];
- unsigned int stripecount;
- unsigned int stripesize;
- unsigned int stripeoffset;
- } cache = {
- .fsname = {'\0'}
- };
-
- int rc;
- char fsname_buf[PATH_MAX + 1];
- unsigned int tmp[3];
-
- if (fsname == NULL) {
- rc = llapi_search_fsname(pathname, fsname_buf);
- if (rc)
- return rc;
- } else {
+ static struct {
+ char fsname[PATH_MAX + 1];
+ unsigned int stripecount;
+ unsigned int stripesize;
+ unsigned int stripeoffset;
+ } cache = {
+ .fsname = {'\0'}
+ };
+
+ int rc;
+ char fsname_buf[PATH_MAX + 1];
+ unsigned int tmp[3];
+
+ if (fsname == NULL) {
+ rc = llapi_search_fsname(pathname, fsname_buf);
+ if (rc)
+ return rc;
+ } else {
snprintf(fsname_buf, sizeof(fsname_buf), "%s", fsname);
snprintf(fsname_buf, sizeof(fsname_buf), "%s", fsname);
- /*
- * Ensure all 3 sattrs (count, size, and offset) are
- * successfully retrieved and stored in tmp before writing to
- * cache.
- */
+ /*
+ * Ensure all 3 sattrs (count, size, and offset) are
+ * successfully retrieved and stored in tmp before writing to
+ * cache.
+ */
rc = sattr_get_defaults(fsname_buf, &tmp[0], &tmp[1], &tmp[2]);
rc = sattr_get_defaults(fsname_buf, &tmp[0], &tmp[1], &tmp[2]);
- cache.stripecount = tmp[0];
- cache.stripesize = tmp[1];
- cache.stripeoffset = tmp[2];
+ cache.stripecount = tmp[0];
+ cache.stripesize = tmp[1];
+ cache.stripeoffset = tmp[2];
snprintf(cache.fsname, sizeof(cache.fsname), "%s", fsname_buf);
snprintf(cache.fsname, sizeof(cache.fsname), "%s", fsname_buf);
- if (scount)
- *scount = cache.stripecount;
- if (ssize)
- *ssize = cache.stripesize;
- if (soffset)
- *soffset = cache.stripeoffset;
+ if (scount)
+ *scount = cache.stripecount;
+ if (ssize)
+ *ssize = cache.stripesize;
+ if (soffset)
+ *soffset = cache.stripeoffset;
if (verbose & ~VERBOSE_DFID)
llapi_printf(LLAPI_MSG_NORMAL, "%slmm_fid: ",
space);
if (verbose & ~VERBOSE_DFID)
llapi_printf(LLAPI_MSG_NORMAL, "%slmm_fid: ",
space);
* have { oi.oi_id = mds_inum, oi.oi_seq = 0 } and 2.x lmm_oi
* have { oi.oi_id = mds_oid, oi.oi_seq = mds_seq } instead of
* a real FID. Ideally the 2.x code would have stored this
* have { oi.oi_id = mds_inum, oi.oi_seq = 0 } and 2.x lmm_oi
* have { oi.oi_id = mds_oid, oi.oi_seq = mds_seq } instead of
* a real FID. Ideally the 2.x code would have stored this
* oi_fid fields are in the right order. This is why there are
* separate lmm_oi_seq() and lmm_oi_id() routines for this.
*
* oi_fid fields are in the right order. This is why there are
* separate lmm_oi_seq() and lmm_oi_id() routines for this.
*
seq = lmm_oi_seq(&lum->lmm_oi) == 0 ?
lmm_oi_id(&lum->lmm_oi) : lmm_oi_seq(&lum->lmm_oi);
oid = lmm_oi_seq(&lum->lmm_oi) == 0 ?
seq = lmm_oi_seq(&lum->lmm_oi) == 0 ?
lmm_oi_id(&lum->lmm_oi) : lmm_oi_seq(&lum->lmm_oi);
oid = lmm_oi_seq(&lum->lmm_oi) == 0 ?
rc = sattr_cache_get_defaults(NULL, path, NULL, &ssize,
NULL);
if (rc == 0)
llapi_printf(LLAPI_MSG_NORMAL, "%u", ssize);
else
llapi_error(LLAPI_MSG_ERROR, rc,
rc = sattr_cache_get_defaults(NULL, path, NULL, &ssize,
NULL);
if (rc == 0)
llapi_printf(LLAPI_MSG_NORMAL, "%u", ssize);
else
llapi_error(LLAPI_MSG_ERROR, rc,
} else {
/* Extension size is in KiB */
llapi_printf(LLAPI_MSG_NORMAL, "%llu",
} else {
/* Extension size is in KiB */
llapi_printf(LLAPI_MSG_NORMAL, "%llu",
space, i, idx, PFID(&fid));
} else {
char fmt[48];
space, i, idx, PFID(&fid));
} else {
char fmt[48];
for (i = 0; i < lum->lum_stripe_count; i++) {
int idx = objects[i].lum_mds;
struct lu_fid *fid = &objects[i].lum_fid;
for (i = 0; i < lum->lum_stripe_count; i++) {
int idx = objects[i].lum_mds;
struct lu_fid *fid = &objects[i].lum_fid;
if ((obdindex == OBD_NOT_FOUND) || (obdindex == idx))
llapi_printf(LLAPI_MSG_NORMAL,
"%6u\t\t "DFID"\t\t%s\n",
idx, PFID(fid),
obdindex == idx ? " *" : "");
}
if ((obdindex == OBD_NOT_FOUND) || (obdindex == idx))
llapi_printf(LLAPI_MSG_NORMAL,
"%6u\t\t "DFID"\t\t%s\n",
idx, PFID(fid),
obdindex == idx ? " *" : "");
}
* @mds indicates if this is MDS timestamps and there are attributes on OSTs.
*
* The result is -1 if it does not match, 0 if not yet clear, 1 if matches.
* @mds indicates if this is MDS timestamps and there are attributes on OSTs.
*
* The result is -1 if it does not match, 0 if not yet clear, 1 if matches.
* 9 | file < limit; sign < 0 | ? / -1 |
* --------------------------------------
* Note: 5th actually means that the value is within the interval
* 9 | file < limit; sign < 0 | ? / -1 |
* --------------------------------------
* Note: 5th actually means that the value is within the interval
static int find_value_cmp(unsigned long long file, unsigned long long limit,
int sign, int negopt, unsigned long long margin,
bool mds)
static int find_value_cmp(unsigned long long file, unsigned long long limit,
int sign, int negopt, unsigned long long margin,
bool mds)
- llapi_printf(LLAPI_MSG_NORMAL, "unknown lmm_magic: %#x "
- "(expecting one of %#x %#x %#x %#x)\n",
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "unknown lmm_magic: %#x (expecting one of %#x %#x %#x %#x)\n",
*(__u32 *)¶m->fp_lmd->lmd_lmm,
LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3,
LMV_USER_MAGIC, LMV_MAGIC_V1);
*(__u32 *)¶m->fp_lmd->lmd_lmm,
LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3,
LMV_USER_MAGIC, LMV_MAGIC_V1);
- data.ioc_version = OBD_IOCTL_VERSION;
- data.ioc_len = sizeof(data);
- data.ioc_inlbuf1 = (char *)name;
- data.ioc_inllen1 = strlen(name) + 1;
+ data.ioc_version = OBD_IOCTL_VERSION;
+ data.ioc_len = sizeof(data);
+ data.ioc_inlbuf1 = (char *)name;
+ data.ioc_inllen1 = strlen(name) + 1;
- if (rc) {
- llapi_error(LLAPI_MSG_ERROR, rc,
- "error: IOC_MDC_LOOKUP pack failed for '%s': rc %d",
- name, rc);
- return rc;
- }
+ if (rc) {
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "error: IOC_MDC_LOOKUP pack failed for '%s': rc %d",
+ name, rc);
+ return rc;
+ }
* Return -1 or 1 if file timestamp does not or does match the given criteria
* correspondingly. Return 0 if the MDS time is being checked and there are
* attributes on OSTs and it is not yet clear if the timespamp matches.
*
* If 0 is returned, we need to do another RPC to the OSTs to obtain the
* Return -1 or 1 if file timestamp does not or does match the given criteria
* correspondingly. Return 0 if the MDS time is being checked and there are
* attributes on OSTs and it is not yet clear if the timespamp matches.
*
* If 0 is returned, we need to do another RPC to the OSTs to obtain the
static int find_time_check(struct find_param *param, int mds)
{
struct lov_user_mds_data *lmd = param->fp_lmd;
static int find_time_check(struct find_param *param, int mds)
{
struct lov_user_mds_data *lmd = param->fp_lmd;
- /* If the previous check matches, but this one is not yet clear,
- * we should return 0 to do an RPC on OSTs. */
+ /*
+ * If the previous check matches, but this one is not yet clear,
+ * we should return 0 to do an RPC on OSTs.
+ */
- /* If the previous check matches, but this one is not yet clear,
- * we should return 0 to do an RPC on OSTs. */
+ /*
+ * If the previous check matches, but this one is not yet clear,
+ * we should return 0 to do an RPC on OSTs.
+ */
- /* Only those files should be accepted, which have a
- * stripe on the specified OST. */
+ /*
+ * Only those files should be accepted, which have a
+ * stripe on the specified OST.
+ */
if (v1->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
comp_v1 = (struct lov_comp_md_v1 *)v1;
count = comp_v1->lcm_entry_count;
if (v1->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
comp_v1 = (struct lov_comp_md_v1 *)v1;
count = comp_v1->lcm_entry_count;
- memset(&stat_buf, 0, sizeof(struct obd_statfs));
- memset(&uuid_buf, 0, sizeof(struct obd_uuid));
+ memset(&stat_buf, 0, sizeof(struct obd_statfs));
+ memset(&uuid_buf, 0, sizeof(struct obd_uuid));
ret = llapi_obd_statfs(path, type,
type == LL_STATFS_LOV ? param->fp_obd_index :
param->fp_mdt_index, &stat_buf,
ret = llapi_obd_statfs(path, type,
type == LL_STATFS_LOV ? param->fp_obd_index :
param->fp_mdt_index, &stat_buf,
* if type specified, check all foreign&type and exclude !foreign + foreign&type
*/
static int find_check_foreign(struct find_param *param)
* if type specified, check all foreign&type and exclude !foreign + foreign&type
*/
static int find_check_foreign(struct find_param *param)
/* If a regular expression is presented, make the initial decision */
if (param->fp_pattern != NULL) {
char *fname = strrchr(path, '/');
/* If a regular expression is presented, make the initial decision */
if (param->fp_pattern != NULL) {
char *fname = strrchr(path, '/');
fname = (fname == NULL ? path : fname + 1);
ret = fnmatch(param->fp_pattern, fname, 0);
if ((ret == FNM_NOMATCH && !param->fp_exclude_pattern) ||
fname = (fname == NULL ? path : fname + 1);
ret = fnmatch(param->fp_pattern, fname, 0);
if ((ret == FNM_NOMATCH && !param->fp_exclude_pattern) ||
if (param->fp_obd_uuid || param->fp_mdt_uuid ||
param->fp_check_uid || param->fp_check_gid ||
param->fp_newerxy || param->fp_btime ||
if (param->fp_obd_uuid || param->fp_mdt_uuid ||
param->fp_check_uid || param->fp_check_gid ||
param->fp_newerxy || param->fp_btime ||
- /* We need to "fake" the "use the default" values
- * since the lmm struct is zeroed out at this point. */
+ /*
+ * We need to "fake" the "use the default" values
+ * since the lmm struct is zeroed out at this point.
+ */
ret = llapi_file_fget_mdtidx(dirfd(dir),
¶m->fp_file_mdt_index);
} else if (S_ISREG(lmd->lmd_stx.stx_mode)) {
ret = llapi_file_fget_mdtidx(dirfd(dir),
¶m->fp_file_mdt_index);
} else if (S_ISREG(lmd->lmd_stx.stx_mode)) {
* file's FID in lmd->lmd_lmm.lmm_oi without
* opening the file, once we are sure that
* LFSCK2 (2.6) has fixed up pre-2.0 LOV EAs.
* That would still be an ioctl() to map the
* file's FID in lmd->lmd_lmm.lmm_oi without
* opening the file, once we are sure that
* LFSCK2 (2.6) has fixed up pre-2.0 LOV EAs.
* That would still be an ioctl() to map the
fd = open(path, O_RDONLY);
if (fd > 0) {
ret = llapi_file_fget_mdtidx(fd,
fd = open(path, O_RDONLY);
if (fd > 0) {
ret = llapi_file_fget_mdtidx(fd,
- /* For a special file, we assume it resides on
- * the same MDT as the parent directory. */
+ /*
+ * For a special file, we assume it resides on
+ * the same MDT as the parent directory.
+ */
ret = llapi_file_fget_mdtidx(dirfd(parent),
¶m->fp_file_mdt_index);
}
ret = llapi_file_fget_mdtidx(dirfd(parent),
¶m->fp_file_mdt_index);
}
if (param->fp_obd_uuid || param->fp_mdt_uuid) {
if (lustre_fs && param->fp_got_uuids &&
param->fp_dev != makedev(lmd->lmd_stx.stx_dev_major,
if (param->fp_obd_uuid || param->fp_mdt_uuid) {
if (lustre_fs && param->fp_got_uuids &&
param->fp_dev != makedev(lmd->lmd_stx.stx_dev_major,
if (param->fp_obd_index != OBD_NOT_FOUND ||
param->fp_mdt_index != OBD_NOT_FOUND) {
if (param->fp_obd_uuid) {
if (check_obd_match(param)) {
if (param->fp_obd_index != OBD_NOT_FOUND ||
param->fp_mdt_index != OBD_NOT_FOUND) {
if (param->fp_obd_uuid) {
if (check_obd_match(param)) {
- /* For regular files with the stripe the decision may have not
- * been taken yet if *time or size is to be checked. */
+ /*
+ * For regular files with the stripe the decision may have not
+ * been taken yet if *time or size is to be checked.
+ */
ret = ioctl(fd, LL_IOC_MIGRATE, rawbuf);
if (ret != 0) {
if (errno == EBUSY && !retry) {
ret = ioctl(fd, LL_IOC_MIGRATE, rawbuf);
if (ret != 0) {
if (errno == EBUSY && !retry) {
* objects in order, for some of them it try lock, while
* there may be conflicting COS locks and cause migrate
* fail with EBUSY, hope a sync() could cause
* objects in order, for some of them it try lock, while
* there may be conflicting COS locks and cause migrate
* fail with EBUSY, hope a sync() could cause
* close the directory after migration,
* so the old directory cache will be cleanup
* on the client side, and re-open to get the
* close the directory after migration,
* so the old directory cache will be cleanup
* on the client side, and re-open to get the
- return param_callback(path, cb_find_init, cb_common_fini, param);
+ return param_callback(path, cb_find_init, cb_common_fini, param);
}
static int cb_get_mdt_index(char *path, DIR *parent, DIR **dirp, void *data,
}
static int cb_get_mdt_index(char *path, DIR *parent, DIR **dirp, void *data,
static int cb_getstripe(char *path, DIR *parent, DIR **dirp, void *data,
struct dirent64 *de)
{
static int cb_getstripe(char *path, DIR *parent, DIR **dirp, void *data,
struct dirent64 *de)
{
* since the lmm struct is zeroed out at this point.
* The magic needs to be set in order to satisfy
* a check later on in the code path.
* The object_seq needs to be set for the "(Default)"
* since the lmm struct is zeroed out at this point.
* The magic needs to be set in order to satisfy
* a check later on in the code path.
* The object_seq needs to be set for the "(Default)"
- llapi_printf(LLAPI_MSG_NORMAL,
- "%s has no stripe info\n", path);
- goto out;
- } else if (errno == ENOENT) {
- llapi_error(LLAPI_MSG_WARN, -ENOENT,
- "warning: %s: %s does not exist",
- __func__, path);
- goto out;
- } else if (errno == ENOTTY) {
- ret = -errno;
- llapi_error(LLAPI_MSG_ERROR, ret,
- "%s: '%s' not on a Lustre fs?",
- __func__, path);
- } else {
- ret = -errno;
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%s has no stripe info\n", path);
+ goto out;
+ } else if (errno == ENOENT) {
+ llapi_error(LLAPI_MSG_WARN, -ENOENT,
+ "warning: %s: %s does not exist",
+ __func__, path);
+ goto out;
+ } else if (errno == ENOTTY) {
+ ret = -errno;
+ llapi_error(LLAPI_MSG_ERROR, ret,
+ "%s: '%s' not on a Lustre fs?",
+ __func__, path);
+ } else {
+ ret = -errno;
err_out:
llapi_error(LLAPI_MSG_ERROR, ret,
"error: %s: %s failed for %s",
err_out:
llapi_error(LLAPI_MSG_ERROR, ret,
"error: %s: %s failed for %s",
int llapi_getstripe(char *path, struct find_param *param)
{
return param_callback(path, (param->fp_verbose & VERBOSE_MDTINDEX) ?
int llapi_getstripe(char *path, struct find_param *param)
{
return param_callback(path, (param->fp_verbose & VERBOSE_MDTINDEX) ?
- cb_get_mdt_index : cb_getstripe,
- cb_common_fini, param);
+ cb_get_mdt_index : cb_getstripe,
+ cb_common_fini, param);
}
int llapi_obd_fstatfs(int fd, __u32 type, __u32 index,
struct obd_statfs *stat_buf, struct obd_uuid *uuid_buf)
{
char raw[MAX_IOC_BUFLEN] = {'\0'};
}
int llapi_obd_fstatfs(int fd, __u32 type, __u32 index,
struct obd_statfs *stat_buf, struct obd_uuid *uuid_buf)
{
char raw[MAX_IOC_BUFLEN] = {'\0'};
- char *rawbuf = raw;
- struct obd_ioctl_data data = { 0 };
- int rc = 0;
-
- data.ioc_inlbuf1 = (char *)&type;
- data.ioc_inllen1 = sizeof(__u32);
- data.ioc_inlbuf2 = (char *)&index;
- data.ioc_inllen2 = sizeof(__u32);
- data.ioc_pbuf1 = (char *)stat_buf;
- data.ioc_plen1 = sizeof(struct obd_statfs);
- data.ioc_pbuf2 = (char *)uuid_buf;
- data.ioc_plen2 = sizeof(struct obd_uuid);
+ char *rawbuf = raw;
+ struct obd_ioctl_data data = { 0 };
+ int rc = 0;
+
+ data.ioc_inlbuf1 = (char *)&type;
+ data.ioc_inllen1 = sizeof(__u32);
+ data.ioc_inlbuf2 = (char *)&index;
+ data.ioc_inllen2 = sizeof(__u32);
+ data.ioc_pbuf1 = (char *)stat_buf;
+ data.ioc_plen1 = sizeof(struct obd_statfs);
+ data.ioc_pbuf2 = (char *)uuid_buf;
+ data.ioc_plen2 = sizeof(struct obd_uuid);
- if (rc != 0) {
- llapi_error(LLAPI_MSG_ERROR, rc,
- "llapi_obd_statfs: error packing ioctl data");
- return rc;
- }
+ if (rc != 0) {
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "llapi_obd_statfs: error packing ioctl data");
+ return rc;
+ }
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc, "error: %s: opening '%s'",
__func__, path);
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc, "error: %s: opening '%s'",
__func__, path);
- /* If we can't even open a file on the filesystem (e.g. with
- * -ESHUTDOWN), force caller to exit or it will loop forever. */
+ /*
+ * If we can't even open a file on the filesystem (e.g. with
+ * -ESHUTDOWN), force caller to exit or it will loop forever.
+ */
- rc = llapi_ping(obd_type_name, obd_name);
- if (rc == ENOTCONN) {
- llapi_printf(LLAPI_MSG_NORMAL, "%s inactive.\n", obd_name);
- } else if (rc) {
- llapi_error(LLAPI_MSG_ERROR, rc, "error: check '%s'", obd_name);
- } else {
- llapi_printf(LLAPI_MSG_NORMAL, "%s active.\n", obd_name);
- }
+ rc = llapi_ping(obd_type_name, obd_name);
+ if (rc == ENOTCONN)
+ llapi_printf(LLAPI_MSG_NORMAL, "%s inactive.\n", obd_name);
+ else if (rc)
+ llapi_error(LLAPI_MSG_ERROR, rc, "error: check '%s'", obd_name);
+ else
+ llapi_printf(LLAPI_MSG_NORMAL, "%s active.\n", obd_name);
- return llapi_target_iterate(type_num, obd_type, NULL, do_target_check);
+ return llapi_target_iterate(type_num, obd_type, NULL, do_target_check);
- return (llapi_is_lustre_mnttype(mnt->mnt_type) &&
- strstr(mnt->mnt_fsname, ":/") != NULL);
+ return (llapi_is_lustre_mnttype(mnt->mnt_type) &&
+ strstr(mnt->mnt_fsname, ":/") != NULL);