diff mbox series

[3/5,v2] btrfs: handle ENOENT in btrfs_uuid_tree_iterate

Message ID 20191206163900.168465-1-josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Josef Bacik Dec. 6, 2019, 4:39 p.m. UTC
If we get an -ENOENT back from btrfs_uuid_iter_rem when iterating the
uuid tree we'll just continue and do btrfs_next_item().  However we've
done a btrfs_release_path() at this point and no longer have a valid
path.  So increment the key and go back and do a normal search.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
v1->v2:
- increase key.offset instead of key.objectid so we don't skip over a bunch of
  keys.

 fs/btrfs/uuid-tree.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Filipe Manana Dec. 6, 2019, 4:46 p.m. UTC | #1
On Fri, Dec 6, 2019 at 4:39 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> If we get an -ENOENT back from btrfs_uuid_iter_rem when iterating the
> uuid tree we'll just continue and do btrfs_next_item().  However we've
> done a btrfs_release_path() at this point and no longer have a valid
> path.  So increment the key and go back and do a normal search.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Now it looks good, thanks.

> ---
> v1->v2:
> - increase key.offset instead of key.objectid so we don't skip over a bunch of
>   keys.
>
>  fs/btrfs/uuid-tree.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
> index 91caab63bdf5..76b84f2397b1 100644
> --- a/fs/btrfs/uuid-tree.c
> +++ b/fs/btrfs/uuid-tree.c
> @@ -324,6 +324,8 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
>                                 }
>                                 if (ret < 0 && ret != -ENOENT)
>                                         goto out;
> +                               key.offset++;
> +                               goto again_search_slot;
>                         }
>                         item_size -= sizeof(subid_le);
>                         offset += sizeof(subid_le);
> --
> 2.23.0
>
Johannes Thumshirn Dec. 9, 2019, 10:52 a.m. UTC | #2
On 06/12/2019 17:39, Josef Bacik wrote:
> If we get an -ENOENT back from btrfs_uuid_iter_rem when iterating the
> uuid tree we'll just continue and do btrfs_next_item().  However we've
> done a btrfs_release_path() at this point and no longer have a valid
> path.  So increment the key and go back and do a normal search.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> v1->v2:
> - increase key.offset instead of key.objectid so we don't skip over a bunch of
>   keys.
> 
>  fs/btrfs/uuid-tree.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
> index 91caab63bdf5..76b84f2397b1 100644
> --- a/fs/btrfs/uuid-tree.c
> +++ b/fs/btrfs/uuid-tree.c
> @@ -324,6 +324,8 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
>  				}
>  				if (ret < 0 && ret != -ENOENT)
>  					goto out;
> +				key.offset++;
> +				goto again_search_slot;
>  			}
>  			item_size -= sizeof(subid_le);
>  			offset += sizeof(subid_le);
> 

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
diff mbox series

Patch

diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
index 91caab63bdf5..76b84f2397b1 100644
--- a/fs/btrfs/uuid-tree.c
+++ b/fs/btrfs/uuid-tree.c
@@ -324,6 +324,8 @@  int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
 				}
 				if (ret < 0 && ret != -ENOENT)
 					goto out;
+				key.offset++;
+				goto again_search_slot;
 			}
 			item_size -= sizeof(subid_le);
 			offset += sizeof(subid_le);