Whamcloud - gitweb
LU-3864 mdt: return st_blocks=1 for released files 76/7776/3
authorBruno Faccini <bruno.faccini@intel.com>
Sun, 29 Sep 2013 06:58:44 +0000 (08:58 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 1 Oct 2013 04:22:16 +0000 (04:22 +0000)
Before this patch it has been decided to return st_blocks=0 for
released files. Unfortunatelly this caused tools like tar then
to consider the file as fully sparse and to archive it as is
without attempting to access/restore its content.
As this leads to potential corruption, it has been decided that
the less ugly and intrusive way to bypass this was to return 1
block considering this is consumed by file's metadatas.

Signed-off-by: Bruno Faccini <bruno.faccini@intel.com>
Change-Id: I85df56a60bf3585b42999fc1b80d1f075435dbc3
Reviewed-on: http://review.whamcloud.com/7776
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Reviewed-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
lustre/mdt/mdt_handler.c
lustre/tests/sanity-hsm.sh

index 3ac51d7..dc960e5 100644 (file)
@@ -414,7 +414,13 @@ void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b,
        } else if ((ma->ma_valid & MA_LOV) && ma->ma_lmm != NULL &&
                   ma->ma_lmm->lmm_pattern & LOV_PATTERN_F_RELEASED) {
                /* A released file stores its size on MDS. */
-               b->blocks = 0;
+               /* But return 1 block for released file, unless tools like tar
+                * will consider it fully sparse. (LU-3864)
+                */
+               if (unlikely(b->size == 0))
+                       b->blocks = 0;
+               else
+                       b->blocks = 1;
                b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
        }
 
index 5209cab..64ae27f 100644 (file)
@@ -1256,7 +1256,7 @@ test_21() {
        $LFS hsm_archive $f || error "could not archive file"
        wait_request_state $fid ARCHIVE SUCCEED
 
-       [ $(stat -c "%b" $f) -ne "0" ] || error "wrong block number"
+       [ $(stat -c "%b" $f) -ne "1" ] || error "wrong block number"
        local sz=$(stat -c "%s" $f)
        [ $sz -ne "0" ] || error "file size should not be zero"
 
@@ -1264,7 +1264,7 @@ test_21() {
        $LFS hsm_release $f || error "could not release file"
        check_hsm_flags $f "0x0000000d"
 
-       [ $(stat -c "%b" $f) -eq "0" ] || error "wrong block number"
+       [ $(stat -c "%b" $f) -eq "1" ] || error "wrong block number"
        [ $(stat -c "%s" $f) -eq $sz ] || error "wrong file size"
 
        # Check we can release an file without stripe info