All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fill_holes: Fix slot number passed to hole_mergeable() call.
@ 2014-07-01  6:34 Chandan Rajendra
  2014-07-02  5:30 ` Wang Shilong
  0 siblings, 1 reply; 2+ messages in thread
From: Chandan Rajendra @ 2014-07-01  6:34 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Chandan Rajendra, aneesh.kumar

For a non-existent key, btrfs_search_slot() sets path->slots[0] to the slot
where the key could have been present, which in this case would be the slot
containing the extent item which would be the next neighbor of the file range
being punched. The current code passes an incremented path->slots[0] and we
skip to the wrong file extent item. This would mean that we would fail to
merge the "yet to be created" hole with the next neighboring hole (if one
exists). Fix this.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
 fs/btrfs/file.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index ad7c059..3cd7997 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2126,10 +2126,9 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
 		goto out;
 	}
 
-	if (hole_mergeable(inode, leaf, path->slots[0]+1, offset, end)) {
+	if (hole_mergeable(inode, leaf, path->slots[0], offset, end)) {
 		u64 num_bytes;
 
-		path->slots[0]++;
 		key.offset = offset;
 		btrfs_set_item_key_safe(root, path, &key);
 		fi = btrfs_item_ptr(leaf, path->slots[0],
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Btrfs: fill_holes: Fix slot number passed to hole_mergeable() call.
  2014-07-01  6:34 [PATCH] Btrfs: fill_holes: Fix slot number passed to hole_mergeable() call Chandan Rajendra
@ 2014-07-02  5:30 ` Wang Shilong
  0 siblings, 0 replies; 2+ messages in thread
From: Wang Shilong @ 2014-07-02  5:30 UTC (permalink / raw)
  To: Chandan Rajendra, linux-btrfs; +Cc: aneesh.kumar

On 07/01/2014 02:34 PM, Chandan Rajendra wrote:
> For a non-existent key, btrfs_search_slot() sets path->slots[0] to the slot
> where the key could have been present, which in this case would be the slot
> containing the extent item which would be the next neighbor of the file range
> being punched. The current code passes an incremented path->slots[0] and we
> skip to the wrong file extent item. This would mean that we would fail to
> merge the "yet to be created" hole with the next neighboring hole (if one
> exists). Fix this.
>
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> ---
Nice catch, this looks good to me.

Reviewed-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>

>   fs/btrfs/file.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index ad7c059..3cd7997 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -2126,10 +2126,9 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
>   		goto out;
>   	}
>   
> -	if (hole_mergeable(inode, leaf, path->slots[0]+1, offset, end)) {
> +	if (hole_mergeable(inode, leaf, path->slots[0], offset, end)) {
>   		u64 num_bytes;
>   
> -		path->slots[0]++;
>   		key.offset = offset;
>   		btrfs_set_item_key_safe(root, path, &key);
>   		fi = btrfs_item_ptr(leaf, path->slots[0],


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-02  5:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-01  6:34 [PATCH] Btrfs: fill_holes: Fix slot number passed to hole_mergeable() call Chandan Rajendra
2014-07-02  5:30 ` Wang Shilong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.