From: Niu Yawei Date: Thu, 9 Oct 2014 08:11:31 +0000 (-0400) Subject: LU-5006 mdd: don't call attr_set on object create X-Git-Tag: 2.6.91~82 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=28c737d69e3a9cf5e7125ffd4d46621fc05b0056 LU-5006 mdd: don't call attr_set on object create The object attr has been initialzed in OSD layer when create object, it's not necessary to initialize it again in MDD layer. Signed-off-by: Niu Yawei Change-Id: I6f4094d4384b2c153d4dad2666d64281c0450059 Reviewed-on: http://review.whamcloud.com/12243 Tested-by: Jenkins Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index d6bb84b..5ab5e61 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -1842,19 +1842,9 @@ static int mdd_object_initialize(const struct lu_env *env, struct lu_attr *attr, struct thandle *handle, const struct md_op_spec *spec) { - int rc; - ENTRY; - - /* - * Update attributes for child. - * - * FIXME: - * (1) the valid bits should be converted between Lustre and Linux; - * (2) maybe, the child attributes should be set in OSD when creation. - */ + int rc = 0; + ENTRY; - rc = mdd_attr_set_internal(env, child, attr, handle, 0); - /* arguments are supposed to stay the same */ if (S_ISDIR(attr->la_mode)) { /* Add "." and ".." for newly created dir */ mdo_ref_add(env, child, handle); diff --git a/lustre/osp/osp_internal.h b/lustre/osp/osp_internal.h index 16bca57..4ce2eec 100644 --- a/lustre/osp/osp_internal.h +++ b/lustre/osp/osp_internal.h @@ -238,7 +238,6 @@ struct osp_object { struct lu_object_header opo_header; struct dt_object opo_obj; unsigned int opo_reserved:1, - opo_new:1, opo_non_exist:1; /* read/write lock for md osp object */ diff --git a/lustre/osp/osp_object.c b/lustre/osp/osp_object.c index 07aeeec..198b8d9 100644 --- a/lustre/osp/osp_object.c +++ b/lustre/osp/osp_object.c @@ -627,10 +627,6 @@ static int __osp_attr_set(const struct lu_env *env, struct dt_object *dt, RETURN(0); if (!is_only_remote_trans(th)) { - if (o->opo_new) - /* no need in logging for new objects being created */ - RETURN(0); - /* * track all UID/GID changes via llog */ @@ -745,9 +741,6 @@ static int osp_attr_set(const struct lu_env *env, struct dt_object *dt, if (is_only_remote_trans(th)) { rc = __osp_attr_set(env, dt, attr, th); - if (rc == 0 && o->opo_new) - o->opo_new = 0; - RETURN(rc); } @@ -755,15 +748,6 @@ static int osp_attr_set(const struct lu_env *env, struct dt_object *dt, if (!(attr->la_valid & (LA_UID | LA_GID))) RETURN(0); - /* new object, the very first ->attr_set() - * initializing attributes needs no logging - * all subsequent one are subject to the - * logging and synchronization with OST */ - if (o->opo_new) { - o->opo_new = 0; - RETURN(0); - } - rc = osp_sync_add(env, o, MDS_SETATTR64_REC, th, attr); /* XXX: send new uid/gid to OST ASAP? */ @@ -1569,10 +1553,6 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt, } } - /* new object, the very first ->attr_set() - * initializing attributes needs no logging */ - o->opo_new = 1; - /* Only need update last_used oid file, seq file will only be update * during seq rollover */ osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off, diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 8f4c82a..4fa7185 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -2349,6 +2349,36 @@ test_36() { } run_test 36 "Migrate old admin files into new global indexes" +# chown/chgrp to the file created with MDS_OPEN_DELAY_CREATE +# LU-5006 +test_37() { + setup_quota_test + trap cleanup_quota_test EXIT + + # make sure the system is clean + local USED=$(getquota -u $TSTID global curspace) + [ $USED -ne 0 ] && + error "Used space ($USED) for user $TSTID isn't 0." + + # create file with MDS_OPEN_DELAY_CREATE flag + $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile || + error "Create file failed" + # write to file + dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 conv=notrunc \ + oflag=sync || error "Write file failed" + # chown to the file + chown $TSTID $DIR/$tdir/$tfile || error "Chown to file failed" + + # wait for setattr on objects finished..." + wait_delete_completed + + USED=$(getquota -u $TSTID global curspace) + [ $USED -ne 0 ] || quota_error u $TSTUSR "Used space is 0" + + cleanup_quota_test +} +run_test 37 "Quota accounted properly for file created by 'lfs setstripe'" + quota_fini() { do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"