X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fliblustreapi.c;h=cd9e09447208fe90123cc18c6ef3bbce8d0929d8;hb=b53675ea643df1f9db8768975e89acb8f0ee081d;hp=155f5c33a5f7383fdb74dbd498afbdfe72edf744;hpb=a61ff5914bf6b784b22eea0625bb8b61d7bea950;p=fs%2Flustre-release.git diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 155f5c3..cd9e094 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -170,8 +170,8 @@ void llapi_printf(int level, char *fmt, ...) /** * size_units is to be initialized (or zeroed) by caller. */ -int parse_size(char *optarg, unsigned long long *size, - unsigned long long *size_units, int bytes_spec) +int llapi_parse_size(const char *optarg, unsigned long long *size, + unsigned long long *size_units, int bytes_spec) { char *end; @@ -524,7 +524,7 @@ static int get_param_lmv(const char *path, static int get_mds_md_size(const char *path) { - int md_size = lov_mds_md_size(LOV_MAX_STRIPE_COUNT, LOV_MAGIC_V3); + int md_size = lov_user_md_size(LOV_MAX_STRIPE_COUNT, LOV_USER_MAGIC_V3); char buf[80]; int rc; @@ -759,7 +759,8 @@ int llapi_dir_create_pool(const char *name, int flags, int stripe_offset, llapi_err_noerrno(LLAPI_MSG_ERROR, "error LL_IOC_LMV_SETSTRIPE '%s' : too large" "pool name: %s", name, pool_name); - GOTO(out, rc = -E2BIG); + rc = -E2BIG; + goto out; } memcpy(lmu.lum_pool_name, pool_name, strlen(pool_name)); } @@ -777,14 +778,14 @@ int llapi_dir_create_pool(const char *name, int flags, int stripe_offset, llapi_error(LLAPI_MSG_ERROR, rc, "error: LL_IOC_LMV_SETSTRIPE pack failed '%s'.", name); - GOTO(out, rc); + goto out; } fd = open(dir, O_DIRECTORY | O_RDONLY); if (fd < 0) { rc = -errno; llapi_error(LLAPI_MSG_ERROR, rc, "unable to open '%s'", name); - GOTO(out, rc); + goto out; } if (ioctl(fd, LL_IOC_LMV_SETSTRIPE, buf)) { @@ -827,7 +828,7 @@ int llapi_direntry_remove(char *dname) rc = -errno; llapi_error(LLAPI_MSG_ERROR, rc, "unable to open '%s'", filename); - GOTO(out, rc); + goto out; } if (ioctl(fd, LL_IOC_REMOVE_ENTRY, filename)) { @@ -1475,15 +1476,19 @@ static int llapi_semantic_traverse(char *path, int size, DIR *parent, } else if (!d && !parent) { /* ENOTDIR. Open the parent dir. */ p = opendir_parent(path); - if (!p) - GOTO(out, ret = -errno); + if (!p) { + ret = -errno; + goto out; + } } if (sem_init && (ret = sem_init(path, parent ?: p, d, data, de))) goto err; - if (!d || (param->get_lmv && !param->recursive)) - GOTO(out, ret = 0); + if (!d || (param->get_lmv && !param->recursive)) { + ret = 0; + goto out; + } while ((dent = readdir64(d)) != NULL) { param->have_fileinfo = 0; @@ -2186,10 +2191,12 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path, } } - if ((verbose & VERBOSE_DETAIL) && !is_dir) { - llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_pattern: %x%c", - lum->lmm_pattern, nl); - } + if ((verbose & VERBOSE_LAYOUT) && !is_dir) { + if (verbose & ~VERBOSE_LAYOUT) + llapi_printf(LLAPI_MSG_NORMAL, "%spattern: ", + prefix); + llapi_printf(LLAPI_MSG_NORMAL, "%.x%c", lum->lmm_pattern, nl); + } if ((verbose & VERBOSE_GENERATION) && !is_dir) { if (verbose & ~VERBOSE_GENERATION) @@ -2703,11 +2710,12 @@ static int cb_find_init(char *path, DIR *parent, DIR *dir, /* Request MDS for the stat info if some of these parameters need * to be compared. */ - if (param->obduuid || param->mdtuuid || param->check_uid || - param->check_gid || param->check_pool || param->atime || - param->ctime || param->mtime || param->check_size || - param->check_stripecount || param->check_stripesize) - decision = 0; + if (param->obduuid || param->mdtuuid || param->check_uid || + param->check_gid || param->check_pool || param->atime || + param->ctime || param->mtime || param->check_size || + param->check_stripecount || param->check_stripesize || + param->check_layout) + decision = 0; if (param->type && checked_type == 0) decision = 0; @@ -2812,6 +2820,18 @@ static int cb_find_init(char *path, DIR *parent, DIR *dir, goto decided; } + if (param->check_layout) { + __u32 found; + + found = (param->lmd->lmd_lmm.lmm_pattern & param->layout); + if ((param->lmd->lmd_lmm.lmm_pattern == 0xFFFFFFFF) || + (found && param->exclude_layout) || + (!found && !param->exclude_layout)) { + decision = -1; + goto decided; + } + } + /* If an OBD UUID is specified but none matches, skip this file. */ if ((param->obduuid && param->obdindex == OBD_NOT_FOUND) || (param->mdtuuid && param->mdtindex == OBD_NOT_FOUND)) @@ -3098,7 +3118,7 @@ static int cb_getstripe(char *path, DIR *parent, DIR *d, void *data, * The object_seq needs to be set for the "(Default)" * prefix to be displayed. */ struct lov_user_md *lmm = ¶m->lmd->lmd_lmm; - lmm->lmm_magic = LOV_MAGIC_V1; + lmm->lmm_magic = LOV_USER_MAGIC_V1; if (!param->raw) ostid_set_seq(&lmm->lmm_oi, FID_SEQ_LOV_DEFAULT); @@ -3464,7 +3484,9 @@ static int rmtacl_notify(int ops) close(fd); if (rc < 0) { rc = -errno; - llapi_error(LLAPI_MSG_ERROR, rc, "ioctl %d\n", fd); + llapi_error(LLAPI_MSG_ERROR, rc, + "ioctl RMTACL on '%s' err %d\n", + mnt->mnt_dir, rc); goto out; } @@ -4219,13 +4241,18 @@ int llapi_create_volatile_idx(char *directory, int idx, int mode) return -errno; } if (idx == -1) - sprintf(filename, LUSTRE_VOLATILE_HDR"::%.4X", random); + snprintf(filename, sizeof(filename), + LUSTRE_VOLATILE_HDR"::%.4X", random); else - sprintf(filename, LUSTRE_VOLATILE_IDX"%.4X", 0, random); + snprintf(filename, sizeof(filename), + LUSTRE_VOLATILE_IDX"%.4X", 0, random); - sprintf(file_path, "%s/%s", directory, filename); + rc = snprintf(file_path, sizeof(file_path), + "%s/%s", directory, filename); + if (rc >= sizeof(file_path)) + return -E2BIG; - fd = open(file_path, O_RDWR|O_CREAT|mode, S_IRUSR|S_IWUSR); + fd = open(file_path, (O_RDWR | O_CREAT | mode), (S_IRUSR | S_IWUSR)); if (fd < 0) { llapi_error(LLAPI_MSG_ERROR, errno, "Cannot create volatile file %s in %s\n",