mbox series

[v5,0/4] btrfs: match device by dev_t

Message ID cover.1641963296.git.anand.jain@oracle.com (mailing list archive)
Headers show
Series btrfs: match device by dev_t | expand

Message

Anand Jain Jan. 12, 2022, 5:05 a.m. UTC
v5: Patch 1/4 device_matched() to return bool; absorb errors in it to false.
     Move if (!device->name) into device_matched().
    Patch 2/4 fix the commit title and add a comment.
    Patch 3/4 add more comment about btrfs_device::devt.
    
v4: Return 1 for device matched in device_matched()
    Use scnprintf() instead of sprintf() in device_matched()
    Change log updated drop commit id
    Use str[0] instead of strlen()
    Change logic from !lookup_bdev() to lookup_bdev == 0

v3: Added patch 3/4 saves and uses dev_t in btrfs_device and
    thus patch 4/4 removes the function device_matched().
    fstests btrfs passed with no new regressions.

v2: Fix 
     sparse: warning: incorrect type in argument 1 (different address spaces)
     For using device->name->str

    Fix Josef suggestion to pass dev_t instead of device-path in the
     patch 2/2.

--- original cover letter -----
Patch 1 is the actual bug fix and should go to stable 5.4 as well.
On 5.4 patch1 conflicts (outside of the changes in the patch),
so not yet marked for the stable.

Patch 2 simplifies calling lookup_bdev() in the device_matched()
by moving the same to the parent function two levels up.

Patch 2 is not merged with 1 because to keep the patch 1 changes local
to a function so that it can be easily backported to 5.4 and 5.10.

We should save the dev_t in struct btrfs_device with that may be
we could clean up a few more things, including fixing the below sparse
warning.

  sparse: sparse: incorrect type in argument 1 (different address spaces)

For using without rcu:

  error = lookup_bdev(device->name->str, &dev_old); 


Anand Jain (4):
  btrfs: harden identification of the stale device
  btrfs: redeclare btrfs_free_stale_devices arg1 to dev_t
  btrfs: add device major-minor info in the struct btrfs_device
  btrfs: use dev_t to match device in device_matched

 fs/btrfs/dev-replace.c |  3 ++
 fs/btrfs/super.c       |  8 ++++-
 fs/btrfs/volumes.c     | 67 +++++++++++++++++-------------------------
 fs/btrfs/volumes.h     |  7 ++++-
 4 files changed, 43 insertions(+), 42 deletions(-)

Comments

Anand Jain Jan. 18, 2022, 2:02 a.m. UTC | #1
David, Gentle ping about this patch set.
Thanks, Anand


On 12/01/2022 13:05, Anand Jain wrote:
> v5: Patch 1/4 device_matched() to return bool; absorb errors in it to false.
>       Move if (!device->name) into device_matched().
>      Patch 2/4 fix the commit title and add a comment.
>      Patch 3/4 add more comment about btrfs_device::devt.
>      
> v4: Return 1 for device matched in device_matched()
>      Use scnprintf() instead of sprintf() in device_matched()
>      Change log updated drop commit id
>      Use str[0] instead of strlen()
>      Change logic from !lookup_bdev() to lookup_bdev == 0
> 
> v3: Added patch 3/4 saves and uses dev_t in btrfs_device and
>      thus patch 4/4 removes the function device_matched().
>      fstests btrfs passed with no new regressions.
> 
> v2: Fix
>       sparse: warning: incorrect type in argument 1 (different address spaces)
>       For using device->name->str
> 
>      Fix Josef suggestion to pass dev_t instead of device-path in the
>       patch 2/2.
> 
> --- original cover letter -----
> Patch 1 is the actual bug fix and should go to stable 5.4 as well.
> On 5.4 patch1 conflicts (outside of the changes in the patch),
> so not yet marked for the stable.
> 
> Patch 2 simplifies calling lookup_bdev() in the device_matched()
> by moving the same to the parent function two levels up.
> 
> Patch 2 is not merged with 1 because to keep the patch 1 changes local
> to a function so that it can be easily backported to 5.4 and 5.10.
> 
> We should save the dev_t in struct btrfs_device with that may be
> we could clean up a few more things, including fixing the below sparse
> warning.
> 
>    sparse: sparse: incorrect type in argument 1 (different address spaces)
> 
> For using without rcu:
> 
>    error = lookup_bdev(device->name->str, &dev_old);
> 
> 
> Anand Jain (4):
>    btrfs: harden identification of the stale device
>    btrfs: redeclare btrfs_free_stale_devices arg1 to dev_t
>    btrfs: add device major-minor info in the struct btrfs_device
>    btrfs: use dev_t to match device in device_matched
> 
>   fs/btrfs/dev-replace.c |  3 ++
>   fs/btrfs/super.c       |  8 ++++-
>   fs/btrfs/volumes.c     | 67 +++++++++++++++++-------------------------
>   fs/btrfs/volumes.h     |  7 ++++-
>   4 files changed, 43 insertions(+), 42 deletions(-)
>
David Sterba Jan. 18, 2022, 3:31 p.m. UTC | #2
On Wed, Jan 12, 2022 at 01:05:58PM +0800, Anand Jain wrote:
> v5: Patch 1/4 device_matched() to return bool; absorb errors in it to false.
>      Move if (!device->name) into device_matched().
>     Patch 2/4 fix the commit title and add a comment.
>     Patch 3/4 add more comment about btrfs_device::devt.
>     
> v4: Return 1 for device matched in device_matched()
>     Use scnprintf() instead of sprintf() in device_matched()
>     Change log updated drop commit id
>     Use str[0] instead of strlen()
>     Change logic from !lookup_bdev() to lookup_bdev == 0
> 
> v3: Added patch 3/4 saves and uses dev_t in btrfs_device and
>     thus patch 4/4 removes the function device_matched().
>     fstests btrfs passed with no new regressions.
> 
> v2: Fix 
>      sparse: warning: incorrect type in argument 1 (different address spaces)
>      For using device->name->str
> 
>     Fix Josef suggestion to pass dev_t instead of device-path in the
>      patch 2/2.
> 
> --- original cover letter -----
> Patch 1 is the actual bug fix and should go to stable 5.4 as well.
> On 5.4 patch1 conflicts (outside of the changes in the patch),
> so not yet marked for the stable.
> 
> Patch 2 simplifies calling lookup_bdev() in the device_matched()
> by moving the same to the parent function two levels up.
> 
> Patch 2 is not merged with 1 because to keep the patch 1 changes local
> to a function so that it can be easily backported to 5.4 and 5.10.
> 
> We should save the dev_t in struct btrfs_device with that may be
> we could clean up a few more things, including fixing the below sparse
> warning.
> 
>   sparse: sparse: incorrect type in argument 1 (different address spaces)
> 
> For using without rcu:
> 
>   error = lookup_bdev(device->name->str, &dev_old); 
> 
> 
> Anand Jain (4):
>   btrfs: harden identification of the stale device
>   btrfs: redeclare btrfs_free_stale_devices arg1 to dev_t
>   btrfs: add device major-minor info in the struct btrfs_device
>   btrfs: use dev_t to match device in device_matched

V5 looks good to me, thanks. If there are still fixups needed, I'm not
sure Nick has seen v5, I'll fold them to the patches in misc-next.