From: jacob Date: Thu, 31 Mar 2005 21:21:39 +0000 (+0000) Subject: b=3048 X-Git-Tag: v1_8_0_110~486^7~76 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=55abf95630bfc7d5afb005d10e916d69efdfb654;p=fs%2Flustre-release.git b=3048 r=me, adilger when creating new directories, inherit parent's striping --- diff --git a/lustre/ChangeLog b/lustre/ChangeLog index f962e5e..d39c02c 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -13,6 +13,8 @@ - fix rename of one directory over another leaking an inode (5953) - avoid SetPageDirty on 2.6 (5981) - don't re-add just-being-destroyed locks to the waiting list (5653) + - when creating new directories, inherit the parent's custom + striping settings if present parent (3048) * miscellania - by default create 1 inode per 4kB space on MDS, per 16kB on OSTs - allow --write-conf on an MDS with different nettype than client (5619) @@ -21,9 +23,9 @@ - init scripts are now turned off by default; run chkconfig --on lustre and chkconfig --on lustrefs to use them - upcalls are no longer needed for clients to recover to failover - servers (3262) + servers (3262) - add --abort-recovery option to lconf to abort recovery on device - startup (6017) + startup (6017) 2005-03-22 Cluster File Systems, Inc. * version 1.4.1 diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 1f310b8..bba0365 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -435,22 +435,34 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset, if (rc == 0 && (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) && rec->ur_eadata != NULL) { struct lov_stripe_md *lsm = NULL; + struct lov_user_md *lum = NULL; rc = ll_permission(inode, MAY_WRITE, NULL); if (rc < 0) GOTO(cleanup, rc); - rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, - mds->mds_osc_exp, 0, &lsm, rec->ur_eadata); - if (rc) - GOTO(cleanup, rc); - - obd_free_memmd(mds->mds_osc_exp, &lsm); - - rc = fsfilt_set_md(obd, inode, handle, rec->ur_eadata, - rec->ur_eadatalen); - if (rc) - GOTO(cleanup, rc); + lum = rec->ur_eadata; + /* if lmm_stripe_size is -1, then delete the stripe + info from the dir */ + if (S_ISDIR(inode->i_mode) && + lum->lmm_stripe_size == (typeof(lum->lmm_stripe_size))(-1)){ + rc = fsfilt_set_md(obd, inode, handle, NULL, 0); + if (rc) + GOTO(cleanup, rc); + } else { + rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, + mds->mds_osc_exp, 0, + &lsm, rec->ur_eadata); + if (rc) + GOTO(cleanup, rc); + + obd_free_memmd(mds->mds_osc_exp, &lsm); + + rc = fsfilt_set_md(obd, inode, handle, rec->ur_eadata, + rec->ur_eadatalen); + if (rc) + GOTO(cleanup, rc); + } } body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); @@ -712,6 +724,21 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, if (rc) CERROR("error on parent setattr: rc = %d\n", rc); + if (S_ISDIR(inode->i_mode)) { + struct lov_mds_md lmm; + int lmm_size = sizeof(lmm); + rc = mds_get_md(obd, dir, &lmm, &lmm_size, 1); + if (rc > 0) { + down(&inode->i_sem); + rc = fsfilt_set_md(obd, inode, handle, + &lmm, lmm_size); + up(&inode->i_sem); + } + if (rc) + CERROR("error on copy stripe info: rc = %d\n", + rc); + } + body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*body)); mds_pack_inode2fid(&body->fid1, inode); mds_pack_inode2body(body, inode); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 0f67643..da9e1b7 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2215,10 +2215,11 @@ test_65e() { mkdir -p $DIR/d65 $LSTRIPE $DIR/d65 0 -1 0 || error "setstripe" + $LFS find -v $DIR/d65 | grep "$DIR/d65/ has no stripe info" || error "no stripe info failed" touch $DIR/d65/f6 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed" } -run_test 65e "directory setstripe 0 -1 0 (default) =============" +run_test 65e "directory setstripe 0 -1 0 =============" test_65f() { mkdir -p $DIR/d65f @@ -2226,6 +2227,23 @@ test_65f() { } run_test 65f "dir setstripe permission (should return error) ===" +test_65g() { + mkdir -p $DIR/d65 + $LSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe" + $LSTRIPE -d $DIR/d65 || error "setstripe" + $LFS find -v $DIR/d65 | grep "$DIR/d65/ has no stripe info" || error "no stripe info failed" +} +run_test 65g "directory setstripe -d ========" + +test_65h() { + mkdir -p $DIR/d65 + $LSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe" + mkdir -p $DIR/d65/dd1 + [ "`$LFS find -v $DIR/d65 | grep "^count"`" == \ + "`$LFS find -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed" +} +run_test 65h "directory stripe info inherit ======" + # bug 2543 - update blocks count on client test_66() { COUNT=${COUNT:-8} diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index fdce3d6..449f676 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -54,8 +54,11 @@ static int lfs_catinfo(int argc, char **argv); command_t cmdlist[] = { {"setstripe", lfs_setstripe, 0, "Create a new file with a specific striping pattern or\n" - "Set the default striping pattern on an existing directory\n" + "set the default striping pattern on an existing directory or\n" + "delete the default striping pattern from an existing directory\n" "usage: setstripe \n" + " or \n" + " setstripe -d \n" "\tstripe size: Number of bytes in each stripe (0 default)\n" "\tstripe start: OST index of first stripe (-1 default)\n" "\tstripe count: Number of OSTs to stripe over (0 default, -1 all)"}, @@ -85,52 +88,66 @@ command_t cmdlist[] = { /* functions */ static int lfs_setstripe(int argc, char **argv) { + char *fname; int result; long st_size; int st_offset, st_count; char *end; int page_size; - if (argc != 5) + if (argc != 5 && argc != 3) return CMD_HELP; - // get the stripe size - st_size = strtoul(argv[2], &end, 0); - if (*end != '\0') { - fprintf(stderr, "error: %s: bad stripe size '%s'\n", - 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); - if (*end != '\0') { - fprintf(stderr, "error: %s: bad stripe offset '%s'\n", + if (argc == 3) { + if (strcmp(argv[1], "-d") != 0) + return CMD_HELP; + + fname = argv[2]; + st_size = -1; + st_count = 0; + st_offset = 0; + } else { + fname = argv[1]; + + // get the stripe size + st_size = strtoul(argv[2], &end, 0); + if (*end != '\0') { + fprintf(stderr, "error: %s: bad stripe size '%s'\n", + 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); + if (*end != '\0') { + fprintf(stderr, "error: %s: bad stripe offset '%s'\n", argv[0], argv[3]); - return CMD_HELP; - } - // get the stripe count - st_count = strtoul(argv[4], &end, 0); - if (*end != '\0') { - fprintf(stderr, "error: %s: bad stripe count '%s'\n", + return CMD_HELP; + } + // get the stripe count + st_count = strtoul(argv[4], &end, 0); + if (*end != '\0') { + fprintf(stderr, "error: %s: bad stripe count '%s'\n", argv[0], argv[4]); - return CMD_HELP; + return CMD_HELP; + } } - result = llapi_file_create(argv[1], st_size, st_offset, st_count, 0); + result = llapi_file_create(fname, st_size, st_offset, st_count, 0); if (result) fprintf(stderr, "error: %s: create stripe file failed\n", argv[0]); diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index bb2e949..77a3959 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -66,6 +66,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; @@ -75,8 +76,10 @@ int llapi_file_create(char *name, long stripe_size, int stripe_offset, lum.lmm_stripe_offset = stripe_offset; fd = open(name, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644); - if (errno == EISDIR) + if (errno == EISDIR) { fd = open(name, O_DIRECTORY | O_RDONLY); + isdir++; + } if (fd < 0) { err_msg("unable to open '%s'",name); @@ -84,6 +87,19 @@ int llapi_file_create(char *name, long stripe_size, int stripe_offset, return rc; } + /* setting stripe pattern 0 -1 0 to a dir means to delete it */ + if (isdir) { + if (stripe_size == 0 && stripe_count == 0 && + stripe_offset == -1) + lum.lmm_stripe_size = -1; + } else { + if (stripe_size == -1) { + err_msg("deleting file stripe info is not allowed\n"); + rc = -EPERM; + goto out; + } + } + if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, &lum)) { char *errmsg = "stripe already set"; if (errno != EEXIST && errno != EALREADY) @@ -93,6 +109,7 @@ int llapi_file_create(char *name, long stripe_size, int stripe_offset, (__u64)LL_IOC_LOV_SETSTRIPE, name, fd, errmsg); rc = -errno; } +out: if (close(fd) < 0) { err_msg("error on close for '%s' (%d)", name, fd); if (rc == 0)