Whamcloud - gitweb
LU-13151 mdt: add parent FID to Changelog recordss
[fs/lustre-release.git] / lustre / mdd / mdd_object.c
index d30599a..6c6afbf 100644 (file)
@@ -72,6 +72,7 @@ static int mdd_changelog_data_store_by_fid(const struct lu_env *env,
                                           enum changelog_rec_type type,
                                           enum changelog_rec_flags clf_flags,
                                           const struct lu_fid *fid,
+                                          const struct lu_fid *pfid,
                                           const char *xattr_name,
                                           struct thandle *handle);
 
@@ -449,7 +450,7 @@ static int mdd_xattr_get(const struct lu_env *env,
 
                rc2 = mdd_changelog_data_store_by_fid(env, mdd, CL_GETXATTR, 0,
                                                      mdd_object_fid(mdd_obj),
-                                                     name, handle);
+                                                     NULL, name, handle);
 
 stop:
                rc2 = mdd_trans_stop(env, mdd, rc2, handle);
@@ -884,6 +885,7 @@ static int mdd_changelog_data_store_by_fid(const struct lu_env *env,
                                           enum changelog_rec_type type,
                                           enum changelog_rec_flags clf_flags,
                                           const struct lu_fid *fid,
+                                          const struct lu_fid *pfid,
                                           const char *xattr_name,
                                           struct thandle *handle)
 {
@@ -919,6 +921,8 @@ static int mdd_changelog_data_store_by_fid(const struct lu_env *env,
        rec->cr.cr_flags = clf_flags;
        rec->cr.cr_type = (__u32)type;
        rec->cr.cr_tfid = *fid;
+       if (pfid)
+               rec->cr.cr_pfid = *pfid;
        rec->cr.cr_namelen = 0;
 
        if (clf_flags & CLF_JOBID)
@@ -950,11 +954,13 @@ static int mdd_changelog_data_store_by_fid(const struct lu_env *env,
  * want the change to commit without the log entry.
  * \param mdd_obj - mdd_object of change
  * \param handle - transaction handle
+ * \param pfid - parent FID for CL_MTIME changelogs
  */
 int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd,
                             enum changelog_rec_type type,
                             enum changelog_rec_flags clf_flags,
-                            struct mdd_object *mdd_obj, struct thandle *handle)
+                            struct mdd_object *mdd_obj, struct thandle *handle,
+                            const struct lu_fid *pfid)
 {
        int                              rc;
 
@@ -976,7 +982,7 @@ int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd,
        }
 
        rc = mdd_changelog_data_store_by_fid(env, mdd, type, clf_flags,
-                                            mdd_object_fid(mdd_obj),
+                                            mdd_object_fid(mdd_obj), pfid,
                                             NULL, handle);
        if (rc == 0)
                mdd_obj->mod_cltime = ktime_get();
@@ -1013,7 +1019,7 @@ int mdd_changelog_data_store_xattr(const struct lu_env *env,
        }
 
        rc = mdd_changelog_data_store_by_fid(env, mdd, type, clf_flags,
-                                            mdd_object_fid(mdd_obj),
+                                            mdd_object_fid(mdd_obj), NULL,
                                             xattr_name, handle);
        if (rc == 0)
                mdd_obj->mod_cltime = ktime_get();
@@ -1052,7 +1058,7 @@ static int mdd_changelog(const struct lu_env *env, enum changelog_rec_type type,
                GOTO(stop, rc);
 
        rc = mdd_changelog_data_store_by_fid(env, mdd, type, clf_flags,
-                                            fid, NULL, handle);
+                                            fid, NULL, NULL, handle);
 
 stop:
        rc = mdd_trans_stop(env, mdd, rc, handle);
@@ -1073,7 +1079,7 @@ stop:
  * atime and ctime are independent.) */
 static int mdd_attr_set_changelog(const struct lu_env *env,
                                   struct md_object *obj, struct thandle *handle,
-                                  __u64 valid)
+                                 const struct lu_fid *pfid, __u64 valid)
 {
        struct mdd_device *mdd = mdo2mdd(obj);
        int bits, type = 0;
@@ -1093,8 +1099,8 @@ static int mdd_attr_set_changelog(const struct lu_env *env,
        type = __ffs(bits);
 
        /* XXX: we only store the low CLF_FLAGMASK bits of la_valid */
-       return mdd_changelog_data_store(env, mdd, type, valid,
-                                       md2mdd_obj(obj), handle);
+       return mdd_changelog_data_store(env, mdd, type, valid, md2mdd_obj(obj),
+                                       handle, pfid);
 }
 
 static int mdd_declare_attr_set(const struct lu_env *env,
@@ -1320,7 +1326,7 @@ int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
 
 out:
        if (rc == 0)
-               rc = mdd_attr_set_changelog(env, obj, handle,
+               rc = mdd_attr_set_changelog(env, obj, handle, &ma->ma_pfid,
                                            la_copy->la_valid);
 
        if (handle != NULL)
@@ -1601,8 +1607,10 @@ static int mdd_xattr_merge(const struct lu_env *env, struct md_object *md_obj,
        if (rc) /* wtf? */
                GOTO(out_restore, rc);
 
-       (void)mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, obj, handle);
-       (void)mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, vic, handle);
+       (void)mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, obj, handle,
+                                      NULL);
+       (void)mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, vic, handle,
+                                      NULL);
        EXIT;
 
 out_restore:
