Whamcloud - gitweb
LU-11369 hsm: allow non-owner writers to set HSM state dirty 58/33158/2
authorJohn L. Hammond <jhammond@whamcloud.com>
Thu, 13 Sep 2018 17:52:45 +0000 (12:52 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 12 Oct 2018 23:50:21 +0000 (23:50 +0000)
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 <jhammond@whamcloud.com>
Change-Id: Ibd7e9e039c3a984642b4a01c63cd11d2029e93f1
Reviewed-on: https://review.whamcloud.com/33158
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_reint.c
lustre/tests/sanity-hsm.sh

index e76c5c3..a520d0a 100644 (file)
@@ -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);
index 7816583..904f2df 100755 (executable)
@@ -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