Whamcloud - gitweb
LU-3677 mdt: Set HSM dirty open-for-write file when evicted. 95/7195/2
authorAurelien Degremont <aurelien.degremont@cea.fr>
Wed, 12 Jun 2013 10:22:03 +0000 (12:22 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 8 Aug 2013 19:08:03 +0000 (19:08 +0000)
Fix regression introduced by LU-1303 (5165cdd). Previously,
MDS_CLOSE_CLEANUP was used to detect file closing, due to eviction.
This flag is no more since 5165cdd.

It completely removed this symbol.

Signed-off-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Change-Id: I20e18103fe085672f499c956e831564e45bd5200
Reviewed-on: http://review.whamcloud.com/7195
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre/lustre_idl.h
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_open.c

index 59e72f4..3ee0c7e 100644 (file)
@@ -2398,7 +2398,7 @@ enum mds_op_bias {
        MDS_PERM_BYPASS         = 1 << 3,
        MDS_SOM                 = 1 << 4,
        MDS_QUOTA_IGNORE        = 1 << 5,
-       MDS_CLOSE_CLEANUP       = 1 << 6,
+       /* Was MDS_CLOSE_CLEANUP (1 << 6), No more used */
        MDS_KEEP_ORPHAN         = 1 << 7,
        MDS_RECOV_OPEN          = 1 << 8,
        MDS_DATA_MODIFIED       = 1 << 9,
index 9ec0404..4ceb146 100644 (file)
@@ -5568,6 +5568,31 @@ static int mdt_obd_reconnect(const struct lu_env *env,
         RETURN(rc);
 }
 
+static int mdt_ctxt_add_dirty_flag(struct lu_env *env,
+                                  struct mdt_thread_info *info,
+                                  struct mdt_file_data *mfd)
+{
+       struct lu_context ses;
+       int rc;
+       ENTRY;
+
+       rc = lu_context_init(&ses, LCT_SESSION);
+       if (rc)
+               RETURN(rc);
+
+       env->le_ses = &ses;
+       lu_context_enter(&ses);
+
+       mdt_ucred(info)->uc_valid = UCRED_OLD;
+       rc = mdt_add_dirty_flag(info, mfd->mfd_object, &info->mti_attr);
+
+       lu_context_exit(&ses);
+       lu_context_fini(&ses);
+       env->le_ses = NULL;
+
+       RETURN(rc);
+}
+
 static int mdt_export_cleanup(struct obd_export *exp)
 {
         struct mdt_export_data *med = &exp->exp_mdt_data;
@@ -5612,6 +5637,24 @@ static int mdt_export_cleanup(struct obd_export *exp)
                 cfs_list_for_each_entry_safe(mfd, n, &closing_list, mfd_list) {
                         cfs_list_del_init(&mfd->mfd_list);
                        ma->ma_need = ma->ma_valid = 0;
+
+                       /* This file is being closed due to an eviction, it
+                        * could have been modified and now dirty regarding to
+                        * HSM archive, check this!
+                        * The logic here is to mark a file dirty if there's a
+                        * chance it was dirtied before the client was evicted,
+                        * so that we don't have to wait for a release attempt
+                        * before finding out the file was actually dirty and
+                        * fail the release. Aggressively marking it dirty here
+                        * will cause the policy engine to attempt to
+                        * re-archive it; when rearchiving, we can compare the
+                        * current version to the HSM data_version and make the
+                        * archive request into a noop if it's not actually
+                        * dirty.
+                        */
+                       if (mfd->mfd_mode & (FMODE_WRITE|MDS_FMODE_TRUNC))
+                               rc = mdt_ctxt_add_dirty_flag(&env, info, mfd);
+
                        /* Don't unlink orphan on failover umount, LU-184 */
                        if (exp->exp_flags & OBD_OPT_FAILOVER) {
                                ma->ma_valid = MA_FLAGS;
index 6bc4f59..a967c44 100644 (file)
@@ -2160,22 +2160,8 @@ int mdt_mfd_close(struct mdt_thread_info *info, struct mdt_file_data *mfd)
                 rc = mo_attr_set(info->mti_env, next, ma);
         }
 
-       /* If file data is modified, add the dirty flag.
-        *
-        * If MDS_CLOSE_CLEANUP is set, this file is being closed due to an
-        * eviction, file could have been modified and now dirty
-        * regarding to HSM archive, check this!
-        * The logic here is to mark a file dirty if there's a chance it was
-        * dirtied before the client was evicted, so that we don't have to wait
-        * for a release attempt before finding out the file was actually dirty
-        * and fail the release. Aggressively marking it dirty here will cause
-        * the policy engine to attempt to re-archive it; when rearchiving, we
-        * can compare the current version to the LMA data_version and make the
-        * archive request into a noop if it's not actually dirty.
-        */
-       if ((ma->ma_attr_flags & MDS_DATA_MODIFIED) ||
-           ((ma->ma_attr_flags & MDS_CLOSE_CLEANUP) &&
-            (mode & (FMODE_WRITE|MDS_FMODE_TRUNC))))
+       /* If file data is modified, add the dirty flag. */
+       if (ma->ma_attr_flags & MDS_DATA_MODIFIED)
                rc = mdt_add_dirty_flag(info, o, ma);
 
         ma->ma_need |= MA_INODE;