Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753753AbcDJNOZ (ORCPT ); Sun, 10 Apr 2016 09:14:25 -0400 Received: from smtp1.ccs.ornl.gov ([160.91.199.38]:42640 "EHLO smtp1.ccs.ornl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753582AbcDJNOR (ORCPT ); Sun, 10 Apr 2016 09:14:17 -0400 From: James Simmons To: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Oleg Drokin Cc: Linux Kernel Mailing List , Lustre Development List , Bruno Faccini , James Simmons Subject: [PATCH 14/17] staging: lustre: lov: return minimal FIEMAP for released files Date: Sun, 10 Apr 2016 09:13:37 -0400 Message-Id: <1460294020-2111-15-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1460294020-2111-1-git-send-email-jsimmons@infradead.org> References: <1460294020-2111-1-git-send-email-jsimmons@infradead.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2127 Lines: 59 From: Bruno Faccini Since st_blocks = NULL is returned for released files, FIEMAP should at least return a minimal mapping to make users aware that file contains data but it is not immediately available. This will make coreutils and tools such tar happy and have them presume file is sparse. Also, add a new test_228 in sanity-hsm to verify it works for "[cp,tar] --sparse" commands. Also fix a LBUG ("lov_fiemap()) ASSERTION( fm_local ) failed") likely to occur when no-object/ENOMEM conditions and also now when released. Signed-off-by: Bruno Faccini Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3864 Reviewed-on: http://review.whamcloud.com/7584 Reviewed-by: Andreas Dilger Reviewed-by: Aurelien Degremont Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lov/lov_obd.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 1a9e3e8..9b72671 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1733,6 +1733,27 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, unsigned int buffer_size = FIEMAP_BUFFER_SIZE; if (!lsm_has_objects(lsm)) { + if (lsm && lsm_is_released(lsm) && (fm_key->fiemap.fm_start < + fm_key->oa.o_size)) { + /* + * released file, return a minimal FIEMAP if + * request fits in file-size. + */ + fiemap->fm_mapped_extents = 1; + fiemap->fm_extents[0].fe_logical = + fm_key->fiemap.fm_start; + if (fm_key->fiemap.fm_start + fm_key->fiemap.fm_length < + fm_key->oa.o_size) { + fiemap->fm_extents[0].fe_length = + fm_key->fiemap.fm_length; + } else { + fiemap->fm_extents[0].fe_length = + fm_key->oa.o_size - fm_key->fiemap.fm_start; + fiemap->fm_extents[0].fe_flags |= + (FIEMAP_EXTENT_UNKNOWN | + FIEMAP_EXTENT_LAST); + } + } rc = 0; goto out; } -- 1.7.1