* [PATCH btrfs-progs] btrfs-progs: do not fail when offset of a ROOT_ITEM is not -1
@ 2021-02-09 17:34 ` Marek Behún
0 siblings, 0 replies; 4+ messages in thread
From: Marek Behún @ 2021-02-09 17:34 UTC (permalink / raw)
To: linux-btrfs; +Cc: u-boot, Marek Behún, David Sterba, Qu Wenruo, Tom Rini
When the btrfs_read_fs_root() function is searching a ROOT_ITEM with
location key offset other than -1, it currently fails via BUG_ON.
The offset can have other value than -1, though. This can happen for
example if a subvolume is renamed:
$ btrfs subvolume create X && sync
Create subvolume './X'
$ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: X$
location key (270 ROOT_ITEM 18446744073709551615) type DIR
transid 283 data_len 0 name_len 1
name: X
$ mv X Y && sync
$ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: Y$
location key (270 ROOT_ITEM 0) type DIR
transid 285 data_len 0 name_len 1
name: Y
As can be seen the offset changed from -1ULL to 0.
Do not fail in this case.
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: David Sterba <dsterba@suse.com>
Cc: Qu Wenruo <wqu@suse.com>
Cc: Tom Rini <trini@konsulko.com>
---
kernel-shared/disk-io.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 6f584986..ba8ffd8b 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -752,8 +752,7 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
return fs_info->free_space_root ? fs_info->free_space_root :
ERR_PTR(-ENOENT);
- BUG_ON(location->objectid == BTRFS_TREE_RELOC_OBJECTID ||
- location->offset != (u64)-1);
+ BUG_ON(location->objectid == BTRFS_TREE_RELOC_OBJECTID);
node = rb_search(&fs_info->fs_root_tree, (void *)&objectid,
btrfs_fs_roots_compare_objectids, NULL);
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH btrfs-progs] btrfs-progs: do not fail when offset of a ROOT_ITEM is not -1
@ 2021-02-09 17:34 ` Marek Behún
0 siblings, 0 replies; 4+ messages in thread
From: Marek Behún @ 2021-02-09 17:34 UTC (permalink / raw)
To: u-boot
When the btrfs_read_fs_root() function is searching a ROOT_ITEM with
location key offset other than -1, it currently fails via BUG_ON.
The offset can have other value than -1, though. This can happen for
example if a subvolume is renamed:
$ btrfs subvolume create X && sync
Create subvolume './X'
$ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: X$
location key (270 ROOT_ITEM 18446744073709551615) type DIR
transid 283 data_len 0 name_len 1
name: X
$ mv X Y && sync
$ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: Y$
location key (270 ROOT_ITEM 0) type DIR
transid 285 data_len 0 name_len 1
name: Y
As can be seen the offset changed from -1ULL to 0.
Do not fail in this case.
Signed-off-by: Marek Beh?n <marek.behun@nic.cz>
Cc: David Sterba <dsterba@suse.com>
Cc: Qu Wenruo <wqu@suse.com>
Cc: Tom Rini <trini@konsulko.com>
---
kernel-shared/disk-io.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 6f584986..ba8ffd8b 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -752,8 +752,7 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
return fs_info->free_space_root ? fs_info->free_space_root :
ERR_PTR(-ENOENT);
- BUG_ON(location->objectid == BTRFS_TREE_RELOC_OBJECTID ||
- location->offset != (u64)-1);
+ BUG_ON(location->objectid == BTRFS_TREE_RELOC_OBJECTID);
node = rb_search(&fs_info->fs_root_tree, (void *)&objectid,
btrfs_fs_roots_compare_objectids, NULL);
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH btrfs-progs] btrfs-progs: do not fail when offset of a ROOT_ITEM is not -1
2021-02-09 17:34 ` Marek Behún
@ 2021-02-19 14:05 ` David Sterba
-1 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2021-02-19 14:05 UTC (permalink / raw)
To: Marek Behún; +Cc: linux-btrfs, u-boot, David Sterba, Qu Wenruo, Tom Rini
On Tue, Feb 09, 2021 at 06:34:06PM +0100, Marek Behún wrote:
> When the btrfs_read_fs_root() function is searching a ROOT_ITEM with
> location key offset other than -1, it currently fails via BUG_ON.
>
> The offset can have other value than -1, though. This can happen for
> example if a subvolume is renamed:
>
> $ btrfs subvolume create X && sync
> Create subvolume './X'
> $ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: X$
> location key (270 ROOT_ITEM 18446744073709551615) type DIR
> transid 283 data_len 0 name_len 1
> name: X
> $ mv X Y && sync
> $ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: Y$
> location key (270 ROOT_ITEM 0) type DIR
> transid 285 data_len 0 name_len 1
> name: Y
>
> As can be seen the offset changed from -1ULL to 0.
>
> Do not fail in this case.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Cc: David Sterba <dsterba@suse.com>
> Cc: Qu Wenruo <wqu@suse.com>
> Cc: Tom Rini <trini@konsulko.com>
Added to devel, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH btrfs-progs] btrfs-progs: do not fail when offset of a ROOT_ITEM is not -1
@ 2021-02-19 14:05 ` David Sterba
0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2021-02-19 14:05 UTC (permalink / raw)
To: u-boot
On Tue, Feb 09, 2021 at 06:34:06PM +0100, Marek Beh?n wrote:
> When the btrfs_read_fs_root() function is searching a ROOT_ITEM with
> location key offset other than -1, it currently fails via BUG_ON.
>
> The offset can have other value than -1, though. This can happen for
> example if a subvolume is renamed:
>
> $ btrfs subvolume create X && sync
> Create subvolume './X'
> $ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: X$
> location key (270 ROOT_ITEM 18446744073709551615) type DIR
> transid 283 data_len 0 name_len 1
> name: X
> $ mv X Y && sync
> $ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: Y$
> location key (270 ROOT_ITEM 0) type DIR
> transid 285 data_len 0 name_len 1
> name: Y
>
> As can be seen the offset changed from -1ULL to 0.
>
> Do not fail in this case.
>
> Signed-off-by: Marek Beh?n <marek.behun@nic.cz>
> Cc: David Sterba <dsterba@suse.com>
> Cc: Qu Wenruo <wqu@suse.com>
> Cc: Tom Rini <trini@konsulko.com>
Added to devel, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-19 14:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 17:34 [PATCH btrfs-progs] btrfs-progs: do not fail when offset of a ROOT_ITEM is not -1 Marek Behún
2021-02-09 17:34 ` Marek Behún
2021-02-19 14:05 ` David Sterba
2021-02-19 14:05 ` David Sterba
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.