From: John L. Hammond Date: Thu, 13 Sep 2018 17:52:45 +0000 (-0500) Subject: LU-11369 hsm: allow non-owner writers to set HSM state dirty X-Git-Tag: 2.12.0-RC1~180 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=a9e48fa940c45e51fd792c5d9fc4c647f64ed94e LU-11369 hsm: allow non-owner writers to set HSM state dirty In mdt_add_dirty_flag(), bump up the capability so that mdt_hsm_attr_set() will succeed even if the writer (or truncater) is not the owner of the file. Signed-off-by: John L. Hammond Change-Id: Ibd7e9e039c3a984642b4a01c63cd11d2029e93f1 Reviewed-on: https://review.whamcloud.com/33158 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-by: Quentin Bouget Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index e76c5c3..a520d0a 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -638,6 +638,8 @@ out_unlock: int mdt_add_dirty_flag(struct mdt_thread_info *info, struct mdt_object *mo, struct md_attr *ma) { + struct lu_ucred *uc = mdt_ucred(info); + cfs_cap_t cap_saved; int rc; ENTRY; @@ -655,7 +657,12 @@ int mdt_add_dirty_flag(struct mdt_thread_info *info, struct mdt_object *mo, && !(ma->ma_hsm.mh_flags & (HS_DIRTY|HS_RELEASED))) { ma->ma_hsm.mh_flags |= HS_DIRTY; + /* Bump cap so that closes from non-owner writers can + * set the HSM state to dirty. */ + cap_saved = uc->uc_cap; + uc->uc_cap |= MD_CAP_TO_MASK(CFS_CAP_FOWNER); rc = mdt_hsm_attr_set(info, mo, &ma->ma_hsm); + uc->uc_cap = cap_saved; if (rc) CERROR("file attribute change error for "DFID": %d\n", PFID(mdt_object_fid(mo)), rc); diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index 7816583..904f2df 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -2238,6 +2238,30 @@ test_24f() { } run_test 24f "root can archive, release, and restore tar files" +test_24g() { + local file=$DIR/$tdir/$tfile + local fid + + echo "RUNAS = '$RUNAS'" + + copytool setup + + mkdir -p $DIR/$tdir + chmod ugo+rwx $DIR/$tdir + + echo "Please listen carefully as our options have changed." | tee $file + fid=$(path2fid $file) + chmod ugo+rw $file + + $LFS hsm_archive $file + wait_request_state $fid ARCHIVE SUCCEED + check_hsm_flags $file 0x00000009 # exists archived + + echo "To be electrocuted by your telephone, press #." | $RUNAS tee $file + check_hsm_flags $file 0x0000000b # exists dirty archived +} +run_test 24g "write by non-owner still sets dirty" # LU-11369 + test_25a() { # test needs a running copytool copytool setup