Commit 86416916 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: move GENHD_FL_NATIVE_CAPACITY to disk->state

The flag to indicate an unlocked native capacity is dynamic state,
not a driver capability flag, so move it to disk->state.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211122130625.1136848-2-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d9337a42
...@@ -527,18 +527,15 @@ int bdev_resize_partition(struct gendisk *disk, int partno, sector_t start, ...@@ -527,18 +527,15 @@ int bdev_resize_partition(struct gendisk *disk, int partno, sector_t start,
static bool disk_unlock_native_capacity(struct gendisk *disk) static bool disk_unlock_native_capacity(struct gendisk *disk)
{ {
const struct block_device_operations *bdops = disk->fops; if (!disk->fops->unlock_native_capacity ||
test_and_set_bit(GD_NATIVE_CAPACITY, &disk->state)) {
if (bdops->unlock_native_capacity &&
!(disk->flags & GENHD_FL_NATIVE_CAPACITY)) {
printk(KERN_CONT "enabling native capacity\n");
bdops->unlock_native_capacity(disk);
disk->flags |= GENHD_FL_NATIVE_CAPACITY;
return true;
} else {
printk(KERN_CONT "truncated\n"); printk(KERN_CONT "truncated\n");
return false; return false;
} }
printk(KERN_CONT "enabling native capacity\n");
disk->fops->unlock_native_capacity(disk);
return true;
} }
void blk_drop_partitions(struct gendisk *disk) void blk_drop_partitions(struct gendisk *disk)
......
...@@ -60,12 +60,6 @@ struct partition_meta_info { ...@@ -60,12 +60,6 @@ struct partition_meta_info {
* (``BLOCK_EXT_MAJOR``). * (``BLOCK_EXT_MAJOR``).
* This affects the maximum number of partitions. * This affects the maximum number of partitions.
* *
* ``GENHD_FL_NATIVE_CAPACITY`` (0x0080): based on information in the
* partition table, the device's capacity has been extended to its
* native capacity; i.e. the device has hidden capacity used by one
* of the partitions (this is a flag used so that native capacity is
* only ever unlocked once).
*
* ``GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE`` (0x0100): event polling is * ``GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE`` (0x0100): event polling is
* blocked whenever a writer holds an exclusive lock. * blocked whenever a writer holds an exclusive lock.
* *
...@@ -86,7 +80,6 @@ struct partition_meta_info { ...@@ -86,7 +80,6 @@ struct partition_meta_info {
#define GENHD_FL_CD 0x0008 #define GENHD_FL_CD 0x0008
#define GENHD_FL_SUPPRESS_PARTITION_INFO 0x0020 #define GENHD_FL_SUPPRESS_PARTITION_INFO 0x0020
#define GENHD_FL_EXT_DEVT 0x0040 #define GENHD_FL_EXT_DEVT 0x0040
#define GENHD_FL_NATIVE_CAPACITY 0x0080
#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100 #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100
#define GENHD_FL_NO_PART_SCAN 0x0200 #define GENHD_FL_NO_PART_SCAN 0x0200
#define GENHD_FL_HIDDEN 0x0400 #define GENHD_FL_HIDDEN 0x0400
...@@ -140,6 +133,7 @@ struct gendisk { ...@@ -140,6 +133,7 @@ struct gendisk {
#define GD_NEED_PART_SCAN 0 #define GD_NEED_PART_SCAN 0
#define GD_READ_ONLY 1 #define GD_READ_ONLY 1
#define GD_DEAD 2 #define GD_DEAD 2
#define GD_NATIVE_CAPACITY 3
struct mutex open_mutex; /* open/close mutex */ struct mutex open_mutex; /* open/close mutex */
unsigned open_partitions; /* number of open partitions */ unsigned open_partitions; /* number of open partitions */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment