From patchwork Thu Apr 22 05:36:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ma X-Patchwork-Id: 94004 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3M5cKfa030914 for ; Thu, 22 Apr 2010 05:38:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752663Ab0DVFgx (ORCPT ); Thu, 22 Apr 2010 01:36:53 -0400 Received: from rcsinet10.oracle.com ([148.87.113.121]:62957 "EHLO rcsinet10.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752599Ab0DVFgx (ORCPT ); Thu, 22 Apr 2010 01:36:53 -0400 Received: from rcsinet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o3M5an5I019104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 22 Apr 2010 05:36:51 GMT Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by rcsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o3LLlhqs016700 for ; Thu, 22 Apr 2010 05:36:49 GMT Received: from abhmt006.oracle.com by acsmt355.oracle.com with ESMTP id 180034431271914597; Wed, 21 Apr 2010 22:36:37 -0700 Received: from localhost.localdomain (/10.182.120.240) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Apr 2010 22:36:36 -0700 From: Tao Ma To: linux-btrfs@vger.kernel.org Cc: sunil.mushran@oracle.com, Tao Ma , Jeff Liu , Chris Mason Subject: [RFC] btrfs: Don't return extent in fiemap if we meet with a hole. Date: Thu, 22 Apr 2010 13:36:30 +0800 Message-Id: <1271914590-7743-1-git-send-email-tao.ma@oracle.com> X-Mailer: git-send-email 1.6.3.3 X-Auth-Type: Internal IP X-Source-IP: rcsinet15.oracle.com [148.87.113.117] X-CT-RefId: str=0001.0A090207.4BCFE073.00EF:SCFMA4539811,ss=1,fgs=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 22 Apr 2010 05:38:21 +0000 (UTC) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index b177ed3..7eb4d77 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2951,7 +2951,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u32 flags = 0; u64 disko = 0; struct extent_map *em = NULL; - int end = 0; + int end = 0, hole = 0; u64 em_start = 0, em_len = 0; unsigned long emflags; ret = 0; @@ -2978,12 +2978,13 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, disko = 0; flags = 0; + hole = 0; if (em->block_start == EXTENT_MAP_LAST_BYTE) { end = 1; flags |= FIEMAP_EXTENT_LAST; } else if (em->block_start == EXTENT_MAP_HOLE) { - flags |= FIEMAP_EXTENT_UNWRITTEN; + hole = 1; } else if (em->block_start == EXTENT_MAP_INLINE) { flags |= (FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_NOT_ALIGNED); @@ -3015,10 +3016,12 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, end = 1; } - ret = fiemap_fill_next_extent(fieinfo, em_start, disko, - em_len, flags); - if (ret) - goto out_free; + if (!hole) { + ret = fiemap_fill_next_extent(fieinfo, em_start, disko, + em_len, flags); + if (ret) + goto out_free; + } } out_free: free_extent_map(em);