From: jacob Date: Fri, 1 Apr 2005 20:52:21 +0000 (+0000) Subject: b=3048 X-Git-Tag: v1_8_0_110~486^7~71 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=d2d23d9bd2d8b0de3b1582914f0781c89fcf9722;p=fs%2Flustre-release.git b=3048 r=me, originally from adilger Moves the checking for stripe sizes into the lib, so all callers get this. Properly checks for dirstripe default removal, and always prints the directory default striping. --- diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 6eb898e..7ab020e 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -160,7 +160,7 @@ command_t cmdlist[] = { "usage: lov_modify_tgts add|del "}, {"lov_getconfig", jt_obd_lov_getconfig, 0, "read lov configuration from an mds device\n" - "usage: lov_getconfig /mount/path"}, + "usage: lov_getconfig "}, {"record", jt_cfg_record, 0, "record commands that follow in log\n" "usage: record cfg-uuid-name"}, {"endrecord", jt_cfg_endrecord, 0, "stop recording\n" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 449f676..cccb397 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -93,7 +93,6 @@ static int lfs_setstripe(int argc, char **argv) long st_size; int st_offset, st_count; char *end; - int page_size; if (argc != 5 && argc != 3) return CMD_HELP; @@ -117,19 +116,6 @@ static int lfs_setstripe(int argc, char **argv) argv[0], argv[2]); return CMD_HELP; } - /* 64 KB is the largest common page size I'm aware of (on ia64), but - * check the local page size just in case. */ - page_size = 65536; - if (getpagesize() > page_size) { - fprintf(stderr, "WARNING: your page size (%d) is larger than " - "expected.\n", getpagesize()); - page_size = getpagesize(); - } - if (st_size % page_size) { - fprintf(stderr, "FATAL: stripe_size must be an even multiple " - "of %d bytes.\n", page_size); - return CMD_HELP; - } // get the stripe offset st_offset = strtoul(argv[3], &end, 0); diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index fa51411..9684127 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -53,7 +53,7 @@ static void err_msg(char *fmt, ...) { va_list args; - int tmp_errno = errno; + int tmp_errno = abs(errno); va_start(args, fmt); vfprintf(stderr, fmt, args); @@ -67,13 +67,7 @@ int llapi_file_create(char *name, long stripe_size, int stripe_offset, struct lov_user_md lum = { 0 }; int fd, rc = 0; int isdir = 0; - - /* Initialize IOCTL striping pattern structure */ - lum.lmm_magic = LOV_USER_MAGIC; - lum.lmm_pattern = stripe_pattern; - lum.lmm_stripe_size = stripe_size; - lum.lmm_stripe_count = stripe_count; - lum.lmm_stripe_offset = stripe_offset; + int page_size; fd = open(name, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644); if (errno == EISDIR) { @@ -87,6 +81,45 @@ int llapi_file_create(char *name, long stripe_size, int stripe_offset, return rc; } + /* 64 KB is the largest common page size I'm aware of (on ia64), but + * check the local page size just in case. */ + page_size = 65536; + if (getpagesize() > page_size) { + page_size = getpagesize(); + fprintf(stderr, "WARNING: your page size (%d) is larger than " + "expected.\n", page_size); + } + if ((stripe_size < 0 || stripe_size % 65536) && + !(isdir && stripe_size == -1)) { + rc = -EINVAL; + err_msg("error: stripe_size must be an even " + "multiple of %d bytes.\n", page_size); + goto out; + } + if (stripe_offset < -1 || stripe_offset > 65534) { + errno = rc = -EINVAL; + err_msg("error: bad stripe offset %d\n", stripe_offset); + goto out; + } + if (stripe_count < -1 || stripe_count > 65534) { + errno = rc = -EINVAL; + err_msg("error: bad stripe count %d\n", stripe_count); + goto out; + } + if (stripe_count > 0 && (__u64)stripe_size * stripe_count > ~0UL) { + errno = rc = -EINVAL; + err_msg("error: stripe_size %ld * stripe_count %d " + "exceeds %lu bytes.\n", ~0UL); + goto out; + } + + /* Initialize IOCTL striping pattern structure */ + lum.lmm_magic = LOV_USER_MAGIC; + lum.lmm_pattern = stripe_pattern; + lum.lmm_stripe_size = stripe_size; + lum.lmm_stripe_count = stripe_count; + lum.lmm_stripe_offset = stripe_offset; + /* setting stripe pattern 0 -1 0 to a dir means to delete it */ if (isdir) { if (stripe_size == 0 && stripe_count == 0 && @@ -94,8 +127,8 @@ int llapi_file_create(char *name, long stripe_size, int stripe_offset, lum.lmm_stripe_size = -1; } else { if (stripe_size == -1) { + errno = rc = -EPERM; err_msg("deleting file stripe info is not allowed\n"); - rc = -EPERM; goto out; } } @@ -276,12 +309,14 @@ void lov_dump_user_lmm_v1(struct lov_user_md_v1 *lum, char *dname, char *fname, /* if it's a directory */ if (*fname == '\0') { - if (header && (obdstripe == 1)) { - printf("default lmm_stripe_count: %u\n" - "default lmm_stripe_size: %u\n" - "default lmm_stripe_offset: %u\n", - lum->lmm_stripe_count, lum->lmm_stripe_size, - (int)lum->lmm_stripe_offset); + if (obdstripe == 1) { + printf("default stripe_count: %d stripe_size: %u " + "stripe_offset: %d\n", + lum->lmm_stripe_count == (__u16)-1 ? -1 : + lum->lmm_stripe_count, + lum->lmm_stripe_size, + lum->lmm_stripe_offset == (__u16)-1 ? -1 : + lum->lmm_stripe_offset); } return; }