From 93829a847a3c18b1132845bf114acf31f20a6360 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Sun, 29 Sep 2013 08:58:44 +0200 Subject: [PATCH] LU-3864 mdt: return st_blocks=1 for released files 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 Change-Id: I85df56a60bf3585b42999fc1b80d1f075435dbc3 Reviewed-on: http://review.whamcloud.com/7776 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Aurelien Degremont Reviewed-by: Jinshan Xiong --- lustre/mdt/mdt_handler.c | 8 +++++++- lustre/tests/sanity-hsm.sh | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 3ac51d7..dc960e5 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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; } diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index 5209cab..64ae27f 100644 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -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 -- 1.8.3.1