[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f0ac497e-e599-4892-94f7-469660cb5f84@suse.de>
Date: Mon, 20 Nov 2023 11:45:14 +0100
From: Hannes Reinecke <hare@...e.de>
To: Yu Kuai <yukuai1@...weicloud.com>, axboe@...nel.dk
Cc: linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
yukuai3@...wei.com, yi.zhang@...wei.com, yangerkun@...wei.com
Subject: Re: [PATCH 1/2] block: introduce new field flags in block_device
On 11/20/23 10:38, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@...wei.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@...wei.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@...e.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)
Powered by blists - more mailing lists