block: enhance use of GENHD_FL_UP
Subsystems (5)
cover block: enhance use of GENHD_FL_UP
This is the second group of patches which I'd like some review on as part of the *add_disk*() error handling conversion. While converting drivers to add error handling, I noticed some were using the flag GENHD_FL_UP to see if a block device is ready, or for bringing a device down, so to call del_gendisk() safely. This first group of patches just address the few areas where the flag is used directly.
Direct use of the flag GENHD_FL_UP is useful but incorrect as we can add the flag in a gendisk left half built. Instead, add a flag to actually represent the desired goal.
The next group will deal with the use of the flag for del_gendisk().
Luis Chamberlain (6):
genhd: update docs for GENHD_FL_UP
block: add flag for add_disk() completion notation
md: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED on is_mddev_broken() mmc/core/block: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED
nvme: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED fs/block_dev: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED
block/genhd.c | 8 ++++++++ drivers/md/md.h | 2 +- drivers/mmc/core/block.c | 2 +- drivers/nvme/host/core.c | 4 ++-- drivers/nvme/host/multipath.c | 2 +- fs/block_dev.c | 5 +++-- include/linux/genhd.h | 13 +++++++++++-- 7 files changed, 27 insertions(+), 9 deletions(-)
Signature · 1 line
2.27.0
RFC 1/6 genhd: update docs for GENHD_FL_UP
The GENHD_FL_UP is used internally so we can know when we can add and remove partitions, so just clarify that. Right now it has this 1980's description comparing it to network drivers "ifconfig up" idea, and that can easily lead to invalid uses.
--- include/linux/genhd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/genhd.h +1 -1
@@ -61,7 +61,7 @@ struct partition_meta_info {* Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl. * * ``GENHD_FL_UP`` (0x0010): indicates that the block device is "up", -* with a similar meaning to network interfaces. +* and we can add / remove partitions. * * ``GENHD_FL_SUPPRESS_PARTITION_INFO`` (0x0020): don't include * partition information in ``/proc/partitions`` or in the output of
Signature · 1 line
2.27.0
Re: [RFC 1/6] genhd: update docs for GENHD_FL_UP
Quoted 16 lines · Luis Chamberlain
The
GENHD_FL_UPis used internally so we can know when we can add and remove partitions, so just clarify that. Right now it has this 1980's description comparing it to network drivers "ifconfig up" idea, and that can easily lead to invalid uses.Signed-off-by Luis Chamberlain <[email protected]>--- include/linux/genhd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/genhd.h +0
-0
include/linux/genhd.h struct partition_meta_info { · line 67
Quoted 8 lines
include/linux/genhd.h +1
-1@@ -61,7 +61,7 @@ struct partition_meta_info {* Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl. * * ``GENHD_FL_UP`` (0x0010): indicates that the block device is "up", -* with a similar meaning to network interfaces. +* and we can add / remove partitions. * * ``GENHD_FL_SUPPRESS_PARTITION_INFO`` (0x0020): don't include * partition information in ``/proc/partitions`` or in the output of
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [RFC 1/6] genhd: update docs for GENHD_FL_UP
In reply to Luis ChamberlainQuoted 4 lines · Luis Chamberlain
The
GENHD_FL_UPis used internally so we can know when we can add and remove partitions, so just clarify that. Right now it has this 1980's description comparing it to network drivers "ifconfig up" idea, and that can easily lead to invalid uses.
GENHD_FL_UP actually is pretty horrible - it uses a value used for something that should be mostly read only at device runtime for state an does so badly. I actually have a patch to kill it, as we can just check if the inode for the whole device blockdev is hashed instead.
RFC 2/6 block: add flag for add_disk() completion notation
In reply to Luis ChamberlainOften drivers may have complex setups where it is not clear if their disk completed their respective *add_disk*() call. They either have to invent a setting or, they incorrectly use GENHD_FL_UP. Using GENHD_FL_UP however is used internally so we know when we can add / remove partitions safely. We can easily fail along the way prior to add_disk() completing and still have GENHD_FL_UP set, so it would not be correct in that case to call del_gendisk() on the disk.
Provide a new flag then which allows us to check if *add_disk*() completed, and conversely just make del_gendisk() check for this for drivers so that they can safely call del_gendisk() and we'll figure it out if it is safe for you to call this.
--- block/genhd.c | 8 ++++++++ include/linux/genhd.h | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
block/genhd.c +8 -0
@@ -630,6 +630,8 @@ static int __device_add_disk(struct device *parent, struct gendisk *disk,if (ret) goto exit_del_events; + disk->flags |=GENHD_FL_DISK_ADDED ; +return 0 ; exit_del_events:disk_del_events (disk);
@@ -677,6 +679,9 @@ EXPORT_SYMBOL(device_add_disk_no_queue_reg);* with put_disk(), which should be called after del_gendisk(), if * __device_add_disk() was used. * +* Drivers can safely call this even if they are not sure if the respective +* __device_add_disk() call succeeded. +* * Drivers exist which depend on the release of the gendisk to be synchronous, * it should not be deferred. *
@@ -686,6 +691,9 @@ void del_gendisk(struct gendisk *disk) {might_sleep (); +if (!blk_disk_registered (disk)) +return ; +if (WARN_ON_ONCE (!disk->queue))return ;
include/linux/genhd.h +10 -1
@@ -56,6 +56,10 @@ struct partition_meta_info {* Must not be set for devices which are removed entirely when the * media is removed. * +* ``GENHD_FL_DISK_ADDED`` (0x0002): used to clarify that the +* respective add_disk*() call completed successfully, so that +* we know we can safely process del_gendisk() on the disk. +* * ``GENHD_FL_CD`` (0x0008): the block device is a CD-ROM-style * device. * Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl.
@@ -94,7 +98,7 @@ struct partition_meta_info {* Used for multipath devices. */ #define GENHD_FL_REMOVABLE 0x0001 -/* 2 is unused (used to be GENHD_FL_DRIVERFS) */ +#define GENHD_FL_DISK_ADDED 0x0002/* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */ #define GENHD_FL_CD 0x0008#define GENHD_FL_UP 0x0010
@@ -189,6 +193,11 @@ struct gendisk {#define disk_to_cdi (disk) NULL#endif +static inline bool blk_disk_registered (struct gendisk *disk) +{ +return disk && (disk->flags &GENHD_FL_DISK_ADDED ); +} +static inline int disk_max_parts (struct gendisk *disk) {if (disk->flags &GENHD_FL_EXT_DEVT )
Signature · 1 line
2.27.0
Re: [RFC 2/6] block: add flag for add_disk() completion notation
Quoted 82 lines · Luis Chamberlain
Often drivers may have complex setups where it is not clear if their disk completed their respective *add_disk*() call. They either have to invent a setting or, they incorrectly use
GENHD_FL_UP. UsingGENHD_FL_UPhowever is used internally so we know when we can add / remove partitions safely. We can easily fail along the way prior toadd_disk()completing and still haveGENHD_FL_UPset, so it would not be correct in that case to calldel_gendisk()on the disk.Provide a new flag then which allows us to check if *add_disk*() completed, and conversely just make
del_gendisk()check for this for drivers so that they can safely calldel_gendisk()and we'll figure it out if it is safe for you to call this.Signed-off-by Luis Chamberlain <[email protected]>--- block/genhd.c | 8 ++++++++ include/linux/genhd.h | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)block/genhd.c +8
-0@@ -630,6 +630,8 @@ static int __device_add_disk(struct device *parent, struct gendisk *disk,if (ret) goto exit_del_events; + disk->flags |=GENHD_FL_DISK_ADDED ; +return 0 ; exit_del_events:disk_del_events (disk);@@ -677,6 +679,9 @@ EXPORT_SYMBOL(device_add_disk_no_queue_reg);* with put_disk(), which should be called after del_gendisk(), if * __device_add_disk() was used. * +* Drivers can safely call this even if they are not sure if the respective +* __device_add_disk() call succeeded. +* * Drivers exist which depend on the release of the gendisk to be synchronous, * it should not be deferred. * @@ -686,6 +691,9 @@ void del_gendisk(struct gendisk *disk) {might_sleep (); +if (!blk_disk_registered (disk)) +return ; +if (WARN_ON_ONCE (!disk->queue))return ;include/linux/genhd.h +5
-1@@ -56,6 +56,10 @@ struct partition_meta_info {* Must not be set for devices which are removed entirely when the * media is removed. * +* ``GENHD_FL_DISK_ADDED`` (0x0002): used to clarify that the +* respective add_disk*() call completed successfully, so that +* we know we can safely process del_gendisk() on the disk. +* * ``GENHD_FL_CD`` (0x0008): the block device is a CD-ROM-style * device. * Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl. @@ -94,7 +98,7 @@ struct partition_meta_info {* Used for multipath devices. */ #define GENHD_FL_REMOVABLE 0x0001 -/* 2 is unused (used to be GENHD_FL_DRIVERFS) */ +#define GENHD_FL_DISK_ADDED 0x0002/* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */ #define GENHD_FL_CD 0x0008#define GENHD_FL_UP 0x0010@@ -189,6 +193,11 @@ struct gendisk {#define disk_to_cdi (disk) NULL
include/linux/genhd.h struct gendisk { · line 203
Quoted 10 lines
include/linux/genhd.h +5
-0#endif +static inline bool blk_disk_registered (struct gendisk *disk) +{ +return disk && (disk->flags &GENHD_FL_DISK_ADDED ); +} +static inline int disk_max_parts (struct gendisk *disk) {if (disk->flags &GENHD_FL_EXT_DEVT )
Bah. The flag is named 'DISK_ADDED', and the wrapper 'disk_registered'. Please use the same wording (either 'added' or 'registered') for both to avoid confusion.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [RFC 2/6] block: add flag for add_disk() completion notation
Quoted 84 lines · Hannes Reinecke
Quoted 83 lines · Luis Chamberlain
Often drivers may have complex setups where it is not clear if their disk completed their respective *add_disk*() call. They either have to invent a setting or, they incorrectly use
GENHD_FL_UP. UsingGENHD_FL_UPhowever is used internally so we know when we can add / remove partitions safely. We can easily fail along the way prior toadd_disk()completing and still haveGENHD_FL_UPset, so it would not be correct in that case to calldel_gendisk()on the disk.Provide a new flag then which allows us to check if *add_disk*() completed, and conversely just make
del_gendisk()check for this for drivers so that they can safely calldel_gendisk()and we'll figure it out if it is safe for you to call this.Signed-off-by Luis Chamberlain <[email protected]>--- block/genhd.c | 8 ++++++++ include/linux/genhd.h | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)block/genhd.c +8
-0@@ -630,6 +630,8 @@ static int __device_add_disk(struct device *parent, struct gendisk *disk,if (ret) goto exit_del_events; + disk->flags |=GENHD_FL_DISK_ADDED ; +return 0 ; exit_del_events:disk_del_events (disk);@@ -677,6 +679,9 @@ EXPORT_SYMBOL(device_add_disk_no_queue_reg);* with put_disk(), which should be called after del_gendisk(), if * __device_add_disk() was used. * +* Drivers can safely call this even if they are not sure if the respective +* __device_add_disk() call succeeded. +* * Drivers exist which depend on the release of the gendisk to be synchronous, * it should not be deferred. * @@ -686,6 +691,9 @@ void del_gendisk(struct gendisk *disk) {might_sleep (); +if (!blk_disk_registered (disk)) +return ; +if (WARN_ON_ONCE (!disk->queue))return ;include/linux/genhd.h +9
-1@@ -56,6 +56,10 @@ struct partition_meta_info {* Must not be set for devices which are removed entirely when the * media is removed. * +* ``GENHD_FL_DISK_ADDED`` (0x0002): used to clarify that the +* respective add_disk*() call completed successfully, so that +* we know we can safely process del_gendisk() on the disk. +* * ``GENHD_FL_CD`` (0x0008): the block device is a CD-ROM-style * device. * Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl. @@ -94,7 +98,7 @@ struct partition_meta_info {* Used for multipath devices. */ #define GENHD_FL_REMOVABLE 0x0001 -/* 2 is unused (used to be GENHD_FL_DRIVERFS) */ +#define GENHD_FL_DISK_ADDED 0x0002/* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */ #define GENHD_FL_CD 0x0008#define GENHD_FL_UP 0x0010@@ -189,6 +193,11 @@ struct gendisk {#define disk_to_cdi (disk) NULL#endif +static inline bool blk_disk_registered (struct gendisk *disk) +{ +return disk && (disk->flags &GENHD_FL_DISK_ADDED ); +}
Quoted 8 lines
include/linux/genhd.h struct gendisk {
Quoted 5 lines
include/linux/genhd.h +1
-0+static inline int disk_max_parts (struct gendisk *disk) {if (disk->flags &GENHD_FL_EXT_DEVT )Bah. The flag is named '
DISK_ADDED', and the wrapper 'disk_registered'. Please use the same wording (either 'added' or 'registered') for both to avoid confusion.
Indeed, will stick with blk_disk_added() then.
Luis
Re: [RFC 2/6] block: add flag for add_disk() completion notation
In reply to Luis Chamberlainblock/genhd.c void del_gendisk(struct gendisk *disk) · line 696
Quoted 6 lines
{
block/genhd.c +3
-0might_sleep (); +if (!blk_disk_registered (disk)) +return ; +
Can't say I like this all that much. Drivers should keep some basic sanity for their unregister path, and while blk_disk_registered can be useful, it's uses should be kept at a minimum.
Re: [RFC 2/6] block: add flag for add_disk() completion notation
Quoted 10 lines · Christoph Hellwig
block/genhd.c void del_gendisk(struct gendisk *disk) · line 696
Quoted 6 lines
{
block/genhd.c +3
-0might_sleep (); +if (!blk_disk_registered (disk)) +return ; +Can't say I like this all that much. Drivers should keep some basic sanity for their unregister path, and while
blk_disk_registeredcan be useful, it's uses should be kept at a minimum.
This just means quite a bit of drivers have to invent some scheme to keep tabs on if registration was completed or not on their own... I can't see too much downfall for us to embrace this. Anyway I'll keep it in the mix and respin it as proper patch as it seems you suggested a respin of the series.
Luis
RFC 3/6 md: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED on is_mddev_broken()
In reply to Luis ChamberlainThe GENHD_FL_DISK_ADDED flag is what we really want, as the flag GENHD_FL_UP could be set on a semi-initialized device.
--- drivers/md/md.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.h +1 -1
@@ -766,7 +766,7 @@ static inline bool is_mddev_broken(struct md_rdev *rdev, const char *md_type) {int flags = rdev->bdev->bd_disk->flags; -if (!(flags &GENHD_FL_UP )) { +if (!(flags &GENHD_FL_DISK_ADDED )) {if (!test_and_set_bit (MD_BROKEN , &rdev->mddev->flags))pr_warn ("md: %s: %s array has a missing/failed member\n" ,mdname (rdev->mddev), md_type);
Signature · 1 line
2.27.0
Re: [RFC 3/6] md: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED on is_mddev_broken()
Quoted 14 lines · Luis Chamberlain
The
GENHD_FL_DISK_ADDEDflag is what we really want, as the flagGENHD_FL_UPcould be set on a semi-initialized device.Signed-off-by Luis Chamberlain <[email protected]>--- drivers/md/md.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/md.h +0
-0
drivers/md/md.h static inline bool is_mddev_broken(struct md_rdev *rdev, const char *md_type) · line 772
Quoted 8 lines
drivers/md/md.h +1
-1@@ -766,7 +766,7 @@ static inline bool is_mddev_broken(struct md_rdev *rdev, const char *md_type) {int flags = rdev->bdev->bd_disk->flags; -if (!(flags &GENHD_FL_UP )) { +if (!(flags &GENHD_FL_DISK_ADDED )) {if (!test_and_set_bit (MD_BROKEN , &rdev->mddev->flags))pr_warn ("md: %s: %s array has a missing/failed member\n" ,mdname (rdev->mddev), md_type);
Why again did you introduce the wrapper?
Shouldn't it be used here?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [RFC 3/6] md: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED on is_mddev_broken()
Quoted 9 lines · Hannes Reinecke
Quoted 8 lines · Luis Chamberlain
The
GENHD_FL_DISK_ADDEDflag is what we really want, as the flagGENHD_FL_UPcould be set on a semi-initialized device.Signed-off-by Luis Chamberlain <[email protected]>--- drivers/md/md.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
drivers/md/md.h static inline bool is_mddev_broken(struct md_rdev *rdev, const char *md_type) · line 772
Quoted 13 lines
drivers/md/md.h +1
-1@@ -766,7 +766,7 @@ static inline bool is_mddev_broken(struct md_rdev *rdev, const char *md_type) {int flags = rdev->bdev->bd_disk->flags; -if (!(flags &GENHD_FL_UP )) { +if (!(flags &GENHD_FL_DISK_ADDED )) {if (!test_and_set_bit (MD_BROKEN , &rdev->mddev->flags))pr_warn ("md: %s: %s array has a missing/failed member\n" ,mdname (rdev->mddev), md_type);Why again did you introduce the wrapper?
Shouldn't it be used here?
Indeed, and that lets us remove the flag copy. Will fix. Thanks for the review.
Luis
Re: [RFC 3/6] md: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED on is_mddev_broken()
In reply to Luis ChamberlainQuoted 14 lines · Luis Chamberlain
The
GENHD_FL_DISK_ADDEDflag is what we really want, as the flagGENHD_FL_UPcould be set on a semi-initialized device.Signed-off-by Luis Chamberlain <[email protected]>--- drivers/md/md.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/md.h +0
-0
drivers/md/md.h static inline bool is_mddev_broken(struct md_rdev *rdev, const char *md_type) · line 769
Quoted 5 lines
drivers/md/md.h +1
-1@@ -766,7 +766,7 @@ static inline bool is_mddev_broken(struct md_rdev *rdev, const char *md_type) {int flags = rdev->bdev->bd_disk->flags; -if (!(flags &GENHD_FL_UP )) { +if (!(flags &GENHD_FL_DISK_ADDED )) {
Thanks for the patch Luis! And thanks Christoph for looping me in on the last iteration.
I think specifically for md, both flags are interchangeable - if add_disk() is not completed, I'm pretty sure we cannot have the array properly working hence we shouldn't ever reach this check for such device. Nevertheless, technically speaking Christoph seems correct and we are checking here in fact if the disk was del_gendisk'ed(). My opinion is that we don't need to change this usage, if possible, but I'm not strongly against the change if you feel it fits better.
Just double-checking - after del_gendisk(), this flag is removed anyways right? Oh, and if possible, loop me in CC for next revisions, using this email. Cheers,
Guilherme
RFC 4/6 mmc/core/block: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED
In reply to Luis ChamberlainThe GENHD_FL_DISK_ADDED flag is what we really want, as the flag GENHD_FL_UP could be set on a semi-initialized device.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -2637,7 +2637,7 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)* from being accepted. */ card = md->queue.card; -if (md->disk->flags &GENHD_FL_UP ) { +if (md->disk->flags &GENHD_FL_DISK_ADDED ) {device_remove_file (disk_to_dev (md->disk), &md->force_ro);if ((md->area_type &MMC_BLK_DATA_AREA_BOOT ) && card->ext_csd.boot_ro_lockable)
Signature · 1 line
2.27.0
Re: [RFC 4/6] mmc/core/block: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED
Quoted 14 lines · Luis Chamberlain
The
GENHD_FL_DISK_ADDEDflag is what we really want, as the flagGENHD_FL_UPcould be set on a semi-initialized device.Signed-off-by Luis Chamberlain <[email protected]>--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mmc/core/block.c +0
-0
drivers/mmc/core/block.c static void mmc_blk_remove_req(struct mmc_blk_data *md) · line 2643
Quoted 8 lines
drivers/mmc/core/block.c +1
-1@@ -2637,7 +2637,7 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)* from being accepted. */ card = md->queue.card; -if (md->disk->flags &GENHD_FL_UP ) { +if (md->disk->flags &GENHD_FL_DISK_ADDED ) {device_remove_file (disk_to_dev (md->disk), &md->force_ro);if ((md->area_type &MMC_BLK_DATA_AREA_BOOT ) && card->ext_csd.boot_ro_lockable)
Same here: as you have provided a wrapper please use it.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
RFC 5/6 nvme: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED
In reply to Luis ChamberlainThe GENHD_FL_DISK_ADDED flag is what we really want, as the flag GENHD_FL_UP could be set on a semi-initialized device.
--- drivers/nvme/host/core.c | 4 ++-- drivers/nvme/host/multipath.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +2 -2
@@ -1819,7 +1819,7 @@ static void nvme_update_disk_info(struct gendisk *disk,static inline bool nvme_first_scan (struct gendisk *disk) {/* nvme_alloc_ns() scans the disk prior to adding it */ -return !(disk->flags &GENHD_FL_UP ); +return !(disk->flags &GENHD_FL_DISK_ADDED ); }static void nvme_set_chunk_sectors (struct nvme_ns *ns,struct nvme_id_ns *id)
@@ -3823,7 +3823,7 @@ static void nvme_ns_remove(struct nvme_ns *ns)nvme_mpath_clear_current_path (ns);synchronize_srcu (&ns->head->srcu);/* wait for concurrent submissions */ -if (ns->disk->flags &GENHD_FL_UP ) { +if (ns->disk->flags &GENHD_FL_DISK_ADDED ) {if (!nvme_ns_head_multipath (ns->head))nvme_cdev_del (&ns->cdev, &ns->cdev_device);del_gendisk (ns->disk);
drivers/nvme/host/multipath.c +1 -1
@@ -764,7 +764,7 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head) {if (!head->disk)return ; -if (head->disk->flags &GENHD_FL_UP ) { +if (head->disk->flags &GENHD_FL_DISK_ADDED ) {nvme_cdev_del (&head->cdev, &head->cdev_device);del_gendisk (head->disk); }
Signature · 1 line
2.27.0
Re: [RFC 5/6] nvme: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED
Quoted 37 lines · Luis Chamberlain
The
GENHD_FL_DISK_ADDEDflag is what we really want, as the flagGENHD_FL_UPcould be set on a semi-initialized device.Signed-off-by Luis Chamberlain <[email protected]>--- drivers/nvme/host/core.c | 4 ++-- drivers/nvme/host/multipath.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/nvme/host/core.c +2
-2@@ -1819,7 +1819,7 @@ static void nvme_update_disk_info(struct gendisk *disk,static inline bool nvme_first_scan (struct gendisk *disk) {/* nvme_alloc_ns() scans the disk prior to adding it */ -return !(disk->flags &GENHD_FL_UP ); +return !(disk->flags &GENHD_FL_DISK_ADDED ); }static void nvme_set_chunk_sectors (struct nvme_ns *ns,struct nvme_id_ns *id)@@ -3823,7 +3823,7 @@ static void nvme_ns_remove(struct nvme_ns *ns)nvme_mpath_clear_current_path (ns);synchronize_srcu (&ns->head->srcu);/* wait for concurrent submissions */ -if (ns->disk->flags &GENHD_FL_UP ) { +if (ns->disk->flags &GENHD_FL_DISK_ADDED ) {if (!nvme_ns_head_multipath (ns->head))nvme_cdev_del (&ns->cdev, &ns->cdev_device);del_gendisk (ns->disk);drivers/nvme/host/multipath.c +0
-0
drivers/nvme/host/multipath.c void nvme_mpath_remove_disk(struct nvme_ns_head *head) · line 770
Quoted 8 lines
drivers/nvme/host/multipath.c +1
-1@@ -764,7 +764,7 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head) {if (!head->disk)return ; -if (head->disk->flags &GENHD_FL_UP ) { +if (head->disk->flags &GENHD_FL_DISK_ADDED ) {nvme_cdev_del (&head->cdev, &head->cdev_device);del_gendisk (head->disk); }
Same here: please use the wrapper.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
RFC 6/6 fs/block_dev: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED
In reply to Luis ChamberlainThe GENHD_FL_DISK_ADDED flag is what we really want, as the flag GENHD_FL_UP could be set on a semi-initialized device.
--- fs/block_dev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/block_dev.c +3 -2
@@ -1338,7 +1338,8 @@ struct block_device *blkdev_get_no_open(dev_t dev) disk = bdev->bd_disk;if (!kobject_get_unless_zero (&disk_to_dev (disk)->kobj)) goto bdput; -if ((disk->flags & (GENHD_FL_UP |GENHD_FL_HIDDEN )) !=GENHD_FL_UP ) +if ((disk->flags & + (GENHD_FL_DISK_ADDED |GENHD_FL_HIDDEN )) !=GENHD_FL_DISK_ADDED ) goto put_disk;if (!try_module_get (bdev->bd_disk->fops->owner)) goto put_disk;
@@ -1407,7 +1408,7 @@ struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder)mutex_lock (&disk->open_mutex); ret = -ENXIO ; -if (!(disk->flags &GENHD_FL_UP )) +if (!(disk->flags &GENHD_FL_DISK_ADDED )) goto abort_claiming;if (bdev_is_partition (bdev)) ret =blkdev_get_part (bdev, mode);
Signature · 1 line
2.27.0
So while patch 1 seems a little pointless given where I'd like to go, the rest of the series goes exactly where I'd like to move things. Can you respin this one quickly and send it out to Jens without the RFC?