All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs@vger.kernel.org, nborisov@suse.com
Subject: Re: [PATCH v2] btrfs: cleanup finding rotating device
Date: Tue, 18 Jan 2022 16:43:30 +0100	[thread overview]
Message-ID: <20220118154330.GN14046@twin.jikos.cz> (raw)
In-Reply-To: <d56216c5f955862d31be7c9884222fa9b7a4ddbd.1642060052.git.anand.jain@oracle.com>

On Thu, Jan 13, 2022 at 03:48:54PM +0800, Anand Jain wrote:
> The pointer to struct request_queue is used only to get device type
> rotating or the non-rotating. So use it directly.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2: Eliminate the if statement.
> 
>  fs/btrfs/volumes.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 70b085dff500..34d08c4f7b6c 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -601,7 +601,6 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
>  			struct btrfs_device *device, fmode_t flags,
>  			void *holder)
>  {
> -	struct request_queue *q;
>  	struct block_device *bdev;
>  	struct btrfs_super_block *disk_super;
>  	u64 devid;
> @@ -643,9 +642,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
>  			set_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);
>  	}
>  
> -	q = bdev_get_queue(bdev);
> -	if (!blk_queue_nonrot(q))
> -		fs_devices->rotating = true;
> +	fs_devices->rotating = !blk_queue_nonrot(bdev_get_queue(bdev));

This is an equivalent change, in the new code fs_devices->rotating will
be always set according to the last device, while in the old code, any
rotational device will set it to true and never back.

>  
>  	device->bdev = bdev;
>  	clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);
> @@ -2590,7 +2587,6 @@ static int btrfs_finish_sprout(struct btrfs_trans_handle *trans)
>  int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path)
>  {
>  	struct btrfs_root *root = fs_info->dev_root;
> -	struct request_queue *q;
>  	struct btrfs_trans_handle *trans;
>  	struct btrfs_device *device;
>  	struct block_device *bdev;
> @@ -2666,7 +2662,6 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
>  		goto error_free_zone;
>  	}
>  
> -	q = bdev_get_queue(bdev);
>  	set_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);
>  	device->generation = trans->transid;
>  	device->io_width = fs_info->sectorsize;
> @@ -2714,8 +2709,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
>  
>  	atomic64_add(device->total_bytes, &fs_info->free_chunk_space);
>  
> -	if (!blk_queue_nonrot(q))
> -		fs_devices->rotating = true;
> +	fs_devices->rotating = !blk_queue_nonrot(bdev_get_queue(bdev));

Same here.

>  
>  	orig_super_total_bytes = btrfs_super_total_bytes(fs_info->super_copy);
>  	btrfs_set_super_total_bytes(fs_info->super_copy,
> -- 
> 2.33.1

  parent reply	other threads:[~2022-01-18 15:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13  4:44 [PATCH] btrfs: cleanup finding rotating device Anand Jain
2022-01-13  7:38 ` Nikolay Borisov
2022-01-13  7:48 ` [PATCH v2] " Anand Jain
2022-01-13  7:50   ` Nikolay Borisov
2022-01-18 15:43   ` David Sterba [this message]
2022-01-19  7:43     ` Anand Jain
2022-01-20 17:08       ` David Sterba

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=20220118154330.GN14046@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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 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.