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,
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;
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;
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;