mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Yu Kuai <yukuai1@huaweicloud.com>, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com
Subject: Re: [PATCH 1/2] block: introduce new field flags in block_device
Date: Mon, 20 Nov 2023 11:45:14 +0100	[thread overview]
Message-ID: <f0ac497e-e599-4892-94f7-469660cb5f84@suse.de> (raw)
In-Reply-To: <20231120093847.2228127-2-yukuai1@huaweicloud.com>

On 11/20/23 10:38, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> There are multiple switches in struct block_device, use seperate bool
> fields for them is not gracefully. Add a new field flags and replace
> swithes to a bit, there are no functional changes, and preapre to add
> a new switch in the next patch.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   block/bdev.c              | 15 ++++++++-------
>   block/blk-core.c          |  7 ++++---
>   block/genhd.c             |  8 +++++---
>   block/ioctl.c             |  2 +-
>   include/linux/blk_types.h | 12 ++++++------
>   include/linux/blkdev.h    |  5 +++--
>   6 files changed, 27 insertions(+), 22 deletions(-)
> 
> diff --git a/block/bdev.c b/block/bdev.c
> index fc8d28d77495..cb849bcf61ae 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -408,10 +408,10 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno)
>   	bdev->bd_partno = partno;
>   	bdev->bd_inode = inode;
>   	bdev->bd_queue = disk->queue;
> -	if (partno)
> -		bdev->bd_has_submit_bio = disk->part0->bd_has_submit_bio;
> +	if (partno && test_bit(BD_FLAG_HAS_SUBMIT_BIO, &disk->part0->flags))
> +		set_bit(BD_FLAG_HAS_SUBMIT_BIO, &bdev->flags);
>   	else
> -		bdev->bd_has_submit_bio = false;
> +		clear_bit(BD_FLAG_HAS_SUBMIT_BIO, &bdev->flags);
>   	bdev->bd_stats = alloc_percpu(struct disk_stats);
>   	if (!bdev->bd_stats) {
>   		iput(inode);

Couldn't you achieve the very same result by using 
'READ_ONCE()/WRITE_ONCE()' and keep the structure as-is?

Cheers,

Hannes--
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg
Managing Directors: I. Totev, A. McDonald, W. Knoblich
(HRB 36809, AG Nürnberg)


  parent reply	other threads:[~2023-11-20 10:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  9:38 [PATCH 0/2] block: warn once for each partition in bio_check_ro() Yu Kuai
2023-11-20  9:38 ` [PATCH 1/2] block: introduce new field flags in block_device Yu Kuai
2023-11-20  3:00   ` Ming Lei
2023-11-20  6:37     ` Yu Kuai
2023-11-20  6:58       ` Ming Lei
2023-11-20  7:14         ` Yu Kuai
2023-11-20  8:01     ` Yu Kuai
2023-11-20 12:39       ` Ming Lei
2023-11-20 10:45   ` Hannes Reinecke [this message]
2023-11-20 13:24     ` Yu Kuai
2023-11-20  9:38 ` [PATCH 2/2] block: warn once for each partition in bio_check_ro() Yu Kuai

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=f0ac497e-e599-4892-94f7-469660cb5f84@suse.de \
    --to=hare@suse.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai1@huaweicloud.com \
    --cc=yukuai3@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®