From patchwork Tue Nov 24 21:07:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Haxby X-Patchwork-Id: 7693091 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 727119F4F5 for ; Tue, 24 Nov 2015 21:07:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A76CB207EB for ; Tue, 24 Nov 2015 21:07:31 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65CBD207E5 for ; Tue, 24 Nov 2015 21:07:29 +0000 (UTC) Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tAOL7Fel004415 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 24 Nov 2015 21:07:15 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id tAOL7EMr005664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 24 Nov 2015 21:07:14 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1a1Kny-0002vm-2V; Tue, 24 Nov 2015 13:07:14 -0800 Received: from userv0021.oracle.com ([156.151.31.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1a1Kns-0002vG-KT for ocfs2-devel@oss.oracle.com; Tue, 24 Nov 2015 13:07:08 -0800 Received: from sheep.uk.oracle.com (dhcp-ukc1-twvpn-2-vpnpool-10-175-209-52.vpn.oracle.com [10.175.209.52]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id tAOL76g0030456 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Tue, 24 Nov 2015 21:07:08 GMT Received: from sheep.uk.oracle.com (localhost.localdomain [127.0.0.1]) by sheep.uk.oracle.com (8.15.2/8.15.2) with ESMTP id tAOL76LR006158; Tue, 24 Nov 2015 21:07:06 GMT Received: (from jch@localhost) by sheep.uk.oracle.com (8.15.2/8.15.2/Submit) id tAOL75UY006157; Tue, 24 Nov 2015 21:07:05 GMT X-Authentication-Warning: sheep.uk.oracle.com: jch set sender to john.haxby@oracle.com using -f From: John Haxby To: Mark Fasheh , Joel Becker , ocfs2-devel@oss.oracle.com Date: Tue, 24 Nov 2015 21:07:01 +0000 Message-Id: <1448399221-6109-2-git-send-email-john.haxby@oracle.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1448399221-6109-1-git-send-email-john.haxby@oracle.com> References: <1448399221-6109-1-git-send-email-john.haxby@oracle.com> Subject: [Ocfs2-devel] [PATCH 1/1] ocfs2: return non-zero st_blocks for inline data X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some versions of tar assume that files with st_blocks == 0 do not contain any data and will skip reading them entirely. See also commit 9206c561554c ("ext4: return non-zero st_blocks for inline data"). Signed-off-by: John Haxby Reviewed-by: Junxiao Bi Reviewed-by: Mark Fasheh --- fs/ocfs2/file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 0e5b451..d631279 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -1302,6 +1302,14 @@ int ocfs2_getattr(struct vfsmount *mnt, } generic_fillattr(inode, stat); + /* + * If there is inline data in the inode, the inode will normally not + * have data blocks allocated (it may have an external xattr block). + * Report at least one sector for such files, so tools like tar, rsync, + * others don't incorrectly think the file is completely sparse. + */ + if (unlikely(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)) + stat->blocks += (stat->size + 511)>>9; /* We set the blksize from the cluster size for performance */ stat->blksize = osb->s_clustersize;