Whamcloud - gitweb
LU-2789 lod: sidestep setstripe vs rename race
authorJohn L. Hammond <john.hammond@intel.com>
Tue, 9 Apr 2013 17:02:52 +0000 (12:02 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 11 Apr 2013 15:30:20 +0000 (11:30 -0400)
In mdd_declare_link() and mdd_declare_rename() pass the actual
attributes to be set down to mdo_declare_attr_set().  In
lod_declare_attr_set() and lod_attr_set() only handle striping if
setting UID or GID.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I511e35833042f6004fa6befd382831b7f33bef5a
Reviewed-on: http://review.whamcloud.com/5802
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_object.c
lustre/mdd/mdd_dir.c

index a5c22cd..8fa06a6 100644 (file)
@@ -291,6 +291,16 @@ static int lod_declare_attr_set(const struct lu_env *env,
        if (rc)
                RETURN(rc);
 
+       /* osp_declare_attr_set() ignores all attributes other than
+        * UID, GID, and size, and osp_attr_set() ignores all but UID
+        * and GID.  Declaration of size attr setting happens through
+        * lod_declare_init_size(), and not through this function.
+        * Therefore we need not load striping unless ownership is
+        * changing.  This should save memory and (we hope) speed up
+        * rename(). */
+       if (!(attr->la_valid & (LA_UID | LA_GID)))
+               RETURN(rc);
+
        /*
         * load striping information, notice we don't do this when object
         * is being initialized as we don't need this information till
@@ -334,6 +344,9 @@ static int lod_attr_set(const struct lu_env *env,
        if (rc)
                RETURN(rc);
 
+       if (!(attr->la_valid & (LA_UID | LA_GID)))
+               RETURN(rc);
+
        /*
         * if object is striped, apply changes to all the stripes
         */
index c28c068..2a8fd65 100644 (file)
@@ -1193,6 +1193,7 @@ static int mdd_declare_link(const struct lu_env *env,
                             struct mdd_object *c,
                             const struct lu_name *name,
                            struct thandle *handle,
+                           struct lu_attr *la,
                            struct linkea_data *data)
 {
         int rc;
@@ -1205,11 +1206,13 @@ static int mdd_declare_link(const struct lu_env *env,
         if (rc)
                 return rc;
 
-        rc = mdo_declare_attr_set(env, p, NULL, handle);
-        if (rc)
-                return rc;
+       la->la_valid = LA_CTIME | LA_MTIME;
+       rc = mdo_declare_attr_set(env, p, la, handle);
+       if (rc != 0)
+               return rc;
 
-        rc = mdo_declare_attr_set(env, c, NULL, handle);
+       la->la_valid = LA_CTIME;
+       rc = mdo_declare_attr_set(env, c, la, handle);
         if (rc)
                 return rc;
 
@@ -1243,8 +1246,11 @@ static int mdd_link(const struct lu_env *env, struct md_object *tgt_obj,
 
        memset(ldata, 0, sizeof(*ldata));
 
+       LASSERT(ma->ma_attr.la_valid & LA_CTIME);
+       la->la_ctime = la->la_mtime = ma->ma_attr.la_ctime;
+
        rc = mdd_declare_link(env, mdd, mdd_tobj, mdd_sobj, lname, handle,
-                             ldata);
+                             la, ldata);
         if (rc)
                 GOTO(stop, rc);
 
@@ -1274,9 +1280,6 @@ static int mdd_link(const struct lu_env *env, struct md_object *tgt_obj,
                GOTO(out_unlock, rc);
        }
 
-        LASSERT(ma->ma_attr.la_valid & LA_CTIME);
-        la->la_ctime = la->la_mtime = ma->ma_attr.la_ctime;
-
         la->la_valid = LA_CTIME | LA_MTIME;
        rc = mdd_attr_check_set_internal(env, mdd_tobj, la, handle, 0);
         if (rc)
@@ -1412,7 +1415,8 @@ static int mdd_declare_unlink(const struct lu_env *env, struct mdd_device *mdd,
                if (rc)
                        return rc;
 
-               rc = mdo_declare_attr_set(env, c, NULL, handle);
+               la->la_valid = LA_CTIME;
+               rc = mdo_declare_attr_set(env, c, la, handle);
                if (rc)
                        return rc;
 
@@ -2390,6 +2394,9 @@ static int mdd_declare_rename(const struct lu_env *env,
        struct lu_attr    *la = &mdd_env_info(env)->mti_la_for_fix;
        int rc;
 
+       LASSERT(ma->ma_attr.la_valid & LA_CTIME);
+       la->la_ctime = la->la_mtime = ma->ma_attr.la_ctime;
+
         LASSERT(mdd_spobj);
         LASSERT(mdd_tpobj);
         LASSERT(mdd_sobj);
@@ -2426,13 +2433,16 @@ static int mdd_declare_rename(const struct lu_env *env,
 
         }
 
-        rc = mdo_declare_attr_set(env, mdd_spobj, NULL, handle);
-        if (rc)
-                return rc;
-
-       LASSERT(ma->ma_attr.la_valid & LA_CTIME);
-       la->la_ctime = la->la_mtime = ma->ma_attr.la_ctime;
        la->la_valid = LA_CTIME | LA_MTIME;
+       rc = mdo_declare_attr_set(env, mdd_spobj, la, handle);
+       if (rc != 0)
+               return rc;
+
+       rc = mdo_declare_attr_set(env, mdd_tpobj, la, handle);
+       if (rc != 0)
+               return rc;
+
+       la->la_valid = LA_CTIME;
        rc = mdo_declare_attr_set(env, mdd_sobj, la, handle);
        if (rc)
                return rc;
@@ -2441,10 +2451,6 @@ static int mdd_declare_rename(const struct lu_env *env,
        if (rc)
                return rc;
 
-        rc = mdo_declare_attr_set(env, mdd_tpobj, NULL, handle);
-        if (rc)
-                return rc;
-
         /* new name */
         rc = mdo_declare_index_insert(env, mdd_tpobj, mdo2fid(mdd_sobj),
                         tname->ln_name, handle);
@@ -2477,7 +2483,8 @@ static int mdd_declare_rename(const struct lu_env *env,
                                 return rc;
                 }
 
-                rc = mdo_declare_attr_set(env, mdd_tobj, NULL, handle);
+               la->la_valid = LA_CTIME;
+               rc = mdo_declare_attr_set(env, mdd_tobj, la, handle);
                 if (rc)
                         return rc;