From 295968fa7257978bba7aa4fedb28cd3563d4a5e0 Mon Sep 17 00:00:00 2001 From: Aurelien Degremont Date: Wed, 12 Jun 2013 12:22:03 +0200 Subject: [PATCH 1/1] LU-3677 mdt: Set HSM dirty open-for-write file when evicted. 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 Change-Id: I20e18103fe085672f499c956e831564e45bd5200 Reviewed-on: http://review.whamcloud.com/7195 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_idl.h | 2 +- lustre/mdt/mdt_handler.c | 43 ++++++++++++++++++++++++++++++++++++++ lustre/mdt/mdt_open.c | 18 ++-------------- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 59e72f4..3ee0c7e 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -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, diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 9ec0404..4ceb146 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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; diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 6bc4f59..a967c44 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -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; -- 1.8.3.1