Whamcloud - gitweb
LU-2883 hsm: Mark file DIRTY as soon as pages are written
authorAurelien Degremont <aurelien.degremont@cea.fr>
Wed, 27 Feb 2013 13:57:34 +0000 (14:57 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 15 Mar 2013 20:44:37 +0000 (16:44 -0400)
Since the dirty flag has to be packed in close, it should be set when
pages are written and not when building BRWs like SOM which relies on
MDS_DONE_WRITING.

Signed-off-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Change-Id: I9cf0a71cf3228a7aadb8205cff2735a7abff5ef0
Reviewed-on: http://review.whamcloud.com/5543
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
lustre/llite/llite_close.c
lustre/llite/vvp_io.c
lustre/tests/sanity-hsm.sh

index 6c897dc..26a2c8c 100644 (file)
@@ -53,7 +53,6 @@ void vvp_write_pending(struct ccc_object *club, struct ccc_page *page)
        ENTRY;
        spin_lock(&lli->lli_lock);
        lli->lli_flags |= LLIF_SOM_DIRTY;
-       lli->lli_flags |= LLIF_DATA_MODIFIED;
        if (page != NULL && cfs_list_empty(&page->cpg_pending_linkage))
                cfs_list_add(&page->cpg_pending_linkage,
                             &club->cob_pending_list);
index 9020d77..db53842 100644 (file)
@@ -1010,6 +1010,7 @@ static int vvp_io_commit_write(const struct lu_env *env,
         struct cl_page    *pg     = slice->cpl_page;
         struct inode      *inode  = ccc_object_inode(obj);
         struct ll_sb_info *sbi    = ll_i2sbi(inode);
+       struct ll_inode_info *lli = ll_i2info(inode);
         cfs_page_t        *vmpage = cp->cpg_page;
 
         int    result;
@@ -1090,6 +1091,20 @@ static int vvp_io_commit_write(const struct lu_env *env,
         }
         ll_stats_ops_tally(sbi, tallyop, 1);
 
+       /* Inode should be marked DIRTY even if no new page was marked DIRTY
+        * because page could have been not flushed between 2 modifications.
+        * It is important the file is marked DIRTY as soon as the I/O is done
+        * Indeed, when cache is flushed, file could be already closed and it
+        * is too late to warn the MDT.
+        * It is acceptable that file is marked DIRTY even if I/O is dropped
+        * for some reasons before being flushed to OST.
+        */
+       if (result == 0) {
+               spin_lock(&lli->lli_lock);
+               lli->lli_flags |= LLIF_DATA_MODIFIED;
+               spin_unlock(&lli->lli_lock);
+       }
+
         size = cl_offset(obj, pg->cp_index) + to;
 
        ll_inode_size_lock(inode);
index a03a327..a0914b8 100644 (file)
@@ -146,7 +146,7 @@ test_3() {
        $LFS hsm_set --exists $TESTFILE.append ||
                error "user could not change hsm flags"
        dd if=/etc/passwd of=$TESTFILE.append bs=1 count=3 \
-          conv=notrunc,fdatasync oflag=append status=noxfer ||
+          conv=notrunc oflag=append status=noxfer ||
                error "could not append to test file"
        $LFS hsm_state $TESTFILE.append | grep -q " (0x00000003)" ||
                error "wrong hsm state: !0x3"
@@ -156,7 +156,7 @@ test_3() {
        $LFS hsm_set --exists $TESTFILE.modify ||
                error "user could not change hsm flags"
        dd if=/dev/zero of=$TESTFILE.modify bs=1 count=3 \
-          conv=notrunc,fdatasync status=noxfer ||
+          conv=notrunc status=noxfer ||
                error "could not modify test file"
        $LFS hsm_state $TESTFILE.modify | grep -q " (0x00000003)" ||
                error "wrong hsm state: !0x3"