pass a gendisk instead of block_device in the partitioning code
Subsystems (6)
Hi Jens,
this series passes the gendisk instead of the block_device when operating on the whole device in the partition code.
PATCH 1/4 block: store a gendisk in struct parsed_partitions
Partition scanning only happens on the whole device, so pass a struct gendisk instead of the whole device block_device to the scanners. This allows to simplify printing the device name in various places as the disk name is available in disk->name.
--- block/partitions/acorn.c | 4 ++-- block/partitions/aix.c | 20 ++------------------ block/partitions/amiga.c | 7 +++---- block/partitions/atari.c | 4 ++-- block/partitions/check.h | 2 +- block/partitions/cmdline.c | 6 ++---- block/partitions/core.c | 6 +++--- block/partitions/efi.c | 36 +++++++++++++++++------------------- block/partitions/ibm.c | 4 ++-- block/partitions/ldm.c | 18 +++++++++--------- block/partitions/mac.c | 2 +- block/partitions/msdos.c | 6 ++++-- block/partitions/sgi.c | 5 ++--- block/partitions/sun.c | 5 ++--- 14 files changed, 52 insertions(+), 73 deletions(-)
block/partitions/acorn.c +2 -2
@@ -275,7 +275,7 @@ int adfspart_check_ADFS(struct parsed_partitions *state)/* * Work out start of non-adfs partition. */ - nr_sects = (state->bdev->bd_inode->i_size >>9 ) - start_sect; + nr_sects =get_capacity (state->disk) - start_sect;if (start_sect) {switch (id) {
@@ -540,7 +540,7 @@ int adfspart_check_EESOX(struct parsed_partitions *state)if (i !=0 ) {sector_t size; - size =get_capacity (state->bdev->bd_disk); + size =get_capacity (state->disk);put_partition (state, slot++, start, size - start);strlcat (state->pp_buf,"\n" ,PAGE_SIZE ); }
block/partitions/aix.c +2 -18
@@ -66,22 +66,6 @@ struct pvd {#define LVM_MAXLVS 256 -/** -* last_lba(): return number of last logical block of device -* @bdev: block device -* -* Description: Returns last LBA value on success, 0 on error. -* This is stored (by sd and ide-geometry) in -* the part[0] entry for this disk, and is the number of -* physical sectors available on the disk. -*/ -static u64 last_lba (struct block_device *bdev) -{ -if (!bdev || !bdev->bd_inode) -return 0 ; -return (bdev->bd_inode->i_size >>9 ) -1ULL ; -} -/** * read_lba(): Read bytes from disk, starting at given LBA * @state
@@ -89,7 +73,7 @@ static u64 last_lba(struct block_device *bdev)* @buffer * @count * -* Description: Reads @count bytes from @state->bdev into @buffer. +* Description: Reads @count bytes from @state->disk into @buffer. * Returns number of bytes read on success, 0 on error. */ static size_t read_lba(struct parsed_partitions *state, u64 lba, u8 *buffer,
@@ -97,7 +81,7 @@ static size_t read_lba(struct parsed_partitions *state, u64 lba, u8 *buffer, {size_t totalreadcount =0 ; -if (!buffer || lba + count /512 >last_lba (state->bdev)) +if (!buffer || lba + count /512 >get_capacity (state->disk) -1ULL )return 0 ;while (count) {
block/partitions/amiga.c +3 -4
@@ -34,7 +34,6 @@ int amiga_partition(struct parsed_partitions *state)int start_sect, nr_sects, blk, part, res =0 ;int blksize =1 ;/* Multiplier for disk block size */ int slot =1 ; -char b[BDEVNAME_SIZE ];for (blk =0 ; ; blk++,put_dev_sector (sect)) {if (blk ==RDB_ALLOCATION_LIMIT )
@@ -42,7 +41,7 @@ int amiga_partition(struct parsed_partitions *state) data =read_part_sector (state, blk, §);if (!data) {pr_err ("Dev %s: unable to read RDB block %d\n" , -bdevname (state->bdev, b), blk); + state->disk->disk_name, blk); res =-1 ; goto rdb_done; }
@@ -64,7 +63,7 @@ int amiga_partition(struct parsed_partitions *state) }pr_err ("Dev %s: RDB in block %d has bad checksum\n" , -bdevname (state->bdev, b), blk); + state->disk->disk_name, blk); }/* blksize is blocks per 512 byte standard block */
@@ -84,7 +83,7 @@ int amiga_partition(struct parsed_partitions *state) data =read_part_sector (state, blk, §);if (!data) {pr_err ("Dev %s: unable to read partition block %d\n" , -bdevname (state->bdev, b), blk); + state->disk->disk_name, blk); res =-1 ; goto rdb_done; }
block/partitions/atari.c +2 -2
@@ -47,7 +47,7 @@ int atari_partition(struct parsed_partitions *state)* ATARI partition scheme supports 512 lba only. If this is not * the case, bail early to avoid miscalculating hd_size. */ -if (bdev_logical_block_size (state->bdev) !=512 ) +if (queue_logical_block_size (state->disk->queue) !=512 )return 0 ; rs =read_part_sector (state,0 , §);
@@ -55,7 +55,7 @@ int atari_partition(struct parsed_partitions *state)return -1 ;/* Verify this is an Atari rootsector: */ - hd_size = state->bdev->bd_inode->i_size >>9 ; + hd_size =get_capacity (state->disk); if (!VALID_PARTITION(&rs->part[0], hd_size) && !VALID_PARTITION(&rs->part[1], hd_size) && !VALID_PARTITION(&rs->part[2], hd_size) &&
block/partitions/check.h +1 -1
@@ -9,7 +9,7 @@* description. */ struct parsed_partitions { -struct block_device *bdev; +struct gendisk *disk;char name[BDEVNAME_SIZE ];struct {sector_t from;
block/partitions/cmdline.c +2 -4
@@ -380,7 +380,6 @@ static void cmdline_parts_verifier(int slot, struct parsed_partitions *state)int cmdline_partition (struct parsed_partitions *state) {sector_t disk_size; -char bdev[BDEVNAME_SIZE ];struct cmdline_parts *parts;if (cmdline) {
@@ -397,12 +396,11 @@ int cmdline_partition(struct parsed_partitions *state)if (!bdev_parts)return 0 ; -bdevname (state->bdev, bdev); - parts =cmdline_parts_find (bdev_parts, bdev); + parts =cmdline_parts_find (bdev_parts, state->disk->disk_name);if (!parts)return 0 ; - disk_size =get_capacity (state->bdev->bd_disk) <<9 ; + disk_size =get_capacity (state->disk) <<9 ;cmdline_parts_set (parts, disk_size, state);cmdline_parts_verifier (1 , state);
block/partitions/core.c +3 -3
@@ -135,7 +135,7 @@ static struct parsed_partitions *check_partition(struct gendisk *hd) } state->pp_buf[0 ] ='\0' ; - state->bdev = hd->part0; + state->disk = hd;snprintf (state->name,BDEVNAME_SIZE ,"%s" , hd->disk_name);snprintf (state->pp_buf,PAGE_SIZE ," %s:" , state->name);if (isdigit (state->name[strlen (state->name)-1 ]))
@@ -717,10 +717,10 @@ EXPORT_SYMBOL_GPL(bdev_disk_changed);void *read_part_sector (struct parsed_partitions *state,sector_t n,Sector *p) { -struct address_space *mapping = state->bdev->bd_inode->i_mapping; +struct address_space *mapping = state->disk->part0->bd_inode->i_mapping;struct page *page; -if (n >=get_capacity (state->bdev->bd_disk)) { +if (n >=get_capacity (state->disk)) { state->access_beyond_eod = true;return NULL ; }
block/partitions/efi.c +17 -19
@@ -124,19 +124,17 @@ efi_crc32(const void *buf, unsigned long len)/** * last_lba(): return number of last logical block of device -* @bdev: block device +* @disk: block device * * Description: Returns last LBA value on success, 0 on error. * This is stored (by sd and ide-geometry) in * the part[0] entry for this disk, and is the number of * physical sectors available on the disk. */ -static u64 last_lba (struct block_device *bdev) +static u64 last_lba (struct gendisk *disk) { -if (!bdev || !bdev->bd_inode) -return 0 ; -return div_u64 (bdev->bd_inode->i_size, -bdev_logical_block_size (bdev)) -1ULL ; +return div_u64 (disk->part0->bd_inode->i_size, +queue_logical_block_size (disk->queue)) -1ULL ; }static inline int pmbr_part_valid (gpt_mbr_record *part)
@@ -231,17 +229,17 @@ static int is_pmbr_valid(legacy_mbr *mbr, sector_t total_sectors)* @buffer: destination buffer * @count: bytes to read * -* Description: Reads @count bytes from @state->bdev into @buffer. +* Description: Reads @count bytes from @state->disk into @buffer. * Returns number of bytes read on success, 0 on error. */ static size_t read_lba (struct parsed_partitions *state,u64 lba,u8 *buffer,size_t count) {size_t totalreadcount =0 ; -struct block_device *bdev = state->bdev; -sector_t n = lba * (bdev_logical_block_size (bdev) /512 ); +sector_t n = lba * + (queue_logical_block_size (state->disk->queue) /512 ); -if (!buffer || lba >last_lba (bdev)) +if (!buffer || lba >last_lba (state->disk))return 0 ;while (count) {
@@ -302,14 +300,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,* @lba: the Logical Block Address of the partition table * * Description: returns GPT header on success, NULL on error. Allocates -* and fills a GPT header starting at @ from @state->bdev. +* and fills a GPT header starting at @ from @state->disk. * Note: remember to free gpt when finished with it. */ static gpt_header *alloc_read_gpt_header (struct parsed_partitions *state,u64 lba) {gpt_header *gpt; -unsigned ssz =bdev_logical_block_size (state->bdev); +unsigned ssz =queue_logical_block_size (state->disk->queue); gpt =kmalloc (ssz,GFP_KERNEL );if (!gpt)
@@ -356,10 +354,10 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,/* Check the GUID Partition Table header size is too big */ if (le32_to_cpu ((*gpt)->header_size) > -bdev_logical_block_size (state->bdev)) { +queue_logical_block_size (state->disk->queue)) {pr_debug ("GUID Partition Table Header size is too large: %u > %u\n" ,le32_to_cpu ((*gpt)->header_size), -bdev_logical_block_size (state->bdev)); +queue_logical_block_size (state->disk->queue)); goto fail; }
@@ -395,7 +393,7 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,/* Check the first_usable_lba and last_usable_lba are * within the disk. */ - lastlba =last_lba (state->bdev); + lastlba =last_lba (state->disk);if (le64_to_cpu ((*gpt)->first_usable_lba) > lastlba) { pr_debug("GPT: first_usable_lba incorrect: %lld > %lld\n", (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba),
@@ -587,13 +585,13 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,gpt_header *pgpt =NULL , *agpt =NULL ;gpt_entry *pptes =NULL , *aptes =NULL ;legacy_mbr *legacymbr; -sector_t total_sectors =i_size_read (state->bdev->bd_inode) >>9 ; +sector_t total_sectors =get_capacity (state->disk);u64 lastlba;if (!ptes)return 0 ; - lastlba =last_lba (state->bdev); + lastlba =last_lba (state->disk);if (!force_gpt) {/* This will be added to the EFI Spec. per Intel after v1.02. */ legacymbr =kzalloc (sizeof (*legacymbr),GFP_KERNEL );
@@ -705,7 +703,7 @@ int efi_partition(struct parsed_partitions *state)gpt_header *gpt =NULL ;gpt_entry *ptes =NULL ;u32 i; -unsigned ssz =bdev_logical_block_size (state->bdev) /512 ; +unsigned ssz =queue_logical_block_size (state->disk->queue) /512 ;if (!find_valid_gpt (state, &gpt, &ptes) || !gpt || !ptes) {kfree (gpt);
@@ -722,7 +720,7 @@ int efi_partition(struct parsed_partitions *state)u64 size =le64_to_cpu (ptes[i].ending_lba) -le64_to_cpu (ptes[i].starting_lba) +1ULL ; -if (!is_pte_valid (&ptes[i],last_lba (state->bdev))) +if (!is_pte_valid (&ptes[i],last_lba (state->disk)))continue ;put_partition (state, i+1 , start * ssz, size * ssz);
block/partitions/ibm.c +2 -2
@@ -290,8 +290,8 @@ static int find_cms1_partitions(struct parsed_partitions *state,int ibm_partition (struct parsed_partitions *state) {int (*fn)(struct gendisk *disk,dasd_information2_t *info); -struct block_device *bdev = state->bdev; -struct gendisk *disk = bdev->bd_disk; +struct gendisk *disk = state->disk; +struct block_device *bdev = disk->part0;int blocksize, res;loff_t i_size, offset, size;dasd_information2_t *info;
block/partitions/ldm.c +9 -9
@@ -304,7 +304,7 @@ static bool ldm_validate_privheads(struct parsed_partitions *state, } } - num_sects = state->bdev->bd_inode->i_size >>9 ; + num_sects =get_capacity (state->disk);if ((ph[0 ]->config_start > num_sects) || ((ph[0 ]->config_start + ph[0 ]->config_size) > num_sects)) {
@@ -339,11 +339,11 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,/** * ldm_validate_tocblocks - Validate the table of contents and its backups * @state: Partition check state including device holding the LDM Database -* @base: Offset, into @state->bdev, of the database +* @base: Offset, into @state->disk, of the database * @ldb: Cache of the database structures * * Find and compare the four tables of contents of the LDM Database stored on -* @state->bdev and return the parsed information into @toc1. +* @state->disk and return the parsed information into @toc1. * * The offsets and sizes of the configs are range-checked against a privhead. *
@@ -486,8 +486,8 @@ static bool ldm_validate_vmdb(struct parsed_partitions *state,* only likely to happen if the underlying device is strange. If that IS * the case we should return zero to let someone else try. * -* Return: 'true' @state->bdev is a dynamic disk -* 'false' @state->bdev is not a dynamic disk, or an error occurred +* Return: 'true' @state->disk is a dynamic disk +* 'false' @state->disk is not a dynamic disk, or an error occurred */ static bool ldm_validate_partition_table (struct parsed_partitions *state) {
@@ -1340,7 +1340,7 @@ static bool ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb)/** * ldm_get_vblks - Read the on-disk database of VBLKs into memory * @state: Partition check state including device holding the LDM Database -* @base: Offset, into @state->bdev, of the database +* @base: Offset, into @state->disk, of the database * @ldb: Cache of the database structures * * To use the information from the VBLKs, they need to be read from the disk,
@@ -1432,10 +1432,10 @@ static void ldm_free_vblks (struct list_head *lh)* example, if the device is hda, we would have: hda1: LDM database, hda2, hda3, * and so on: the actual data containing partitions. * -* Return: 1 Success, @state->bdev is a dynamic disk and we handled it -* 0 Success, @state->bdev is not a dynamic disk +* Return: 1 Success, @state->disk is a dynamic disk and we handled it +* 0 Success, @state->disk is not a dynamic disk * -1 An error occurred before enough information had been read -* Or @state->bdev is a dynamic disk, but it may be corrupted +* Or @state->disk is a dynamic disk, but it may be corrupted */ int ldm_partition (struct parsed_partitions *state) {
block/partitions/mac.c +1 -1
@@ -133,7 +133,7 @@ int mac_partition(struct parsed_partitions *state) }#ifdef CONFIG_PPC_PMAC if (found_root_goodness) -note_bootable_part (state->bdev->bd_dev, found_root, +note_bootable_part (state->disk->part0->bd_dev, found_root, found_root_goodness);#endif
block/partitions/msdos.c +4 -2
@@ -135,11 +135,12 @@ static void parse_extended(struct parsed_partitions *state,Sector sect;unsigned char *data;sector_t this_sector, this_size; -sector_t sector_size =bdev_logical_block_size (state->bdev) /512 ; +sector_t sector_size;int loopct =0 ;/* number of links followed without finding a data partition */ int i; + sector_size =queue_logical_block_size (state->disk->queue) /512 ; this_sector = first_sector; this_size = first_size;
@@ -579,7 +580,7 @@ static struct {int msdos_partition (struct parsed_partitions *state) { -sector_t sector_size =bdev_logical_block_size (state->bdev) /512 ; +sector_t sector_size;Sector sect;unsigned char *data;struct msdos_partition *p;
@@ -587,6 +588,7 @@ int msdos_partition(struct parsed_partitions *state)int slot;u32 disksig; + sector_size =queue_logical_block_size (state->disk->queue) /512 ; data =read_part_sector (state,0 , §);if (!data)return -1 ;
block/partitions/sgi.c +2 -3
@@ -43,7 +43,6 @@ int sgi_partition(struct parsed_partitions *state)Sector sect;struct sgi_disklabel *label;struct sgi_partition *p; -char b[BDEVNAME_SIZE ]; label =read_part_sector (state,0 , §);if (!label)
@@ -52,7 +51,7 @@ int sgi_partition(struct parsed_partitions *state) magic = label->magic_mushroom;if (be32_to_cpu (magic) !=SGI_LABEL_MAGIC ) {/*printk("Dev %s SGI disklabel: bad magic %08x\n", -bdevname(bdev, b), be32_to_cpu(magic));*/ +state->disk->disk_name, be32_to_cpu(magic));*/ put_dev_sector (sect);return 0 ; }
@@ -63,7 +62,7 @@ int sgi_partition(struct parsed_partitions *state) }if (csum) {printk (KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n" , -bdevname (state->bdev, b)); + state->disk->disk_name);put_dev_sector (sect);return 0 ; }
block/partitions/sun.c +2 -3
@@ -65,7 +65,6 @@ int sun_partition(struct parsed_partitions *state) } * label;struct sun_partition *p;unsigned long spc; -char b[BDEVNAME_SIZE ];int use_vtoc;int nparts;
@@ -76,7 +75,7 @@ int sun_partition(struct parsed_partitions *state) p = label->partitions;if (be16_to_cpu (label->magic) !=SUN_LABEL_MAGIC ) {/* printk(KERN_INFO "Dev %s Sun disklabel: bad magic %04x\n", -bdevname(bdev, b), be16_to_cpu(label->magic)); */ +state->disk->disk_name, be16_to_cpu(label->magic)); */ put_dev_sector (sect);return 0 ; }
@@ -86,7 +85,7 @@ int sun_partition(struct parsed_partitions *state) csum ^= *ush--;if (csum) {printk ("Dev %s Sun disklabel: Csum bad, label corrupted\n" , -bdevname (state->bdev, b)); + state->disk->disk_name);put_dev_sector (sect);return 0 ; }
Signature · 1 line
2.30.2
Re: [PATCH 1/4] block: store a gendisk in struct parsed_partitions
Am 10.08.21 um 17:45 schrieb Christoph Hellwig:
Quoted 6 lines
Partition scanning only happens on the whole device, so pass a struct gendisk instead of the whole device
block_deviceto the scanners. This allows to simplify printing the device name in various places as the disk name is available indisk->name.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 10 lines
--- block/partitions/acorn.c | 4 ++-- block/partitions/aix.c | 20 ++------------------ block/partitions/amiga.c | 7 +++---- block/partitions/atari.c | 4 ++-- block/partitions/check.h | 2 +- block/partitions/cmdline.c | 6 ++---- block/partitions/core.c | 6 +++--- block/partitions/efi.c | 36 +++++++++++++++++------------------- block/partitions/ibm.c | 4 ++--
for the DASD part:
Looks good.
PATCH 2/4 block: pass a gendisk to bdev_add_partition
In reply to Christoph Hellwigbdev_add_partition can only operate on the whole device. Make that clear by passing a gendisk instead of a block_device.
--- block/blk.h | 4 ++-- block/ioctl.c | 3 ++- block/partitions/core.c | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-)
block/blk.h +2 -2
@@ -347,8 +347,8 @@ void blk_free_ext_minor(unsigned int minor);#define ADDPART_FLAG_NONE 0#define ADDPART_FLAG_RAID 1#define ADDPART_FLAG_WHOLEDISK 2 -int bdev_add_partition (struct block_device *bdev,int partno, -sector_t start,sector_t length); +int bdev_add_partition (struct gendisk *disk,int partno,sector_t start, +sector_t length);int bdev_del_partition (struct block_device *bdev,int partno);int bdev_resize_partition (struct block_device *bdev,int partno,sector_t start,sector_t length);
block/ioctl.c +2 -1
@@ -16,6 +16,7 @@static int blkpg_do_ioctl (struct block_device *bdev,struct blkpg_partition __user *upart,int op) { +struct gendisk *disk = bdev->bd_disk;struct blkpg_partition p;long long start, length;
@@ -40,7 +41,7 @@ static int blkpg_do_ioctl(struct block_device *bdev,/* check if partition is aligned to blocksize */ if (p.start & (bdev_logical_block_size (bdev) -1 ))return -EINVAL ; -return bdev_add_partition (bdev, p.pno, start, length); +return bdev_add_partition (disk, p.pno, start, length);case BLKPG_RESIZE_PARTITION :return bdev_resize_partition (bdev, p.pno, start, length);default :
block/partitions/core.c +2 -3
@@ -451,11 +451,10 @@ static bool partition_overlaps(struct gendisk *disk, sector_t start,return overlap; } -int bdev_add_partition (struct block_device *bdev,int partno, -sector_t start,sector_t length) +int bdev_add_partition (struct gendisk *disk,int partno,sector_t start, +sector_t length) {struct block_device *part; -struct gendisk *disk = bdev->bd_disk;int ret;mutex_lock (&disk->open_mutex);
Signature · 1 line
2.30.2
PATCH 3/4 block: pass a gendisk to bdev_del_partition
In reply to Christoph Hellwigbdev_del_partition can only operate on the whole device. Make that clear by passing a gendisk instead of a block_device.
--- block/blk.h | 2 +- block/ioctl.c | 2 +- block/partitions/core.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-)
block/blk.h +1 -1
@@ -349,7 +349,7 @@ void blk_free_ext_minor(unsigned int minor);#define ADDPART_FLAG_WHOLEDISK 2int bdev_add_partition (struct gendisk *disk,int partno,sector_t start,sector_t length); -int bdev_del_partition (struct block_device *bdev,int partno); +int bdev_del_partition (struct gendisk *disk,int partno);int bdev_resize_partition (struct block_device *bdev,int partno,sector_t start,sector_t length);
block/ioctl.c +1 -1
@@ -31,7 +31,7 @@ static int blkpg_do_ioctl(struct block_device *bdev,return -EINVAL ;if (op ==BLKPG_DEL_PARTITION ) -return bdev_del_partition (bdev, p.pno); +return bdev_del_partition (disk, p.pno); start = p.start >>SECTOR_SHIFT ; length = p.length >>SECTOR_SHIFT ;
block/partitions/core.c +4 -4
@@ -476,13 +476,13 @@ int bdev_add_partition(struct gendisk *disk, int partno, sector_t start,return ret; } -int bdev_del_partition (struct block_device *bdev,int partno) +int bdev_del_partition (struct gendisk *disk,int partno) {struct block_device *part =NULL ;int ret = -ENXIO ; -mutex_lock (&bdev->bd_disk->open_mutex); - part =xa_load (&bdev->bd_disk->part_tbl, partno); +mutex_lock (&disk->open_mutex); + part =xa_load (&disk->part_tbl, partno);if (!part) goto out_unlock;
@@ -493,7 +493,7 @@ int bdev_del_partition(struct block_device *bdev, int partno)delete_partition (part); ret =0 ; out_unlock: -mutex_unlock (&bdev->bd_disk->open_mutex); +mutex_unlock (&disk->open_mutex);return ret; }
Signature · 1 line
2.30.2
PATCH 4/4 block: pass a gendisk to bdev_resize_partition
In reply to Christoph Hellwigbdev_resize_partition can only operate on the whole device. Make that clear by passing a gendisk instead of a block_device.
--- block/blk.h | 4 ++-- block/ioctl.c | 2 +- block/partitions/core.c | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-)
block/blk.h +2 -2
@@ -350,8 +350,8 @@ void blk_free_ext_minor(unsigned int minor);int bdev_add_partition (struct gendisk *disk,int partno,sector_t start,sector_t length);int bdev_del_partition (struct gendisk *disk,int partno); -int bdev_resize_partition (struct block_device *bdev,int partno, -sector_t start,sector_t length); +int bdev_resize_partition (struct gendisk *disk,int partno,sector_t start, +sector_t length); int bio_add_hw_page(struct request_queue *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset,
block/ioctl.c +1 -1
@@ -43,7 +43,7 @@ static int blkpg_do_ioctl(struct block_device *bdev,return -EINVAL ;return bdev_add_partition (disk, p.pno, start, length);case BLKPG_RESIZE_PARTITION : -return bdev_resize_partition (bdev, p.pno, start, length); +return bdev_resize_partition (disk, p.pno, start, length);default :return -EINVAL ; }
block/partitions/core.c +6 -6
@@ -497,14 +497,14 @@ int bdev_del_partition(struct gendisk *disk, int partno)return ret; } -int bdev_resize_partition (struct block_device *bdev,int partno, -sector_t start,sector_t length) +int bdev_resize_partition (struct gendisk *disk,int partno,sector_t start, +sector_t length) {struct block_device *part =NULL ;int ret = -ENXIO ; -mutex_lock (&bdev->bd_disk->open_mutex); - part =xa_load (&bdev->bd_disk->part_tbl, partno); +mutex_lock (&disk->open_mutex); + part =xa_load (&disk->part_tbl, partno);if (!part) goto out_unlock;
@@ -513,14 +513,14 @@ int bdev_resize_partition(struct block_device *bdev, int partno, goto out_unlock; ret = -EBUSY ; -if (partition_overlaps (bdev->bd_disk, start, length, partno)) +if (partition_overlaps (disk, start, length, partno)) goto out_unlock;bdev_set_nr_sectors (part, length); ret =0 ; out_unlock: -mutex_unlock (&bdev->bd_disk->open_mutex); +mutex_unlock (&disk->open_mutex);return ret; }
Signature · 1 line
2.30.2
Quoted 4 lines · Christoph Hellwig
Hi Jens,
this series passes the gendisk instead of the
block_devicewhen operating on the whole device in the partition code.
Applied, thanks.
Signature · 1 line
Jens Axboe