From: Aurelien Degremont Date: Wed, 27 Feb 2013 13:57:34 +0000 (+0100) Subject: LU-2883 hsm: Mark file DIRTY as soon as pages are written X-Git-Tag: 2.3.63~53 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3a0bb68dca5f7f28e650cf521d703b2714087830 LU-2883 hsm: Mark file DIRTY as soon as pages are written 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 Change-Id: I9cf0a71cf3228a7aadb8205cff2735a7abff5ef0 Reviewed-on: http://review.whamcloud.com/5543 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Johann Lombardi --- diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index 6c897dc..26a2c8c 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -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); diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 9020d77..db53842 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -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); diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index a03a327..a0914b8 100644 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -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"