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>
} 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;
}
$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"
$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