public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Anand Jain <anand.jain@oracle.com>, linux-btrfs@vger.kernel.org
Cc: josef@toxicpanda.com, dsterba@suse.com, l@damenly.su
Subject: Re: [PATCH v4 2/4] btrfs: redeclare btrfs_stale_devices arg1 to dev_t
Date: Mon, 10 Jan 2022 17:20:14 +0200	[thread overview]
Message-ID: <df5e06aa-5ed4-0df2-9210-ea8d19069cba@suse.com> (raw)
In-Reply-To: <d05f560ad6b65dd6fd7fca0e54271d3d0d8a3f8b.1641794058.git.anand.jain@oracle.com>



On 10.01.22 г. 15:23, Anand Jain wrote:
> After the commit (btrfs: harden identification of the stale device), we
> don't have to match the device path anymore. Instead, we match the dev_t.
> So pass in the dev_t instead of the device-path, in the call chain
> btrfs_forget_devices()->btrfs_free_stale_devices().
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v4: Change log updated drop commit id
>     Use name[0] instead of strlen()
>     Change logic from !lookup_bdev() to lookup_bdev == 0
> v3: -
> 
>  fs/btrfs/super.c   |  8 +++++++-
>  fs/btrfs/volumes.c | 51 +++++++++++++++++++++++++---------------------
>  fs/btrfs/volumes.h |  2 +-
>  3 files changed, 36 insertions(+), 25 deletions(-)
> 
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 1ff03fb6c64a..6eca93096ca5 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -2386,6 +2386,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
>  {
>  	struct btrfs_ioctl_vol_args *vol;
>  	struct btrfs_device *device = NULL;
> +	dev_t devt = 0;
>  	int ret = -ENOTTY;
>  
>  	if (!capable(CAP_SYS_ADMIN))
> @@ -2405,7 +2406,12 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
>  		mutex_unlock(&uuid_mutex);
>  		break;
>  	case BTRFS_IOC_FORGET_DEV:
> -		ret = btrfs_forget_devices(vol->name);
> +		if (vol->name[0] != '\0') {
> +			ret = lookup_bdev(vol->name, &devt);
> +			if (ret)
> +				break;
> +		}
> +		ret = btrfs_forget_devices(devt);
>  		break;
>  	case BTRFS_IOC_DEVICES_READY:
>  		mutex_lock(&uuid_mutex);

<snip>

> @@ -577,16 +572,16 @@ static int device_matched(struct btrfs_device *device, const char *path)
>  /*
>   *  Search and remove all stale (devices which are not mounted) devices.
>   *  When both inputs are NULL, it will search and release all stale devices.
> - *  path:	Optional. When provided will it release all unmounted devices
> - *		matching this path only.
> + *  devt:	Optional. When provided will it release all unmounted devices
> + *		matching this devt only.
>   *  skip_dev:	Optional. Will skip this device when searching for the stale
>   *		devices.
> - *  Return:	0 for success or if @path is NULL.
> - * 		-EBUSY if @path is a mounted device.
> - * 		-ENOENT if @path does not match any device in the list.
> + *  Return:	0 for success or if @devt is 0.
> + *		-EBUSY if @devt is a mounted device.
> + *		-ENOENT if @devt does not match any device in the list.
>   */
> -static int btrfs_free_stale_devices(const char *path,
> -				     struct btrfs_device *skip_device)
> +static int btrfs_free_stale_devices(dev_t devt,
> +				    struct btrfs_device *skip_device)
>  {
>  	struct btrfs_fs_devices *fs_devices, *tmp_fs_devices;
>  	struct btrfs_device *device, *tmp_device;
> @@ -594,7 +589,7 @@ static int btrfs_free_stale_devices(const char *path,
>  
>  	lockdep_assert_held(&uuid_mutex);
>  
> -	if (path)
> +	if (devt)
>  		ret = -ENOENT;
>  
>  	list_for_each_entry_safe(fs_devices, tmp_fs_devices, &fs_uuids, fs_list) {
> @@ -604,14 +599,14 @@ static int btrfs_free_stale_devices(const char *path,
>  					 &fs_devices->devices, dev_list) {
>  			if (skip_device && skip_device == device)
>  				continue;
> -			if (path && !device->name)
> +			if (devt && !device->name)

This check is now rendered obsolete since ->name is used iff we have
passed a patch to match against it, but since your series removes the
path altogether having device->name becomes obsolete, hence it can be
removed.

<snip>

  reply	other threads:[~2022-01-10 15:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 13:23 [PATCH v4 0/4] btrfs: match device by dev_t Anand Jain
2022-01-10 13:23 ` [PATCH v4 1/4] btrfs: harden identification of the stale device Anand Jain
2022-01-10 14:41   ` Nikolay Borisov
2022-01-11  4:50     ` [External] : " Anand Jain
2022-01-10 13:23 ` [PATCH v4 2/4] btrfs: redeclare btrfs_stale_devices arg1 to dev_t Anand Jain
2022-01-10 15:20   ` Nikolay Borisov [this message]
2022-01-11  4:51     ` [External] : " Anand Jain
2022-01-11  8:30       ` Nikolay Borisov
2022-01-11 12:36         ` Anand Jain
2022-01-11 12:49           ` Nikolay Borisov
2022-01-11 13:58             ` Nikolay Borisov
2022-01-12  4:13               ` Anand Jain
2022-01-10 13:23 ` [PATCH v4 3/4] btrfs: add device major-minor info in the struct btrfs_device Anand Jain
2022-01-10 20:13   ` Goffredo Baroncelli
2022-01-11  5:27     ` Anand Jain
2022-01-11 17:18       ` Goffredo Baroncelli
2022-01-12  3:17         ` Anand Jain
2022-01-13  6:09           ` Goffredo Baroncelli
2022-01-10 13:23 ` [PATCH v4 4/4] btrfs: use dev_t to match device in device_matched Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df5e06aa-5ed4-0df2-9210-ea8d19069cba@suse.com \
    --to=nborisov@suse.com \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=l@damenly.su \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox