cleanup the partitioning code
Subsystems (13)
Hi Jens,
this series cleans up the partitioning code.
PATCH 1/21 block: remove the blk_lookup_devt export
This function is only used by init/do_mounts.c, which can't be modular.
--- block/genhd.c | 1 - 1 file changed, 1 deletion(-)
block/genhd.c +0 -1
@@ -1463,7 +1463,6 @@ dev_t blk_lookup_devt(const char *name, int partno)class_dev_iter_exit (&iter);return devt; } -EXPORT_SYMBOL (blk_lookup_devt);struct gendisk *__alloc_disk_node (int minors,int node_id) {
Signature · 1 line
2.24.1
PATCH 2/21 block: remove __bdevname
In reply to Christoph HellwigThere is no good reason for __bdevname to exist. Just open code printing the string in the callers. For three of them the format string can be trivially merged into existing printk statements, and in init/do_mounts.c we can at least do the scnprintf once at the start of the function, and unconditional of CONFIG_BLOCK to make the output for tiny configfs a little more helpful.
--- block/partition-generic.c | 14 -------------- drivers/md/md.c | 4 ++-- fs/ext4/super.c | 6 +++--- fs/reiserfs/journal.c | 5 ++--- include/linux/fs.h | 1 - init/do_mounts.c | 12 ++---------- 6 files changed, 9 insertions(+), 33 deletions(-)
block/partition-generic.c +0 -14
@@ -57,20 +57,6 @@ const char *bio_devname(struct bio *bio, char *buf) }EXPORT_SYMBOL (bio_devname); -/* -* There's very little reason to use this, you should really -* have a struct block_device just about everywhere and use -* bdevname() instead. -*/ -const char *__bdevname (dev_t dev,char *buffer) -{ -scnprintf (buffer,BDEVNAME_SIZE ,"unknown-block(%u,%u)" , -MAJOR (dev),MINOR (dev)); -return buffer; -} - -EXPORT_SYMBOL (__bdevname); -static ssize_t part_partition_show (struct device *dev,struct device_attribute *attr,char *buf) {
drivers/md/md.c +2 -2
@@ -2491,12 +2491,12 @@ static int lock_rdev(struct md_rdev *rdev, dev_t dev, int shared) {int err =0 ;struct block_device *bdev; -char b[BDEVNAME_SIZE ]; bdev =blkdev_get_by_dev (dev,FMODE_READ |FMODE_WRITE |FMODE_EXCL , shared ? (struct md_rdev *)lock_rdev : rdev);if (IS_ERR (bdev)) { -pr_warn ("md: could not open %s.\n" ,__bdevname (dev, b)); +pr_warn ("md: could not open device unknown-block(%u,%u).\n" , +MAJOR (dev),MINOR (dev));return PTR_ERR (bdev); } rdev->bdev = bdev;
fs/ext4/super.c +3 -3
@@ -927,7 +927,6 @@ void ext4_update_dynamic_rev(struct super_block *sb)static struct block_device *ext4_blkdev_get (dev_t dev,struct super_block *sb) {struct block_device *bdev; -char b[BDEVNAME_SIZE ]; bdev =blkdev_get_by_dev (dev,FMODE_READ |FMODE_WRITE |FMODE_EXCL , sb);if (IS_ERR (bdev))
@@ -935,8 +934,9 @@ static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb)return bdev; fail: -ext4_msg (sb,KERN_ERR ,"failed to open journal device %s: %ld" , -__bdevname (dev, b),PTR_ERR (bdev)); +ext4_msg (sb,KERN_ERR , +"failed to open journal device unknown-block(%u,%u) %ld" , +MAJOR (dev),MINOR (dev),PTR_ERR (bdev));return NULL ; }
fs/reiserfs/journal.c +2 -3
@@ -2599,7 +2599,6 @@ static int journal_init_dev(struct super_block *super,int result;dev_t jdev;fmode_t blkdev_mode =FMODE_READ |FMODE_WRITE |FMODE_EXCL ; -char b[BDEVNAME_SIZE ]; result =0 ;
@@ -2621,8 +2620,8 @@ static int journal_init_dev(struct super_block *super, result =PTR_ERR (journal->j_dev_bd); journal->j_dev_bd =NULL ;reiserfs_warning (super,"sh-458" , -"cannot init journal device '%s': %i" , -__bdevname (jdev, b), result); +"cannot init journal device unknown-block(%u,%u): %i" , +MAJOR (jdev),MINOR (jdev), result);return result; }else if (jdev != super->s_dev)set_blocksize (journal->j_dev_bd, super->s_blocksize);
include/linux/fs.h +0 -1
@@ -2699,7 +2699,6 @@ static inline void unregister_chrdev(unsigned int major, const char *name)#ifdef CONFIG_BLOCK #define BLKDEV_MAJOR_MAX 512 -extern const char *__bdevname (dev_t ,char *buffer);extern const char *bdevname (struct block_device *bdev,char *buffer);extern struct block_device *lookup_bdev (const char *);extern void blkdev_show (struct seq_file *,off_t );
init/do_mounts.c +2 -10
@@ -429,12 +429,10 @@ void __init mount_block_root(char *name, int flags)struct page *page =alloc_page (GFP_KERNEL );char *fs_names =page_address (page);char *p; -#ifdef CONFIG_BLOCK char b[BDEVNAME_SIZE ]; -#else -const char *b = name; -#endif +scnprintf (b,BDEVNAME_SIZE ,"unknown-block(%u,%u)" , +MAJOR (ROOT_DEV ),MINOR (ROOT_DEV ));get_fs_names (fs_names); retry:for (p = fs_names; *p; p +=strlen (p)+1 ) {
@@ -451,9 +449,6 @@ void __init mount_block_root(char *name, int flags)* and bad superblock on root device. * and give them a list of the available devices */ -#ifdef CONFIG_BLOCK -__bdevname (ROOT_DEV , b); -#endif printk ("VFS: Cannot open root device \"%s\" or %s: error %d\n" , root_device_name, b, err);printk ("Please append a correct \"root=\" boot option; here are the available partitions:\n" );
@@ -476,9 +471,6 @@ void __init mount_block_root(char *name, int flags)for (p = fs_names; *p; p +=strlen (p)+1 )printk (" %s" , p);printk ("\n" ); -#ifdef CONFIG_BLOCK -__bdevname (ROOT_DEV , b); -#endif panic ("VFS: Unable to mount root fs on %s" , b); out:put_page (page);
Signature · 1 line
2.24.1
Re: [PATCH 02/21] block: remove __bdevname
Quoted 8 lines · Christoph Hellwig
There is no good reason for
__bdevnameto exist. Just open code printing the string in the callers. For three of them the format string can be trivially merged into existing printk statements, and ininit/do_mounts.cwe can at least do the scnprintf once at the start of the function, and unconditional ofCONFIG_BLOCKto make the output for tiny configfs a little more helpful.Signed-off-by Christoph Hellwig <[email protected]>
PATCH 3/21 block: move disk_name and related helpers out of partition-generic.c
In reply to Christoph HellwigThes functions aren't really related to partition support, so move them to a more suitable place.
--- block/bio.c | 6 ++++++ block/genhd.c | 22 ++++++++++++++++++++++ block/partition-generic.c | 32 -------------------------------- 3 files changed, 28 insertions(+), 32 deletions(-)
block/bio.c +6 -0
@@ -679,6 +679,12 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs) }EXPORT_SYMBOL (bio_clone_fast); +const char *bio_devname (struct bio *bio,char *buf) +{ +return disk_name (bio->bi_disk, bio->bi_partno, buf); +} +EXPORT_SYMBOL (bio_devname); +static inline bool page_is_mergeable (const struct bio_vec *bv,struct page *page,unsigned int len,unsigned int off,bool *same_page)
block/genhd.c +22 -0
@@ -46,6 +46,28 @@ static void disk_add_events(struct gendisk *disk);static void disk_del_events (struct gendisk *disk);static void disk_release_events (struct gendisk *disk); +/* +* Format the devicename of the indicated disk into the supplied buffer and +* return a pointer to that same buffer for convenience. +*/ +char *disk_name (struct gendisk *hd,int partno,char *buf) +{ +if (!partno) +snprintf (buf,BDEVNAME_SIZE ,"%s" , hd->disk_name); +else if (isdigit (hd->disk_name[strlen (hd->disk_name)-1 ])) +snprintf (buf,BDEVNAME_SIZE ,"%sp%d" , hd->disk_name, partno); +else +snprintf (buf,BDEVNAME_SIZE ,"%s%d" , hd->disk_name, partno); + +return buf; +} + +const char *bdevname (struct block_device *bdev,char *buf) +{ +return disk_name (bdev->bd_disk, bdev->bd_part->partno, buf); +} +EXPORT_SYMBOL (bdevname); +void part_inc_in_flight (struct request_queue *q,struct hd_struct *part,int rw) {if (queue_is_mq (q))
block/partition-generic.c +0 -32
@@ -25,38 +25,6 @@extern void md_autodetect_dev (dev_t dev);#endif -/* -* disk_name() is used by partition check code and the genhd driver. -* It formats the devicename of the indicated disk into -* the supplied buffer (of size at least 32), and returns -* a pointer to that same buffer (for convenience). -*/ - -char *disk_name (struct gendisk *hd,int partno,char *buf) -{ -if (!partno) -snprintf (buf,BDEVNAME_SIZE ,"%s" , hd->disk_name); -else if (isdigit (hd->disk_name[strlen (hd->disk_name)-1 ])) -snprintf (buf,BDEVNAME_SIZE ,"%sp%d" , hd->disk_name, partno); -else -snprintf (buf,BDEVNAME_SIZE ,"%s%d" , hd->disk_name, partno); - -return buf; -} - -const char *bdevname (struct block_device *bdev,char *buf) -{ -return disk_name (bdev->bd_disk, bdev->bd_part->partno, buf); -} - -EXPORT_SYMBOL (bdevname); - -const char *bio_devname (struct bio *bio,char *buf) -{ -return disk_name (bio->bi_disk, bio->bi_partno, buf); -} -EXPORT_SYMBOL (bio_devname); -static ssize_t part_partition_show (struct device *dev,struct device_attribute *attr,char *buf) {
Signature · 1 line
2.24.1
PATCH 4/21 block: move sysfs methods shared by disks and partitions to genhd.c
In reply to Christoph HellwigMove the sysfs _show methods that are used both on the full disk and partition nodes to genhd.c instead of hiding them in the partitioning code. Also move the declaration for these methods to block/blk.h so that we don't expose them to drivers.
--- block/blk.h | 11 ++++++ block/genhd.c | 80 ++++++++++++++++++++++++++++++++++++++- block/partition-generic.c | 76 +------------------------------------ include/linux/genhd.h | 14 ------- 4 files changed, 91 insertions(+), 90 deletions(-)
block/blk.h +11 -0
@@ -214,6 +214,17 @@ static inline void elevator_exit(struct request_queue *q,struct hd_struct *__disk_get_part (struct gendisk *disk,int partno); +ssize_t part_size_show (struct device *dev,struct device_attribute *attr, +char *buf); +ssize_t part_stat_show (struct device *dev,struct device_attribute *attr, +char *buf); +ssize_t part_inflight_show (struct device *dev,struct device_attribute *attr, +char *buf); +ssize_t part_fail_show (struct device *dev,struct device_attribute *attr, +char *buf); +ssize_t part_fail_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count); +#ifdef CONFIG_FAIL_IO_TIMEOUT int blk_should_fake_timeout (struct request_queue *);ssize_t part_timeout_show (struct device *,struct device_attribute *,char *);
block/genhd.c +79 -1
101 lines not on this page · raw message
block/partition-generic.c +1 -75
94 lines not on this page · raw message
include/linux/genhd.h +0 -14
@@ -657,20 +657,6 @@ extern void blk_register_region(dev_t devt, unsigned long range, void *data);extern void blk_unregister_region (dev_t devt,unsigned long range); -extern ssize_t part_size_show (struct device *dev, -struct device_attribute *attr,char *buf); -extern ssize_t part_stat_show (struct device *dev, -struct device_attribute *attr,char *buf); -extern ssize_t part_inflight_show (struct device *dev, -struct device_attribute *attr,char *buf); -#ifdef CONFIG_FAIL_MAKE_REQUEST -extern ssize_t part_fail_show (struct device *dev, -struct device_attribute *attr,char *buf); -extern ssize_t part_fail_store (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t count); -#endif /* CONFIG_FAIL_MAKE_REQUEST */ -#define alloc_disk_node (minors, node_id) \ ({ \ static struct lock_class_key __key; \
Signature · 1 line
2.24.1
PATCH 5/21 block: remove alloc_part_info and free_part_info
In reply to Christoph HellwigThere isn't any good reason not to simply open code the allocation and freeing of the partition_meta_info structure. Especially as one of the branches in alloc_part_info is entirely dead code.
--- block/partition-generic.c | 6 ++++-- include/linux/genhd.h | 15 +-------------- 2 files changed, 5 insertions(+), 16 deletions(-)
block/partition-generic.c +4 -2
@@ -249,7 +249,9 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, p->policy =get_disk_ro (disk);if (info) { -struct partition_meta_info *pinfo =alloc_part_info (disk); +struct partition_meta_info *pinfo; + + pinfo =kzalloc_node (sizeof (*pinfo),GFP_KERNEL , disk->node_id);if (!pinfo) { err = -ENOMEM ; goto out_free_stats;
@@ -308,7 +310,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,return p; out_free_info: -free_part_info (p); +kfree (p->info); out_free_stats:free_part_stats (p); out_free:
include/linux/genhd.h +1 -14
@@ -418,19 +418,6 @@ void part_dec_in_flight(struct request_queue *q, struct hd_struct *part,void part_inc_in_flight (struct request_queue *q,struct hd_struct *part,int rw); -static inline struct partition_meta_info *alloc_part_info (struct gendisk *disk) -{ -if (disk) -return kzalloc_node (sizeof (struct partition_meta_info ), -GFP_KERNEL , disk->node_id); -return kzalloc (sizeof (struct partition_meta_info ),GFP_KERNEL ); -} - -static inline void free_part_info (struct hd_struct *part) -{ -kfree (part->info); -} -void update_io_ticks (struct hd_struct *part,unsigned long now);/* block/genhd.c */
@@ -706,7 +693,7 @@ static inline void hd_struct_kill(struct hd_struct *part)static inline void hd_free_part (struct hd_struct *part) {free_part_stats (part); -free_part_info (part); +kfree (part->info);percpu_ref_exit (&part->ref); }
Signature · 1 line
2.24.1
PATCH 6/21 scsi: simplify scsi_bios_ptable
In reply to Christoph HellwigUse read_mapping_page and kmemdup instead of the odd read_dev_sector and put_dev_sector helpers from the partitioning code.
--- drivers/scsi/scsicam.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/scsi/scsicam.c +11 -13
@@ -35,19 +35,17 @@ static int setsize(unsigned long capacity, unsigned int *cyls, unsigned int *hds*/ unsigned char *scsi_bios_ptable (struct block_device *dev) { -unsigned char *res =kmalloc (66 ,GFP_KERNEL ); -if (res) { -struct block_device *bdev = dev->bd_contains; -Sector sect; -void *data =read_dev_sector (bdev,0 , §); -if (data) { -memcpy (res, data +0x1be ,66 ); -put_dev_sector (sect); - }else { -kfree (res); - res =NULL ; - } - } +struct address_space *mapping = dev->bd_contains->bd_inode->i_mapping; +unsigned char *res =NULL ; +struct page *page; + + page =read_mapping_page (mapping,0 ,NULL ); +if (IS_ERR (page)) +return NULL ; + +if (!PageError (page)) + res =kmemdup (page_address (page) +0x1be ,66 ,GFP_KERNEL ); +put_page (page);return res; }EXPORT_SYMBOL (scsi_bios_ptable);
Signature · 1 line
2.24.1
PATCH 7/21 scsi: move scsicam_bios_param to the end of scsicam.c
In reply to Christoph HellwigThis avoids the need for a forward declaration and generally keeps the file in the lower level first, high level last order.
--- drivers/scsi/scsicam.c | 120 ++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 61 deletions(-)
drivers/scsi/scsicam.c +59 -61
@@ -21,10 +21,6 @@#include <scsi/scsicam.h> - -static int setsize (unsigned long capacity,unsigned int *cyls,unsigned int *hds, -unsigned int *secs); -/** * scsi_bios_ptable - Read PC partition table out of first sector of device. * @dev: from this device
@@ -50,63 +46,6 @@ unsigned char *scsi_bios_ptable(struct block_device *dev) }EXPORT_SYMBOL (scsi_bios_ptable); -/** -* scsicam_bios_param - Determine geometry of a disk in cylinders/heads/sectors. -* @bdev: which device -* @capacity: size of the disk in sectors -* @ip: return value: ip[0]=heads, ip[1]=sectors, ip[2]=cylinders -* -* Description : determine the BIOS mapping/geometry used for a drive in a -* SCSI-CAM system, storing the results in ip as required -* by the HDIO_GETGEO ioctl(). -* -* Returns : -1 on failure, 0 on success. -*/ - -int scsicam_bios_param (struct block_device *bdev,sector_t capacity,int *ip) -{ -unsigned char *p; -u64 capacity64 = capacity;/* Suppress gcc warning */ -int ret; - - p =scsi_bios_ptable (bdev); -if (!p) -return -1 ; - -/* try to infer mapping from partition table */ - ret =scsi_partsize (p, (unsigned long )capacity, (unsigned int *)ip +2 , - (unsigned int *)ip +0 , (unsigned int *)ip +1 ); -kfree (p); - -if (ret ==-1 && capacity64 < (1ULL <<32 )) { -/* pick some standard mapping with at most 1024 cylinders, -and at most 62 sectors per track - this works up to -7905 MB */ - ret =setsize ((unsigned long )capacity, (unsigned int *)ip +2 , - (unsigned int *)ip +0 , (unsigned int *)ip +1 ); - } - -/* if something went wrong, then apparently we have to return -a geometry with more than 1024 cylinders */ -if (ret || ip[0 ] >255 || ip[1 ] >63 ) { -if ((capacity >>11 ) >65534 ) { - ip[0 ] =255 ; - ip[1 ] =63 ; - }else { - ip[0 ] =64 ; - ip[1 ] =32 ; - } - -if (capacity >65535 *63 *255 ) - ip[2 ] =65535 ; -else - ip[2 ] = (unsigned long )capacity / (ip[0 ] * ip[1 ]); - } - -return 0 ; -} -EXPORT_SYMBOL (scsicam_bios_param); -/** * scsi_partsize - Parse cylinders/heads/sectors from PC partition table * @buf: partition table, see scsi_bios_ptable()
@@ -256,3 +195,62 @@ static int setsize(unsigned long capacity, unsigned int *cyls, unsigned int *hds *hds = (unsigned int ) heads;return (rv); } + +/** +* scsicam_bios_param - Determine geometry of a disk in cylinders/heads/sectors. +* @bdev: which device +* @capacity: size of the disk in sectors +* @ip: return value: ip[0]=heads, ip[1]=sectors, ip[2]=cylinders +* +* Description : determine the BIOS mapping/geometry used for a drive in a +* SCSI-CAM system, storing the results in ip as required +* by the HDIO_GETGEO ioctl(). +* +* Returns : -1 on failure, 0 on success. +*/ +int scsicam_bios_param (struct block_device *bdev,sector_t capacity,int *ip) +{ +unsigned char *p; +u64 capacity64 = capacity;/* Suppress gcc warning */ +int ret; + + p =scsi_bios_ptable (bdev); +if (!p) +return -1 ; + +/* try to infer mapping from partition table */ + ret =scsi_partsize (p, (unsigned long )capacity, (unsigned int *)ip +2 , + (unsigned int *)ip +0 , (unsigned int *)ip +1 ); +kfree (p); + +if (ret ==-1 && capacity64 < (1ULL <<32 )) { +/* +* Pick some standard mapping with at most 1024 cylinders, and +* at most 62 sectors per track - this works up to 7905 MB. +*/ + ret =setsize ((unsigned long )capacity, (unsigned int *)ip +2 , + (unsigned int *)ip +0 , (unsigned int *)ip +1 ); + } + +/* +* If something went wrong, then apparently we have to return a geometry +* with more than 1024 cylinders. +*/ +if (ret || ip[0 ] >255 || ip[1 ] >63 ) { +if ((capacity >>11 ) >65534 ) { + ip[0 ] =255 ; + ip[1 ] =63 ; + }else { + ip[0 ] =64 ; + ip[1 ] =32 ; + } + +if (capacity >65535 *63 *255 ) + ip[2 ] =65535 ; +else + ip[2 ] = (unsigned long )capacity / (ip[0 ] * ip[1 ]); + } + +return 0 ; +} +EXPORT_SYMBOL (scsicam_bios_param);
Signature · 1 line
2.24.1
PATCH 8/21 scsi: simplify scsi_partsize
In reply to Christoph HellwigCall scsi_bios_ptable from scsi_partsize instead of requiring boilerplate code in the callers. Also switch the calling convention to match that of the ->bios_param instances calling this function, and use true/false for the return value instead of the weird -1 convention.
--- Documentation/scsi/scsi_mid_low_api.txt | 21 --------- drivers/scsi/aic7xxx/aic79xx_osm.c | 13 ++---- drivers/scsi/aic7xxx/aic7xxx_osm.c | 13 ++---- drivers/scsi/arcmsr/arcmsr_hba.c | 13 ++---- drivers/scsi/megaraid.c | 13 +----- drivers/scsi/scsicam.c | 61 +++++++++++++------------ include/scsi/scsicam.h | 7 ++- 7 files changed, 46 insertions(+), 95 deletions(-)
Documentation/scsi/scsi_mid_low_api.txt +0 -21
@@ -299,7 +299,6 @@ Summary: scsi_host_alloc - return a new scsi_host instance whose refcount==1 scsi_host_get - increments Scsi_Host instance's refcount scsi_host_put - decrements Scsi_Host instance's refcount (free if 0) - scsi_partsize - parse partition table into cylinders, heads + sectors scsi_register - create and register a scsi host adapter instance. scsi_remove_device - detach and remove a SCSI device scsi_remove_host - detach and remove all SCSI devices owned by host
@@ -472,26 +471,6 @@ void scsi_host_get(struct Scsi_Host *shost) void scsi_host_put(struct Scsi_Host *shost) -/** - * scsi_partsize - parse partition table into cylinders, heads + sectors - * @buf: pointer to partition table - * @capacity: size of (total) disk in 512 byte sectors - * @cyls: outputs number of cylinders calculated via this pointer - * @hds: outputs number of heads calculated via this pointer - * @secs: outputs number of sectors calculated via this pointer - * - * Returns 0 on success, -1 on failure - * - * Might block: no - * - * Notes: Caller owns memory returned (free with kfree() ) - * - * Defined in: drivers/scsi/scsicam.c - **/ -int scsi_partsize(unsigned char *buf, unsigned long capacity, - unsigned int *cyls, unsigned int *hds, unsigned int *secs) - - /** * scsi_register - create and register a scsi host adapter instance. * @sht: pointer to scsi host template
drivers/scsi/aic7xxx/aic79xx_osm.c +3 -10
@@ -723,24 +723,17 @@ static int ahd_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[]) { - uint8_t *bh; int heads;int sectors;int cylinders; -int ret;int extended;struct ahd_softc *ahd; ahd = *((struct ahd_softc **)sdev->host->hostdata); - bh =scsi_bios_ptable (bdev); -if (bh) { - ret =scsi_partsize (bh, capacity, - &geom[2 ], &geom[0 ], &geom[1 ]); -kfree (bh); -if (ret !=-1 ) -return (ret); - } +if (scsi_partsize (bdev, capacity, geom)) +return 0 ; + heads =64 ; sectors =32 ; cylinders =aic_sector_div (capacity, heads, sectors);
drivers/scsi/aic7xxx/aic7xxx_osm.c +3 -10
@@ -695,11 +695,9 @@ static int ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[]) { - uint8_t *bh; int heads;int sectors;int cylinders; -int ret;int extended;struct ahc_softc *ahc;u_int channel;
@@ -707,14 +705,9 @@ ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, ahc = *((struct ahc_softc **)sdev->host->hostdata); channel =sdev_channel (sdev); - bh =scsi_bios_ptable (bdev); -if (bh) { - ret =scsi_partsize (bh, capacity, - &geom[2 ], &geom[0 ], &geom[1 ]); -kfree (bh); -if (ret !=-1 ) -return (ret); - } +if (scsi_partsize (bdev, capacity, geom)) +return 0 ; + heads =64 ; sectors =32 ; cylinders =aic_sector_div (capacity, heads, sectors);
drivers/scsi/arcmsr/arcmsr_hba.c +4 -9
@@ -353,16 +353,11 @@ static irqreturn_t arcmsr_do_interrupt(int irq, void *dev_id)static int arcmsr_bios_param (struct scsi_device *sdev,struct block_device *bdev,sector_t capacity,int *geom) { -int ret, heads, sectors, cylinders, total_capacity; -unsigned char *buffer;/* return copy of block device's partition table */ +int heads, sectors, cylinders, total_capacity; + +if (scsi_partsize (bdev, capacity, geom)) +return 0 ; - buffer =scsi_bios_ptable (bdev); -if (buffer) { - ret =scsi_partsize (buffer, capacity, &geom[2 ], &geom[0 ], &geom[1 ]); -kfree (buffer); -if (ret !=-1 ) -return ret; - } total_capacity = capacity; heads =64 ; sectors =32 ;
drivers/scsi/megaraid.c +2 -11
@@ -2795,11 +2795,9 @@ megaraid_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[]) { adapter_t *adapter; -unsigned char *bh;int heads;int sectors;int cylinders; -int rval;/* Get pointer to host config structure */ adapter = (adapter_t *)sdev->host->hostdata;
@@ -2826,15 +2824,8 @@ megaraid_biosparam(struct scsi_device *sdev, struct block_device *bdev, geom[2 ] = cylinders; }else { - bh =scsi_bios_ptable (bdev); - -if ( bh ) { - rval =scsi_partsize (bh, capacity, - &geom[2 ], &geom[0 ], &geom[1 ]); -kfree (bh); -if ( rval !=-1 ) -return rval; - } +if (scsi_partsize (bdev, capacity, geom)) +return 0 ; dev_info(&adapter->dev->dev, "invalid partition on this disk on channel %d\n",
drivers/scsi/scsicam.c +31 -30
106 lines not on this page · raw message
include/scsi/scsicam.h +3 -4
@@ -13,8 +13,7 @@#ifndef SCSICAM_H #define SCSICAM_H -extern int scsicam_bios_param (struct block_device *bdev,sector_t capacity,int *ip); -extern int scsi_partsize (unsigned char *buf,unsigned long capacity, -unsigned int *cyls,unsigned int *hds,unsigned int *secs); -extern unsigned char *scsi_bios_ptable (struct block_device *bdev); +int scsicam_bios_param (struct block_device *bdev,sector_t capacity,int *ip); +bool scsi_partsize (struct block_device *bdev,sector_t capacity,int geom[3 ]); +unsigned char *scsi_bios_ptable (struct block_device *bdev);#endif /* def SCSICAM_H */
Signature · 1 line
2.24.1
PATCH 9/21 block: unexport read_dev_sector and put_dev_sector
In reply to Christoph Hellwigread_dev_sector and put_dev_sector are now only used by the partition parsing code. Remove the export for read_dev_sector and merge it into the only caller. Clean the mess up a bit by using goto labels and the SECTOR_SHIFT constant.
--- block/partition-generic.c | 31 +++++++++++++++++++------------ block/partitions/check.h | 14 +++++++------- include/linux/blkdev.h | 9 --------- 3 files changed, 26 insertions(+), 28 deletions(-)
block/partition-generic.c +19 -12
@@ -484,22 +484,29 @@ int blk_add_partitions(struct gendisk *disk, struct block_device *bdev)return ret; } -unsigned char *read_dev_sector (struct block_device *bdev,sector_t n,Sector *p) +void *read_part_sector (struct parsed_partitions *state,sector_t n,Sector *p) { -struct address_space *mapping = bdev->bd_inode->i_mapping; +struct address_space *mapping = state->bdev->bd_inode->i_mapping;struct page *page; - page =read_mapping_page (mapping, (pgoff_t)(n >> (PAGE_SHIFT -9 )),NULL ); -if (!IS_ERR (page)) { -if (PageError (page)) - goto fail; - p->v = page; -return (unsigned char *)page_address (page) + ((n & ((1 <<PAGE_SECTORS_SHIFT ) -1 )) <<9 ); -fail: -put_page (page); +if (n >=get_capacity (state->bdev->bd_disk)) { + state->access_beyond_eod = true; +return NULL ; } + + page =read_mapping_page (mapping, + (pgoff_t)(n >>PAGE_SECTORS_SHIFT ),NULL ); +if (IS_ERR (page)) + goto out; +if (PageError (page)) + goto out_put_page; + + p->v = page; +return (unsigned char *)page_address (page) + + ((n & ((1 <<PAGE_SECTORS_SHIFT ) -1 )) <<SECTOR_SHIFT ); +out_put_page: +put_page (page); +out: p->v =NULL ;return NULL ; } - -EXPORT_SYMBOL (read_dev_sector);
block/partitions/check.h +7 -7
@@ -28,14 +28,14 @@ void free_partitions(struct parsed_partitions *state);struct parsed_partitions *check_partition (struct gendisk *,struct block_device *); -static inline void *read_part_sector (struct parsed_partitions *state, -sector_t n,Sector *p) +typedef struct { +struct page *v; +}Sector ; + +void *read_part_sector (struct parsed_partitions *state,sector_t n,Sector *p); +static inline void put_dev_sector (Sector p) { -if (n >=get_capacity (state->bdev->bd_disk)) { - state->access_beyond_eod = true; -return NULL ; - } -return read_dev_sector (state->bdev, n, p); +put_page (p.v); } static inline void
include/linux/blkdev.h +0 -9
@@ -1488,15 +1488,6 @@ static inline unsigned int block_size(struct block_device *bdev)return bdev->bd_block_size; } -typedef struct {struct page *v;}Sector ; - -unsigned char *read_dev_sector (struct block_device *,sector_t ,Sector *); - -static inline void put_dev_sector (Sector p) -{ -put_page (p.v); -} -int kblockd_schedule_work (struct work_struct *work);int kblockd_mod_delayed_work_on (int cpu,struct delayed_work *dwork,unsigned long delay);
Signature · 1 line
2.24.1
PATCH 10/21 block: cleanup how md_autodetect_dev is called
In reply to Christoph HellwigAdd a new include/linux/raid/detect.h header to declare the md_autodetect_dev prototype which can be shared between md and the partition code. Then use IS_BUILTIN to call it instead of the ifdef magic.
--- block/partition-generic.c | 11 ++++------- drivers/md/md.c | 1 + include/linux/raid/detect.h | 3 +++ 3 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 include/linux/raid/detect.h
block/partition-generic.c +4 -7
@@ -18,14 +18,11 @@#include <linux/ctype.h> #include <linux/genhd.h> #include <linux/blktrace_api.h> +#include <linux/raid/detect.h> #include "blk.h" #include "partitions/check.h" -#ifdef CONFIG_BLK_DEV_MD -extern void md_autodetect_dev (dev_t dev); -#endif -static ssize_t part_partition_show (struct device *dev,struct device_attribute *attr,char *buf) {
@@ -407,10 +404,10 @@ static bool blk_add_partition(struct gendisk *disk, struct block_device *bdev,return true; } -#ifdef CONFIG_BLK_DEV_MD -if (state->parts[p].flags &ADDPART_FLAG_RAID ) +if (IS_BUILTIN (CONFIG_BLK_DEV_MD ) && + (state->parts[p].flags &ADDPART_FLAG_RAID ))md_autodetect_dev (part_to_dev (part)->devt); -#endif +return true; }
drivers/md/md.c +1 -0
@@ -58,6 +58,7 @@#include <linux/delay.h> #include <linux/raid/md_p.h> #include <linux/raid/md_u.h> +#include <linux/raid/detect.h> #include <linux/slab.h> #include <linux/percpu-refcount.h>
include/linux/raid/detect.h new file +3 -0
@@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +void md_autodetect_dev (dev_t dev);
Signature · 1 line
2.24.1
PATCH 11/21 block: remove warn_no_part
In reply to Christoph HellwigThe warn_no_part is initialized to 1 and never changed. Remove it and execute the code keyed off from it unconditionally.
--- block/partitions/amiga.c | 10 ++++------ block/partitions/check.c | 7 ++----- block/partitions/check.h | 3 --- 3 files changed, 6 insertions(+), 14 deletions(-)
block/partitions/amiga.c +4 -6
@@ -42,9 +42,8 @@ int amiga_partition(struct parsed_partitions *state) goto rdb_done; data =read_part_sector (state, blk, §);if (!data) { -if (warn_no_part) -pr_err ("Dev %s: unable to read RDB block %d\n" , -bdevname (state->bdev, b), blk); +pr_err ("Dev %s: unable to read RDB block %d\n" , +bdevname (state->bdev, b), blk); res =-1 ; goto rdb_done; }
@@ -85,9 +84,8 @@ int amiga_partition(struct parsed_partitions *state) blk *= blksize;/* Read in terms partition table understands */ data =read_part_sector (state, blk, §);if (!data) { -if (warn_no_part) -pr_err ("Dev %s: unable to read partition block %d\n" , -bdevname (state->bdev, b), blk); +pr_err ("Dev %s: unable to read partition block %d\n" , +bdevname (state->bdev, b), blk); res =-1 ; goto rdb_done; }
block/partitions/check.c +2 -5
@@ -37,8 +37,6 @@#include "sysv68.h" #include "cmdline.h" -int warn_no_part =1 ;/*This is ugly: should make genhd removable media aware*/ -static int (*check_part[])(struct parsed_partitions *) = {/* * Probe partition formats with tables at disk address 0
@@ -186,9 +184,8 @@ check_partition(struct gendisk *hd, struct block_device *bdev)/* The partition is unrecognized. So report I/O errors if there were any */ res = err;if (res) { -if (warn_no_part) -strlcat (state->pp_buf, -" unable to read partition table\n" ,PAGE_SIZE ); +strlcat (state->pp_buf, +" unable to read partition table\n" ,PAGE_SIZE );printk (KERN_INFO "%s" , state->pp_buf); }
block/partitions/check.h +0 -3
@@ -50,6 +50,3 @@ put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)strlcat (p->pp_buf, tmp,PAGE_SIZE ); } } - -extern int warn_no_part; -
Signature · 1 line
2.24.1
PATCH 12/21 block: declare all partition detection routines in check.h
In reply to Christoph HellwigThere is no good reason to include one header per partition type in core.c. Instead move the prototypes for the detection routins to check.h, and remove all now empty headers in block/partitions/.
--- block/partitions/acorn.c | 1 - block/partitions/acorn.h | 15 --------------- block/partitions/aix.c | 1 - block/partitions/aix.h | 2 -- block/partitions/amiga.c | 1 - block/partitions/amiga.h | 7 ------- block/partitions/atari.h | 1 - block/partitions/check.c | 16 ---------------- block/partitions/check.h | 22 ++++++++++++++++++++++ block/partitions/cmdline.c | 1 - block/partitions/cmdline.h | 3 --- block/partitions/efi.h | 3 --- block/partitions/ibm.c | 1 - block/partitions/ibm.h | 2 -- block/partitions/karma.h | 3 --- block/partitions/ldm.h | 2 -- block/partitions/mac.h | 1 - block/partitions/msdos.c | 1 - block/partitions/msdos.h | 1 - block/partitions/osf.h | 1 - block/partitions/sgi.h | 1 - block/partitions/sun.h | 1 - block/partitions/sysv68.c | 1 - block/partitions/sysv68.h | 2 -- block/partitions/ultrix.c | 1 - block/partitions/ultrix.h | 6 ------ 26 files changed, 22 insertions(+), 75 deletions(-) delete mode 100644 block/partitions/acorn.h delete mode 100644 block/partitions/aix.h delete mode 100644 block/partitions/amiga.h delete mode 100644 block/partitions/cmdline.h delete mode 100644 block/partitions/ibm.h delete mode 100644 block/partitions/sysv68.h delete mode 100644 block/partitions/ultrix.h
block/partitions/acorn.c +0 -1
@@ -11,7 +11,6 @@#include <linux/adfs_fs.h> #include "check.h" -#include "acorn.h" /* * Partition types. (Oh for reusability)
block/partitions/acorn.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* linux/fs/partitions/acorn.h -* -* Copyright (C) 1996-2001 Russell King. -* -* I _hate_ this partitioning mess - why can't we have one defined -* format, and everyone stick to it? -*/ - -int adfspart_check_CUMANA (struct parsed_partitions *state); -int adfspart_check_ADFS (struct parsed_partitions *state); -int adfspart_check_ICS (struct parsed_partitions *state); -int adfspart_check_POWERTEC (struct parsed_partitions *state); -int adfspart_check_EESOX (struct parsed_partitions *state);
block/partitions/aix.c +0 -1
@@ -6,7 +6,6 @@*/ #include "check.h" -#include "aix.h" struct lvm_rec {char lvm_id[4 ];/* "_LVM" */
block/partitions/aix.h deleted +0 -2
@@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -extern int aix_partition (struct parsed_partitions *state);
block/partitions/amiga.c +0 -1
@@ -14,7 +14,6 @@#include <linux/affs_hardblocks.h> #include "check.h" -#include "amiga.h" static __inline__u32 checksum_block (__be32 *m,int size)
block/partitions/amiga.h deleted +0 -7
@@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* fs/partitions/amiga.h -*/ - -int amiga_partition (struct parsed_partitions *state); -
block/partitions/atari.h +0 -1
@@ -34,4 +34,3 @@ struct rootsectoru16 checksum;/* checksum for bootable disks */ } __packed; -int atari_partition (struct parsed_partitions *state);
block/partitions/check.c +0 -16
@@ -21,22 +21,6 @@#include "check.h" -#include "acorn.h" -#include "amiga.h" -#include "atari.h" -#include "ldm.h" -#include "mac.h" -#include "msdos.h" -#include "osf.h" -#include "sgi.h" -#include "sun.h" -#include "ibm.h" -#include "ultrix.h" -#include "efi.h" -#include "karma.h" -#include "sysv68.h" -#include "cmdline.h" -static int (*check_part[])(struct parsed_partitions *) = {/* * Probe partition formats with tables at disk address 0
block/partitions/check.h +22 -0
@@ -50,3 +50,25 @@ put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)strlcat (p->pp_buf, tmp,PAGE_SIZE ); } } + +/* detection routines go here in alphabetical order: */ +int adfspart_check_ADFS (struct parsed_partitions *state); +int adfspart_check_CUMANA (struct parsed_partitions *state); +int adfspart_check_EESOX (struct parsed_partitions *state); +int adfspart_check_ICS (struct parsed_partitions *state); +int adfspart_check_POWERTEC (struct parsed_partitions *state); +int aix_partition (struct parsed_partitions *state); +int amiga_partition (struct parsed_partitions *state); +int atari_partition (struct parsed_partitions *state); +int cmdline_partition (struct parsed_partitions *state); +int efi_partition (struct parsed_partitions *state); +int ibm_partition (struct parsed_partitions *); +int karma_partition (struct parsed_partitions *state); +int ldm_partition (struct parsed_partitions *state); +int mac_partition (struct parsed_partitions *state); +int msdos_partition (struct parsed_partitions *state); +int osf_partition (struct parsed_partitions *state); +int sgi_partition (struct parsed_partitions *state); +int sun_partition (struct parsed_partitions *state); +int sysv68_partition (struct parsed_partitions *state); +int ultrix_partition (struct parsed_partitions *state);
block/partitions/cmdline.c +0 -1
@@ -18,7 +18,6 @@#include <linux/cmdline-parser.h> #include "check.h" -#include "cmdline.h" static char *cmdline;static struct cmdline_parts *bdev_parts;
block/partitions/cmdline.h deleted +0 -3
@@ -1,3 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -int cmdline_partition (struct parsed_partitions *state);
block/partitions/efi.h +0 -3
@@ -113,7 +113,4 @@ typedef struct _legacy_mbr { __le16 signature; }__packed legacy_mbr; -/* Functions */ -extern int efi_partition (struct parsed_partitions *state); -#endif
block/partitions/ibm.c +0 -1
@@ -15,7 +15,6 @@#include <asm/vtoc.h> #include "check.h" -#include "ibm.h" union label_t {
block/partitions/ibm.h deleted +0 -2
@@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -int ibm_partition (struct parsed_partitions *);
block/partitions/karma.h +0 -3
@@ -4,6 +4,3 @@*/ #define KARMA_LABEL_MAGIC 0xAB56 - -int karma_partition (struct parsed_partitions *state); -
block/partitions/ldm.h +0 -2
@@ -193,7 +193,5 @@ struct ldmdb { /* Cache of the database */ struct list_head v_part; }; -int ldm_partition (struct parsed_partitions *state); -#endif /* _FS_PT_LDM_H_ */
block/partitions/mac.h +0 -1
@@ -42,4 +42,3 @@ struct mac_driver_desc {/* ... more stuff */ }; -int mac_partition (struct parsed_partitions *state);
block/partitions/msdos.c +0 -1
@@ -24,7 +24,6 @@#include "check.h" #include "msdos.h" #include "efi.h" -#include "aix.h" /* * Many architectures don't like unaligned accesses, while
block/partitions/msdos.h +0 -1
@@ -5,5 +5,4 @@#define MSDOS_LABEL_MAGIC 0xAA55 -int msdos_partition (struct parsed_partitions *state);
block/partitions/osf.h +0 -1
@@ -5,4 +5,3 @@#define DISKLABELMAGIC (0x82564557UL) -int osf_partition (struct parsed_partitions *state);
block/partitions/sgi.h +0 -1
@@ -3,7 +3,6 @@* fs/partitions/sgi.h */ -extern int sgi_partition (struct parsed_partitions *state);#define SGI_LABEL_MAGIC 0x0be5a941
block/partitions/sun.h +0 -1
@@ -6,4 +6,3 @@#define SUN_LABEL_MAGIC 0xDABE#define SUN_VTOC_SANITY 0x600DDEEE -int sun_partition (struct parsed_partitions *state);
block/partitions/sysv68.c +0 -1
@@ -6,7 +6,6 @@*/ #include "check.h" -#include "sysv68.h" /* * Volume ID structure: on first 256-bytes sector of disk
block/partitions/sysv68.h deleted +0 -2
@@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -extern int sysv68_partition (struct parsed_partitions *state);
block/partitions/ultrix.c +0 -1
@@ -8,7 +8,6 @@*/ #include "check.h" -#include "ultrix.h" int ultrix_partition (struct parsed_partitions *state) {
block/partitions/ultrix.h deleted +0 -6
@@ -1,6 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* fs/partitions/ultrix.h -*/ - -int ultrix_partition (struct parsed_partitions *state);
Signature · 1 line
2.24.1
PATCH 13/21 block: remove block/partitions/karma.h
In reply to Christoph HellwigJust move the single define to block/partitions/karma.c.
--- block/partitions/karma.c | 3 ++- block/partitions/karma.h | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 block/partitions/karma.h
block/partitions/karma.c +2 -1
@@ -8,9 +8,10 @@*/ #include "check.h" -#include "karma.h" #include <linux/compiler.h> +#define KARMA_LABEL_MAGIC 0xAB56 +int karma_partition (struct parsed_partitions *state) {int i;
block/partitions/karma.h deleted +0 -6
@@ -1,6 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* fs/partitions/karma.h -*/ - -#define KARMA_LABEL_MAGIC 0xAB56
Signature · 1 line
2.24.1
PATCH 14/21 block: remove block/partitions/osf.h
In reply to Christoph HellwigJust move the single define to block/partitions/osf.c.
--- block/partitions/osf.c | 2 +- block/partitions/osf.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 block/partitions/osf.h
block/partitions/osf.c +1 -1
@@ -9,9 +9,9 @@*/ #include "check.h" -#include "osf.h" #define MAX_OSF_PARTITIONS 18 +#define DISKLABELMAGIC (0x82564557UL)int osf_partition (struct parsed_partitions *state) {
block/partitions/osf.h deleted +0 -7
@@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* fs/partitions/osf.h -*/ - -#define DISKLABELMAGIC (0x82564557UL) -
Signature · 1 line
2.24.1
PATCH 15/21 block: remove block/partitions/sgi.h
In reply to Christoph HellwigJust move the single define to block/partitions/sgi.c.
--- block/partitions/sgi.c | 3 ++- block/partitions/sgi.h | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 block/partitions/sgi.h
block/partitions/sgi.c +2 -1
@@ -6,7 +6,8 @@*/ #include "check.h" -#include "sgi.h" + +#define SGI_LABEL_MAGIC 0x0be5a941struct sgi_disklabel {__be32 magic_mushroom;/* Big fat spliff... */
block/partitions/sgi.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* fs/partitions/sgi.h -*/ - - -#define SGI_LABEL_MAGIC 0x0be5a941 -
Signature · 1 line
2.24.1
PATCH 16/21 block: remove block/partitions/sun.h
In reply to Christoph HellwigJust move the two defines to block/partitions/sun.c.
--- block/partitions/sun.c | 4 +++- block/partitions/sun.h | 8 -------- 2 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 block/partitions/sun.h
block/partitions/sun.c +3 -1
@@ -9,7 +9,9 @@*/ #include "check.h" -#include "sun.h" + +#define SUN_LABEL_MAGIC 0xDABE +#define SUN_VTOC_SANITY 0x600DDEEEint sun_partition (struct parsed_partitions *state) {
block/partitions/sun.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* fs/partitions/sun.h -*/ - -#define SUN_LABEL_MAGIC 0xDABE -#define SUN_VTOC_SANITY 0x600DDEEE -
Signature · 1 line
2.24.1
PATCH 17/21 block: move struct partition out of genhd.h
In reply to Christoph Hellwigstruct partition is the on-disk format of a MSDOS partition table entry. Move it out of genhd.h into a new msdos_partition.h header and give it a msdos_ prefix to avoid confusion.
Also move the magic number from block/partitions/msdos.h to the new header so that it can be used by the SCSI drivers looking at the DOS partition tables.
--- block/partitions/ldm.c | 6 +++--- block/partitions/msdos.c | 28 ++++++++++++++-------------- block/partitions/msdos.h | 8 -------- drivers/scsi/BusLogic.c | 8 +++++--- drivers/scsi/aacraid/linit.c | 7 ++++--- drivers/scsi/scsi_debug.c | 5 +++-- drivers/scsi/scsicam.c | 3 ++- include/linux/genhd.h | 13 ------------- include/linux/msdos_partition.h | 20 ++++++++++++++++++++ 9 files changed, 51 insertions(+), 47 deletions(-) delete mode 100644 block/partitions/msdos.h create mode 100644 include/linux/msdos_partition.h
block/partitions/ldm.c +3 -3
@@ -14,10 +14,10 @@#include <linux/stringify.h> #include <linux/kernel.h> #include <linux/uuid.h> +#include <linux/msdos_partition.h> #include "ldm.h" #include "check.h" -#include "msdos.h" /* * ldm_debug/info/error/crit - Output an error message
@@ -493,7 +493,7 @@ static bool ldm_validate_partition_table(struct parsed_partitions *state) {Sector sect;u8 *data; -struct partition *p; +struct msdos_partition *p;int i;bool result = false;
@@ -508,7 +508,7 @@ static bool ldm_validate_partition_table(struct parsed_partitions *state)if (*(__le16 *) (data +0x01FE ) !=cpu_to_le16 (MSDOS_LABEL_MAGIC )) goto out; - p = (struct partition *)(data +0x01BE ); + p = (struct msdos_partition *)(data +0x01BE );for (i =0 ; i <4 ; i++, p++)if (SYS_IND (p) ==LDM_PARTITION ) { result = true;
block/partitions/msdos.c +14 -14
@@ -20,9 +20,9 @@* Re-organised Feb 1998 Russell King */ #include <linux/msdos_fs.h> +#include <linux/msdos_partition.h> #include "check.h" -#include "msdos.h" #include "efi.h" /*
@@ -34,17 +34,17 @@#define SYS_IND (p) get_unaligned(&p->sys_ind) -static inline sector_t nr_sects (struct partition *p) +static inline sector_t nr_sects (struct msdos_partition *p) {return (sector_t )get_unaligned_le32 (&p->nr_sects); } -static inline sector_t start_sect (struct partition *p) +static inline sector_t start_sect (struct msdos_partition *p) {return (sector_t )get_unaligned_le32 (&p->start_sect); } -static inline int is_extended_partition (struct partition *p) +static inline int is_extended_partition (struct msdos_partition *p) { return (SYS_IND(p) == DOS_EXTENDED_PARTITION || SYS_IND(p) == WIN98_EXTENDED_PARTITION ||
@@ -67,7 +67,7 @@ msdos_magic_present(unsigned char *p)#define AIX_LABEL_MAGIC4 0xC1static int aix_magic_present (struct parsed_partitions *state,unsigned char *p) { -struct partition *pt = (struct partition *) (p +0x1be ); +struct msdos_partition *pt = (struct msdos_partition *) (p +0x1be );Sector sect;unsigned char *d;int slot, ret =0 ;
@@ -121,7 +121,7 @@ static void parse_extended(struct parsed_partitions *state, sector_t first_sector, sector_t first_size, u32 disksig) { - struct partition *p; + struct msdos_partition *p;Sector sect;unsigned char *data;sector_t this_sector, this_size;
@@ -145,7 +145,7 @@ static void parse_extended(struct parsed_partitions *state,if (!msdos_magic_present (data +510 )) goto done; - p = (struct partition *) (data +0x1be ); + p = (struct msdos_partition *) (data +0x1be );/* * Usually, the first entry is the real data partition,
@@ -402,14 +402,14 @@ static void parse_minix(struct parsed_partitions *state,#ifdef CONFIG_MINIX_SUBPARTITION Sector sect;unsigned char *data; -struct partition *p; +struct msdos_partition *p;int i; data =read_part_sector (state, offset, §);if (!data)return ; - p = (struct partition *)(data +0x1be ); + p = (struct msdos_partition *)(data +0x1be );/* The first sector of a Minix partition can have either * a secondary MBR describing its subpartitions, or
@@ -453,7 +453,7 @@ int msdos_partition(struct parsed_partitions *state)sector_t sector_size =bdev_logical_block_size (state->bdev) /512 ;Sector sect;unsigned char *data; -struct partition *p; +struct msdos_partition *p;struct fat_boot_sector *fb;int slot;u32 disksig;
@@ -487,7 +487,7 @@ int msdos_partition(struct parsed_partitions *state)* partition table. Reject this in case the boot indicator * is not 0 or 0x80. */ - p = (struct partition *) (data +0x1be ); + p = (struct msdos_partition *) (data +0x1be );for (slot =1 ; slot <=4 ; slot++, p++) {if (p->boot_ind !=0 && p->boot_ind !=0x80 ) {/*
@@ -509,7 +509,7 @@ int msdos_partition(struct parsed_partitions *state) }#ifdef CONFIG_EFI_PARTITION - p = (struct partition *) (data +0x1be ); + p = (struct msdos_partition *) (data +0x1be );for (slot =1 ; slot <=4 ; slot++, p++) {/* If this is an EFI GPT disk, msdos should ignore it. */ if (SYS_IND (p) ==EFI_PMBR_OSTYPE_EFI_GPT ) {
@@ -518,7 +518,7 @@ int msdos_partition(struct parsed_partitions *state) } }#endif - p = (struct partition *) (data +0x1be ); + p = (struct msdos_partition *) (data +0x1be ); disksig =le32_to_cpup ((__le32 *)(data +0x1b8 ));
@@ -565,7 +565,7 @@ int msdos_partition(struct parsed_partitions *state)strlcat (state->pp_buf,"\n" ,PAGE_SIZE );/* second pass - output for each on a separate line */ - p = (struct partition *) (0x1be + data); + p = (struct msdos_partition *) (0x1be + data);for (slot =1 ; slot <=4 ; slot++, p++) {unsigned char id =SYS_IND (p);int n;
block/partitions/msdos.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* fs/partitions/msdos.h -*/ - -#define MSDOS_LABEL_MAGIC 0xAA55 - -
drivers/scsi/BusLogic.c +5 -3
@@ -36,6 +36,7 @@#include <linux/jiffies.h> #include <linux/dma-mapping.h> #include <linux/slab.h> +#include <linux/msdos_partition.h> #include <scsi/scsicam.h> #include <asm/dma.h>
@@ -3410,9 +3411,10 @@ static int blogic_diskparam(struct scsi_device *sdev, struct block_device *dev,a partition table entry whose end_head matches one of the standard BusLogic geometry translations (64/32, 128/32, or 255/63). */ -if (*(unsigned short *) (buf +64 ) ==0xAA55 ) { -struct partition *part1_entry = (struct partition *) buf; -struct partition *part_entry = part1_entry; +if (*(unsigned short *) (buf +64 ) ==MSDOS_LABEL_MAGIC ) { +struct msdos_partition *part1_entry = + (struct msdos_partition *)buf; +struct msdos_partition *part_entry = part1_entry;int saved_cyl = diskparam->cylinders, part_no;unsigned char part_end_head =0 , part_end_sector =0 ;
drivers/scsi/aacraid/linit.c +4 -3
@@ -33,6 +33,7 @@#include <linux/syscalls.h> #include <linux/delay.h> #include <linux/kthread.h> +#include <linux/msdos_partition.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h>
@@ -328,9 +329,9 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev, buf =scsi_bios_ptable (bdev);if (!buf)return 0 ; -if (*(__le16 *)(buf +0x40 ) ==cpu_to_le16 (0xaa55 )) { -struct partition *first = (struct partition * )buf; -struct partition *entry = first; +if (*(__le16 *)(buf +0x40 ) ==cpu_to_le16 (MSDOS_LABEL_MAGIC )) { +struct msdos_partition *first = (struct msdos_partition *)buf; +struct msdos_partition *entry = first;int saved_cylinders = param->cylinders;int num;unsigned char end_head, end_sec;
drivers/scsi/scsi_debug.c +3 -2
@@ -38,6 +38,7 @@#include <linux/hrtimer.h> #include <linux/uuid.h> #include <linux/t10-pi.h> +#include <linux/msdos_partition.h> #include <net/checksum.h>
@@ -4146,7 +4147,7 @@ static int scsi_debug_host_reset(struct scsi_cmnd *SCpnt)static void __init sdebug_build_parts (unsigned char *ramp,unsigned long store_size) { -struct partition *pp; +struct msdos_partition *pp;int starts[SDEBUG_MAX_PARTS +2 ];int sectors_per_part, num_sectors, k;int heads_by_sects, start_sec, end_sec;
@@ -4171,7 +4172,7 @@ static void __init sdebug_build_parts(unsigned char *ramp, ramp[510 ] =0x55 ;/* magic partition markings */ ramp[511 ] =0xAA ; - pp = (struct partition *)(ramp +0x1be ); + pp = (struct msdos_partition *)(ramp +0x1be );for (k =0 ; starts[k +1 ]; ++k, ++pp) { start_sec = starts[k]; end_sec = starts[k +1 ] -1 ;
drivers/scsi/scsicam.c +2 -1
@@ -17,6 +17,7 @@#include <linux/genhd.h> #include <linux/kernel.h> #include <linux/blkdev.h> +#include <linux/msdos_partition.h> #include <asm/unaligned.h> #include <scsi/scsicam.h>
@@ -61,7 +62,7 @@ bool scsi_partsize(struct block_device *bdev, sector_t capacity, int geom[3]) {int cyl, ext_cyl, end_head, end_cyl, end_sector;unsigned int logical_end, physical_end, ext_physical_end; -struct partition *p, *largest =NULL ; +struct msdos_partition *p, *largest =NULL ;void *buf;int ret = false;
include/linux/genhd.h +0 -13
@@ -70,19 +70,6 @@ enum {#include <linux/fs.h> #include <linux/workqueue.h> -struct partition { -unsigned char boot_ind;/* 0x80 - active */ -unsigned char head;/* starting head */ -unsigned char sector;/* starting sector */ -unsigned char cyl;/* starting cylinder */ -unsigned char sys_ind;/* What partition type */ -unsigned char end_head;/* end head */ -unsigned char end_sector;/* end sector */ -unsigned char end_cyl;/* end cylinder */ -__le32 start_sect;/* starting sector counting from 0 */ -__le32 nr_sects;/* nr of sectors in partition */ -} __attribute__((packed)); -struct disk_stats {u64 nsecs[NR_STAT_GROUPS ];unsigned long sectors[NR_STAT_GROUPS ];
include/linux/msdos_partition.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MSDOS_PARTITION_H +#define _LINUX_MSDOS_PARTITION_H + +#define MSDOS_LABEL_MAGIC 0xAA55 + +struct msdos_partition { +u8 boot_ind;/* 0x80 - active */ +u8 head;/* starting head */ +u8 sector;/* starting sector */ +u8 cyl;/* starting cylinder */ +u8 sys_ind;/* What partition type */ +u8 end_head;/* end head */ +u8 end_sector;/* end sector */ +u8 end_cyl;/* end cylinder */ +__le32 start_sect;/* starting sector counting from 0 */ +__le32 nr_sects;/* nr of sectors in partition */ +} __packed; + +#endif /* LINUX_MSDOS_PARTITION_H */
Signature · 1 line
2.24.1
PATCH 18/21 block: move the *_PARTITION enum out of genhd.h
In reply to Christoph HellwigThe enum containing the *_PARTITION symbolic names is only relevant for the partition parser. More specifically most values are MSDOS partition table system indicators and thus should go straight into msdos.c. One value is only used by the sun partition parser, and the sun and sgi partition parsers use the same value as the x86 Linux RAID indicator to also indicate RAID autodetection. Duplicate them in sun.c and sgi.c given that the different partition types use entirely different values otherwise.
--- block/partitions/sgi.c | 4 ++++ block/partitions/sun.c | 5 +++++ include/linux/genhd.h | 30 ------------------------------ include/linux/msdos_partition.h | 31 +++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 30 deletions(-)
block/partitions/sgi.c +4 -0
@@ -9,6 +9,10 @@#define SGI_LABEL_MAGIC 0x0be5a941 +enum { +LINUX_RAID_PARTITION =0xfd ,/* autodetect RAID partition */ +}; +struct sgi_disklabel {__be32 magic_mushroom;/* Big fat spliff... */ __be16 root_part_num;/* Root partition number */
block/partitions/sun.c +5 -0
@@ -13,6 +13,11 @@#define SUN_LABEL_MAGIC 0xDABE#define SUN_VTOC_SANITY 0x600DDEEE +enum { +SUN_WHOLE_DISK =5 , +LINUX_RAID_PARTITION =0xfd ,/* autodetect RAID partition */ +}; +int sun_partition (struct parsed_partitions *state) {int i;
include/linux/genhd.h +0 -30
@@ -30,36 +30,6 @@ extern struct device_type part_type;extern struct kobject *block_depr;extern struct class block_class; -enum { -/* These three have identical behaviour; use the second one if DOS FDISK gets -confused about extended/logical partitions starting past cylinder 1023. */ -DOS_EXTENDED_PARTITION =5 , -LINUX_EXTENDED_PARTITION =0x85 , -WIN98_EXTENDED_PARTITION =0x0f , - -SUN_WHOLE_DISK =DOS_EXTENDED_PARTITION , - -LINUX_SWAP_PARTITION =0x82 , -LINUX_DATA_PARTITION =0x83 , -LINUX_LVM_PARTITION =0x8e , -LINUX_RAID_PARTITION =0xfd ,/* autodetect RAID partition */ - -SOLARIS_X86_PARTITION =LINUX_SWAP_PARTITION , -NEW_SOLARIS_X86_PARTITION =0xbf , - -DM6_AUX1PARTITION =0x51 ,/* no DDO: use xlated geom */ -DM6_AUX3PARTITION =0x53 ,/* no DDO: use xlated geom */ -DM6_PARTITION =0x54 ,/* has DDO: use xlated geom & offset */ -EZD_PARTITION =0x55 ,/* EZ-DRIVE */ - -FREEBSD_PARTITION =0xa5 ,/* FreeBSD Partition ID */ -OPENBSD_PARTITION =0xa6 ,/* OpenBSD Partition ID */ -NETBSD_PARTITION =0xa9 ,/* NetBSD Partition ID */ -BSDI_PARTITION =0xb7 ,/* BSDI Partition ID */ -MINIX_PARTITION =0x81 ,/* Minix Partition ID */ -UNIXWARE_PARTITION =0x63 ,/* Same as GNU_HURD and SCO Unix */ -}; -#define DISK_MAX_PARTS 256#define DISK_NAME_LEN 32
include/linux/msdos_partition.h +31 -0
@@ -17,4 +17,35 @@ struct msdos_partition { __le32 nr_sects; /* nr of sectors in partition */ } __packed; +enum msdos_sys_ind { +/* +* These three have identical behaviour; use the second one if DOS FDISK +* gets confused about extended/logical partitions starting past +* cylinder 1023. +*/ +DOS_EXTENDED_PARTITION =5 , +LINUX_EXTENDED_PARTITION =0x85 , +WIN98_EXTENDED_PARTITION =0x0f , + +LINUX_SWAP_PARTITION =0x82 , +LINUX_DATA_PARTITION =0x83 , +LINUX_LVM_PARTITION =0x8e , +LINUX_RAID_PARTITION =0xfd ,/* autodetect RAID partition */ + +SOLARIS_X86_PARTITION =LINUX_SWAP_PARTITION , +NEW_SOLARIS_X86_PARTITION =0xbf , + +DM6_AUX1PARTITION =0x51 ,/* no DDO: use xlated geom */ +DM6_AUX3PARTITION =0x53 ,/* no DDO: use xlated geom */ +DM6_PARTITION =0x54 ,/* has DDO: use xlated geom & offset */ +EZD_PARTITION =0x55 ,/* EZ-DRIVE */ + +FREEBSD_PARTITION =0xa5 ,/* FreeBSD Partition ID */ +OPENBSD_PARTITION =0xa6 ,/* OpenBSD Partition ID */ +NETBSD_PARTITION =0xa9 ,/* NetBSD Partition ID */ +BSDI_PARTITION =0xb7 ,/* BSDI Partition ID */ +MINIX_PARTITION =0x81 ,/* Minix Partition ID */ +UNIXWARE_PARTITION =0x63 ,/* Same as GNU_HURD and SCO Unix */ +}; +#endif /* LINUX_MSDOS_PARTITION_H */
Signature · 1 line
2.24.1
PATCH 19/21 partitions/msdos: remove LINUX_SWAP_PARTITION
In reply to Christoph HellwigJust always use NEW_SOLARIS_X86_PARTITION and explain the situation, as that is less confusing than two names for a single value.
--- block/partitions/msdos.c | 18 ++++++++++++------ include/linux/msdos_partition.h | 3 +-- 2 files changed, 13 insertions(+), 8 deletions(-)
block/partitions/msdos.c +12 -6
@@ -77,13 +77,19 @@ static int aix_magic_present(struct parsed_partitions *state, unsigned char *p) p[2] == AIX_LABEL_MAGIC3 && p[3] == AIX_LABEL_MAGIC4))return 0 ; -/* Assume the partition table is valid if Linux partitions exists */ + +/* +* Assume the partition table is valid if Linux partitions exists. +* Note that old Solaris/x86 partitions use the same indicator as +* Linux swap partitions, so we consider that a Linux partition as +* well. +*/ for (slot =1 ; slot <=4 ; slot++, pt++) { -if (pt->sys_ind ==LINUX_SWAP_PARTITION || - pt->sys_ind ==LINUX_RAID_PARTITION || - pt->sys_ind ==LINUX_DATA_PARTITION || - pt->sys_ind ==LINUX_LVM_PARTITION || -is_extended_partition (pt)) +if (pt->sys_ind ==SOLARIS_X86_PARTITION || + pt->sys_ind ==LINUX_RAID_PARTITION || + pt->sys_ind ==LINUX_DATA_PARTITION || + pt->sys_ind ==LINUX_LVM_PARTITION || +is_extended_partition (pt))return 0 ; } d =read_part_sector (state,7 , §);
include/linux/msdos_partition.h +1 -2
@@ -27,12 +27,11 @@ enum msdos_sys_ind {LINUX_EXTENDED_PARTITION =0x85 ,WIN98_EXTENDED_PARTITION =0x0f , -LINUX_SWAP_PARTITION =0x82 ,LINUX_DATA_PARTITION =0x83 ,LINUX_LVM_PARTITION =0x8e ,LINUX_RAID_PARTITION =0xfd ,/* autodetect RAID partition */ -SOLARIS_X86_PARTITION =LINUX_SWAP_PARTITION , +SOLARIS_X86_PARTITION =0x82 ,/* also Linux swap partitions */ NEW_SOLARIS_X86_PARTITION =0xbf , DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */
Signature · 1 line
2.24.1
PATCH 20/21 block: move the various x86 Unix label formats out of genhd.h
In reply to Christoph HellwigAll these are just used in block/partitions/msdos.c, so move them out of the genhd.h driver included by every driver.
--- block/partitions/msdos.c | 125 ++++++++++++++++++++++++++++++++++ include/linux/genhd.h | 143 --------------------------------------- 2 files changed, 125 insertions(+), 143 deletions(-)
block/partitions/msdos.c +125 -0
@@ -18,6 +18,12 @@* Check partition table on IDE disks for common CHS translations * * Re-organised Feb 1998 Russell King +* +* BSD disklabel support by Yossi Gottlieb <[email protected]> +* updated by Marc Espie <[email protected]> +* +* Unixware slices support by Andrzej Krzysztofowicz <[email protected]> +* and Krzysztof G. Baranowski <[email protected]> */ #include <linux/msdos_fs.h> #include <linux/msdos_partition.h>
@@ -215,6 +221,30 @@ static void parse_extended(struct parsed_partitions *state,put_dev_sector (sect); } +#define SOLARIS_X86_NUMSLICE 16 +#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) + +struct solaris_x86_slice { +__le16 s_tag;/* ID tag of partition */ +__le16 s_flag;/* permission flags */ +__le32 s_start;/* start sector no of partition */ +__le32 s_size;/* # of blocks in partition */ +}; + +struct solaris_x86_vtoc { +unsigned int v_bootinfo[3 ];/* info needed by mboot */ +__le32 v_sanity;/* to verify vtoc sanity */ +__le32 v_version;/* layout version */ +char v_volume[8 ];/* volume name */ +__le16 v_sectorsz;/* sector size in bytes */ +__le16 v_nparts;/* number of partitions */ +unsigned int v_reserved[10 ];/* free space */ +struct solaris_x86_slice + v_slice[SOLARIS_X86_NUMSLICE ];/* slice headers */ +unsigned int timestamp[SOLARIS_X86_NUMSLICE ];/* timestamp */ +char v_asciilabel[128 ];/* for compatibility */ +}; +/* [email protected]: Solaris has a nasty indicator: 0x82 which also indicates linux swap. Be careful before believing this is Solaris. */
@@ -270,6 +300,54 @@ static void parse_solaris_x86(struct parsed_partitions *state,#endif } +/* check against BSD src/sys/sys/disklabel.h for consistency */ +#define BSD_DISKMAGIC (0x82564557UL)/* The disk magic number */ +#define BSD_MAXPARTITIONS 16 +#define OPENBSD_MAXPARTITIONS 16 +#define BSD_FS_UNUSED 0/* disklabel unused partition entry ID */ +struct bsd_disklabel { +__le32 d_magic;/* the magic number */ +__s16 d_type;/* drive type */ +__s16 d_subtype;/* controller/d_type specific */ +char d_typename[16 ];/* type name, e.g. "eagle" */ +char d_packname[16 ];/* pack identifier */ +__u32 d_secsize;/* # of bytes per sector */ +__u32 d_nsectors;/* # of data sectors per track */ +__u32 d_ntracks;/* # of tracks per cylinder */ +__u32 d_ncylinders;/* # of data cylinders per unit */ +__u32 d_secpercyl;/* # of data sectors per cylinder */ +__u32 d_secperunit;/* # of data sectors per unit */ +__u16 d_sparespertrack;/* # of spare sectors per track */ +__u16 d_sparespercyl;/* # of spare sectors per cylinder */ +__u32 d_acylinders;/* # of alt. cylinders per unit */ +__u16 d_rpm;/* rotational speed */ +__u16 d_interleave;/* hardware sector interleave */ +__u16 d_trackskew;/* sector 0 skew, per track */ +__u16 d_cylskew;/* sector 0 skew, per cylinder */ +__u32 d_headswitch;/* head switch time, usec */ +__u32 d_trkseek;/* track-to-track seek, usec */ +__u32 d_flags;/* generic flags */ +#define NDDATA 5 +__u32 d_drivedata[NDDATA ];/* drive-type specific information */ +#define NSPARE 5 +__u32 d_spare[NSPARE ];/* reserved for future use */ +__le32 d_magic2;/* the magic number (again) */ +__le16 d_checksum;/* xor of data incl. partitions */ + +/* filesystem and partition information: */ +__le16 d_npartitions;/* number of partitions in following */ +__le32 d_bbsize;/* size of boot area at sn0, bytes */ +__le32 d_sbsize;/* max size of fs superblock, bytes */ +struct bsd_partition {/* the partition table */ +__le32 p_size;/* number of sectors in partition */ +__le32 p_offset;/* starting sector */ +__le32 p_fsize;/* filesystem basic fragment size */ +__u8 p_fstype;/* filesystem type, see below */ +__u8 p_frag;/* filesystem fragments per block */ +__le16 p_cpg;/* filesystem cylinders per group */ + } d_partitions[BSD_MAXPARTITIONS ];/* actually may be more */ +}; +#if defined(CONFIG_BSD_DISKLABEL )/* * Create devices for BSD partitions listed in a disklabel, under a
@@ -354,6 +432,51 @@ static void parse_openbsd(struct parsed_partitions *state,#endif } +#define UNIXWARE_DISKMAGIC (0xCA5E600DUL)/* The disk magic number */ +#define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL)/* The slice table magic nr */ +#define UNIXWARE_NUMSLICE 16 +#define UNIXWARE_FS_UNUSED 0/* Unused slice entry ID */ + +struct unixware_slice { +__le16 s_label;/* label */ +__le16 s_flags;/* permission flags */ +__le32 start_sect;/* starting sector */ +__le32 nr_sects;/* number of sectors in slice */ +}; + +struct unixware_disklabel { +__le32 d_type;/* drive type */ +__le32 d_magic;/* the magic number */ +__le32 d_version;/* version number */ +char d_serial[12 ];/* serial number of the device */ +__le32 d_ncylinders;/* # of data cylinders per device */ +__le32 d_ntracks;/* # of tracks per cylinder */ +__le32 d_nsectors;/* # of data sectors per track */ +__le32 d_secsize;/* # of bytes per sector */ +__le32 d_part_start;/* # of first sector of this partition*/ +__le32 d_unknown1[12 ];/* ? */ +__le32 d_alt_tbl;/* byte offset of alternate table */ +__le32 d_alt_len;/* byte length of alternate table */ +__le32 d_phys_cyl;/* # of physical cylinders per device */ +__le32 d_phys_trk;/* # of physical tracks per cylinder */ +__le32 d_phys_sec;/* # of physical sectors per track */ +__le32 d_phys_bytes;/* # of physical bytes per sector */ +__le32 d_unknown2;/* ? */ +__le32 d_unknown3;/* ? */ +__le32 d_pad[8 ];/* pad */ + +struct unixware_vtoc { +__le32 v_magic;/* the magic number */ +__le32 v_version;/* version number */ +char v_name[8 ];/* volume name */ +__le16 v_nslices;/* # of slices */ +__le16 v_unknown1;/* ? */ +__le32 v_reserved[10 ];/* reserved */ +struct unixware_slice + v_slice[UNIXWARE_NUMSLICE ];/* slice headers */ + } vtoc; +};/* 408 */ +/* * Create devices for Unixware partitions listed in a disklabel, under a * dos-like partition. See parse_extended() for more information.
@@ -397,6 +520,8 @@ static void parse_unixware(struct parsed_partitions *state,#endif } +#define MINIX_NR_SUBPARTITIONS 4 +/* * Minix 2.0.0/2.0.2 subpartition support. * Anand Krishnamurthy <[email protected]>
include/linux/genhd.h +0 -142
145 lines not on this page · raw message
PATCH 21/21 block: merge partition-generic.c and check.c
In reply to Christoph HellwigMerge block/partition-generic.c and block/partitions/check.c into a single block/partitions/core.c as the content is closely related and both files are tiny.
---
block/Makefile | 3 +-
block/partitions/Makefile | 3 +-
block/partitions/check.c | 179 ------------------
block/partitions/check.h | 5 -
.../core.c} | 178 +++++++++++++++--
5 files changed, 166 insertions(+), 202 deletions(-)
delete mode 100644 block/partitions/check.c
rename block/{partition-generic.c => partitions/core.c} (77%)block/Makefile +1 -2
@@ -8,8 +8,7 @@ obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-sysfs.o \ blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \ blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \ blk-mq-sysfs.o blk-mq-cpumap.o blk-mq-sched.o ioctl.o \ - genhd.o partition-generic.o ioprio.o \ - badblocks.o partitions/ blk-rq-qos.o + genhd.o ioprio.o badblocks.o partitions/ blk-rq-qos.o obj-$(CONFIG_BOUNCE) += bounce.o obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_ioctl.o
block/partitions/Makefile +1 -2
@@ -3,8 +3,7 @@ # Makefile for the linux kernel. # -obj-$(CONFIG_BLOCK) := check.o - +obj-$(CONFIG_BLOCK) += core.o obj-$(CONFIG_ACORN_PARTITION) += acorn.o obj-$(CONFIG_AMIGA_PARTITION) += amiga.o obj-$(CONFIG_ATARI_PARTITION) += atari.o
block/partitions/check.c deleted +0 -179
179 lines not on this page · raw message
block/partitions/check.h +0 -5
@@ -23,11 +23,6 @@ struct parsed_partitions {char *pp_buf; }; -void free_partitions (struct parsed_partitions *state); - -struct parsed_partitions * -check_partition (struct gendisk *,struct block_device *); -typedef struct {struct page *v; }Sector ;
block/partitions/core.c renamed from block/partition-generic.c +164 -14
191 lines not on this page · raw message
Signature · 1 line
2.24.1
ping?
Quoted 3 lines · Christoph Hellwig
Hi Jens,
this series cleans up the partitioning code.
---end quoted text---
Jens Axboe
maintainerQuoted 7 lines · Christoph Hellwig
ping?
Quoted 3 lines · Christoph Hellwig
Hi Jens,
this series cleans up the partitioning code.
---end quoted text---
I did take a look, looks fine to me. Doesn't apply to the 5.7/block branch though, I'll take a look in a bit, probably an easy reject.
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerQuoted 11 lines · Jens Axboe
Quoted 7 lines · Christoph Hellwig
ping?
Quoted 3 lines · Christoph Hellwig
Hi Jens,
this series cleans up the partitioning code.
---end quoted text---
I did take a look, looks fine to me. Doesn't apply to the 5.7/block branch though, I'll take a look in a bit, probably an easy reject.
Yeah, looks like a trivial conflict with:
commit e598a72faeb543599bdf0d930df3a71906404e6f
Author: Balbir Singh <[email protected]> Date: Fri Mar 13 05:30:05 2020 +0000
block/genhd: Notify udev about capacity change
Signature · 1 line
Jens Axboe
Quoted 13 lines · Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 7 lines · Christoph Hellwig
ping?
Quoted 3 lines · Christoph Hellwig
Hi Jens,
this series cleans up the partitioning code.
---end quoted text---
I did take a look, looks fine to me. Doesn't apply to the 5.7/block branch though, I'll take a look in a bit, probably an easy reject.
Quoted 7 lines
Yeah, looks like a trivial conflict with:
commit
e598a72faeb543599bdf0d930df3a71906404e6fAuthor: Balbir Singh <[email protected]> Date: Fri Mar 13 05:30:05 2020 +0000block/genhd: Notify udev about capacity change
FYI, I still think that series has a bug in the virtio conversion..
Jens Axboe
maintainerQuoted 11 lines · Jens Axboe
Quoted 7 lines · Christoph Hellwig
ping?
Quoted 3 lines · Christoph Hellwig
Hi Jens,
this series cleans up the partitioning code.
---end quoted text---
I did take a look, looks fine to me. Doesn't apply to the 5.7/block branch though, I'll take a look in a bit, probably an easy reject.
OK, so it also assumes that the PAGE_SHIFT -> PAGE_SECTORS_SHIFT patch is in, which I dropped.
Can you resend?
Signature · 1 line
Jens Axboe