@@ -1834,11 +1842,13 @@ static int mdd_xattr_split(const struct lu_env *env, struct md_object *md_obj,
        if (rc)
                GOTO(out_restore, rc);
 
-       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, obj, handle);
+       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, obj, handle,
+                                     NULL);
        if (rc)
                GOTO(out, rc);
 
-       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, vic, handle);
+       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, vic, handle,
+                                     NULL);
        if (rc)
                GOTO(out, rc);
        EXIT;
@@ -2135,7 +2145,7 @@ static int mdd_xattr_hsm_replace(const struct lu_env *env,
        /* Add a changelog record for release. */
        hsm_set_cl_event(&clf_flags, HE_RELEASE);
        rc = mdd_changelog_data_store(env, mdo2mdd(&o->mod_obj), CL_HSM,
-                                     clf_flags, o, handle);
+                                     clf_flags, o, handle, NULL);
        RETURN(rc);
 }
 
@@ -2571,11 +2581,13 @@ static int mdd_swap_layouts(const struct lu_env *env, struct md_object *obj1,
                GOTO(out_restore, rc);
 
        /* Issue one changelog record per file */
-       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, fst_o, handle);
+       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, fst_o, handle,
+                                     NULL);
        if (rc)
                GOTO(stop, rc);
 
-       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, snd_o, handle);
+       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, snd_o, handle,
+                                     NULL);
        if (rc)
                GOTO(stop, rc);
        EXIT;
@@ -2691,7 +2703,8 @@ mdd_layout_instantiate_component(const struct lu_env *env,
        if (rc)
                RETURN(rc);
 
-       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, obj, handle);
+       rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, obj, handle,
+                                     NULL);
        RETURN(rc);
 }
 
@@ -2775,7 +2788,7 @@ mdd_layout_update_rdonly(const struct lu_env *env, struct mdd_object *obj,
        if (rc)
                GOTO(out, rc);
 
-       rc = mdd_changelog_data_store(env, mdd, CL_FLRW, 0, obj, handle);
+       rc = mdd_changelog_data_store(env, mdd, CL_FLRW, 0, obj, handle, NULL);
        if (rc)
                GOTO(out, rc);
 
@@ -2925,7 +2938,8 @@ mdd_object_update_sync_pending(const struct lu_env *env, struct mdd_object *obj,
                        GOTO(out, rc);
        }
 
-       rc = mdd_changelog_data_store(env, mdd, CL_RESYNC, 0, obj, handle);
+       rc = mdd_changelog_data_store(env, mdd, CL_RESYNC, 0, obj, handle,
+                                     NULL);
        if (rc)
                GOTO(out, rc);
        EXIT;
@@ -3407,7 +3421,7 @@ out:
 
                /* FYI, only the bottom 32 bits of open_flags are recorded */
                mdd_changelog_data_store(env, mdd, CL_CLOSE, open_flags,
-                                        mdd_obj, handle);
+                                        mdd_obj, handle, NULL);
        }
 
 stop: