* [PATCH v3 (Only) 1/3] btrfs-progs: map-logical: look at next leaf if slot > items
@ 2018-06-07 17:28 james harvey
2018-06-07 18:41 ` [PATCH v3 (Only) 2/3] btrfs-progs: map-logical: Use btrfs_next_extent_item() james harvey
0 siblings, 1 reply; 3+ messages in thread
From: james harvey @ 2018-06-07 17:28 UTC (permalink / raw)
To: Btrfs BTRFS
btrfs-map-logical -l 10955980800 -b 4096 <path>
No extent found at range [10955980800,10955984896)
But, this extent exists. btrfs-debug-tree shows:
item 202 key (10955976704 EXTENT_ITEM 4096) itemoff 8772 itemsize 37
refs 1 gen 62656 flags DATA
shared data backref parent 142655488 count 1
...
item 0 key (10955980800 EXTENT_ITEM 4096) itemoff 16246 itemsize 37
refs 1 gen 62656 flags DATA
shared data backref parent 128958464 count 1
The code searches for (logical, 0, 0), and looks forward then backward. It
needs to go to the next leaf when slot > number of items on this leaf.
Signed-off-by: James Harvey <jamespharvey20@gmail.com>
---
btrfs-map-logical.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index 7a8bcff9..8a4228a4 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -65,6 +65,14 @@ static int map_one_extent(struct btrfs_fs_info *fs_info,
BUG_ON(ret == 0);
ret = 0;
+ if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {
+ ret = btrfs_next_leaf(fs_info->extent_root, path);
+ if (ret > 0)
+ ret = -ENOENT;
+ if (ret)
+ goto out;
+ }
+
again:
btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
if ((search_foward && key.objectid < logical) ||
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 (Only) 2/3] btrfs-progs: map-logical: Use btrfs_next_extent_item()
2018-06-07 17:28 [PATCH v3 (Only) 1/3] btrfs-progs: map-logical: look at next leaf if slot > items james harvey
@ 2018-06-07 18:41 ` james harvey
2018-06-08 1:33 ` Su Yue
0 siblings, 1 reply; 3+ messages in thread
From: james harvey @ 2018-06-07 18:41 UTC (permalink / raw)
To: Su Yue; +Cc: Btrfs BTRFS
On Thu, Jun 7, 2018 at 4:50 AM, Su Yue <suy.fnst@cn.fujitsu.com> wrote:
> On 06/07/2018 03:20 PM, james harvey wrote:
>>
>> btrfs_next_extent_item() looks for BTRFS_EXTENT_ITEM_KEY and
>> BTRFS_METADATA_KEY,
>> which are the types we're looking for.
>>
>> Signed-off-by: James Harvey <jamespharvey20@gmail.com>
>
> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com>
btrfs_next_extent_item() looks for BTRFS_EXTENT_ITEM_KEY and BTRFS_METADATA_KEY,
which are the types we're looking for.
(Previous versions missed last 0 argument to btrfs_next_extent_item(). Sorry, I
realize I need to take more time before sending, being more careful on
everything.)
Signed-off-by: James Harvey <jamespharvey20@gmail.com>
---
btrfs-map-logical.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index 2451012b..8a41b037 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -83,7 +83,8 @@ again:
ret = btrfs_previous_extent_item(fs_info->extent_root,
path, 0);
else
- ret = btrfs_next_item(fs_info->extent_root, path);
+ ret = btrfs_next_extent_item(fs_info->extent_root,
+ path, 0);
if (ret)
goto out;
goto again;
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 (Only) 2/3] btrfs-progs: map-logical: Use btrfs_next_extent_item()
2018-06-07 18:41 ` [PATCH v3 (Only) 2/3] btrfs-progs: map-logical: Use btrfs_next_extent_item() james harvey
@ 2018-06-08 1:33 ` Su Yue
0 siblings, 0 replies; 3+ messages in thread
From: Su Yue @ 2018-06-08 1:33 UTC (permalink / raw)
To: james harvey; +Cc: Btrfs BTRFS
On 06/08/2018 02:41 AM, james harvey wrote:
> On Thu, Jun 7, 2018 at 4:50 AM, Su Yue <suy.fnst@cn.fujitsu.com> wrote:
>> On 06/07/2018 03:20 PM, james harvey wrote:
>>>
>>> btrfs_next_extent_item() looks for BTRFS_EXTENT_ITEM_KEY and
>>> BTRFS_METADATA_KEY,
>>> which are the types we're looking for.
>>>
>>> Signed-off-by: James Harvey <jamespharvey20@gmail.com>
>>
>> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com>
>
> btrfs_next_extent_item() looks for BTRFS_EXTENT_ITEM_KEY and BTRFS_METADATA_KEY,
> which are the types we're looking for.
>
> (Previous versions missed last 0 argument to btrfs_next_extent_item(). Sorry, I
> realize I need to take more time before sending, being more careful on
> everything.)
>
So do I.
If you want to write something which is unreleated to
changes in a patch. Just put them and changelog belows "---" under
SOB line.
It would be easier for maintainers to apply patches.
And, I noticed patches sent by you are separated in ML. It's OK.
Puting series into one thread is better for review. You can
use tools like 'git-send-email' to send patches.
The last nag: a coverletter is nice with patches.
Link of conversation:
https://www.spinics.net/lists/linux-btrfs/msg77791.html
> Signed-off-by: James Harvey <jamespharvey20@gmail.com>
> ---
> btrfs-map-logical.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
> index 2451012b..8a41b037 100644
> --- a/btrfs-map-logical.c
> +++ b/btrfs-map-logical.c
> @@ -83,7 +83,8 @@ again:
> ret = btrfs_previous_extent_item(fs_info->extent_root,
> path, 0);
> else
> - ret = btrfs_next_item(fs_info->extent_root, path);
> + ret = btrfs_next_extent_item(fs_info->extent_root,
> + path, 0);
After a careful look, if btrfs_next/previous_extent_item is used here.
It's no need to check
====
if ((search_foward && key.objectid < logical) ||
(!search_foward && key.objectid > logical) ||
(key.type != BTRFS_EXTENT_ITEM_KEY &&
key.type != BTRFS_METADATA_ITEM_KEY)) {
===
Pass @logical as the last parameters of
btrfs_next/previous_extent_item() is simple enough.
Thanks,
Su
> if (ret)
> goto out;
> goto again;
> --
> 2.17.0
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-08 1:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 17:28 [PATCH v3 (Only) 1/3] btrfs-progs: map-logical: look at next leaf if slot > items james harvey
2018-06-07 18:41 ` [PATCH v3 (Only) 2/3] btrfs-progs: map-logical: Use btrfs_next_extent_item() james harvey
2018-06-08 1:33 ` Su Yue
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.