Whamcloud - gitweb
LU-5006 mdd: don't call attr_set on object create 43/12243/4
authorNiu Yawei <yawei.niu@intel.com>
Thu, 9 Oct 2014 08:11:31 +0000 (04:11 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 11 Nov 2014 12:09:36 +0000 (12:09 +0000)
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 <yawei.niu@intel.com>
Change-Id: I6f4094d4384b2c153d4dad2666d64281c0450059
Reviewed-on: http://review.whamcloud.com/12243
Tested-by: Jenkins
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdd/mdd_dir.c
lustre/osp/osp_internal.h
lustre/osp/osp_object.c
lustre/tests/sanity-quota.sh

index d6bb84b..5ab5e61 100644 (file)
@@ -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);
index 16bca57..4ce2eec 100644 (file)
@@ -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 */
index 07aeeec..198b8d9 100644 (file)
@@ -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,
index 8f4c82a..4fa7185 100644 (file)
@@ -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"