Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 00/15] Fix issue with KOBJ_ADD uevent versus disk attributes
This is an attempt to fix the issue that some disks' sysfs attributes are not ready at the time its KOBJ_ADD event is sent. The symptom is during device hotplug, udev may fail to find certain attributes, such as serial or wwn, of the disk. As a result the /dev/disk/by-id entries are not created. The cause is device_add_disk emits the uevent before returning, and the callers have to create sysfs entries after that. The fix here is to pass attr_groups from callers to device_add_disk, so it can be added before KOBJ_ADD. Also add basic error handling around device_add_disk code, (or add FIXME comment where work is left). Fam Zheng (15): disk: Drop add_disk in favor of device_add_disk genhd: Return error from register_disk() genhd: Return error from blk_register_region block: Return error from blk_integrity_add genhd: Return error from disk_{add,alloc}_events genhd: Add return code to device_add_disk genhd: Add attribute group parameter to device_add_disk nvme: Pass attribute group to device_add_disk virtio-blk: Pass attribute group to device_add_disk mtd: Pass attribute group to device_add_disk zram: Pass attribute group to device_add_disk mtip: Pass attribute group to device_add_disk aoeblk: Pass attribute group to device_add_disk axonram: Pass attribute group to device_add_disk block: Add FIXME comment to handle device_add_disk error arch/m68k/emu/nfblock.c | 3 +- arch/powerpc/sysdev/axonram.c | 23 +++++--- arch/um/drivers/ubd_kern.c | 3 +- arch/xtensa/platforms/iss/simdisk.c | 3 +- block/blk-integrity.c | 12 ++-- block/genhd.c | 112 +++++++++++++++++++++++++----------- drivers/block/DAC960.c | 3 +- drivers/block/amiflop.c | 3 +- drivers/block/aoe/aoeblk.c | 13 ++--- drivers/block/ataflop.c | 3 +- drivers/block/brd.c | 6 +- drivers/block/cciss.c | 3 +- drivers/block/drbd/drbd_main.c | 3 +- drivers/block/floppy.c | 5 +- drivers/block/hd.c | 3 +- drivers/block/loop.c | 3 +- drivers/block/mg_disk.c | 3 +- drivers/block/mtip32xx/mtip32xx.c | 39 +++---------- drivers/block/nbd.c | 3 +- drivers/block/null_blk.c | 3 +- drivers/block/osdblk.c | 3 +- drivers/block/paride/pcd.c | 3 +- drivers/block/paride/pd.c | 3 +- drivers/block/paride/pf.c | 3 +- drivers/block/pktcdvd.c | 3 +- drivers/block/ps3disk.c | 3 +- drivers/block/ps3vram.c | 3 +- drivers/block/rbd.c | 3 +- drivers/block/rsxx/dev.c | 3 +- drivers/block/skd_main.c | 5 +- drivers/block/sunvdc.c | 3 +- drivers/block/swim.c | 3 +- drivers/block/swim3.c | 3 +- drivers/block/sx8.c | 3 +- drivers/block/umem.c | 3 +- drivers/block/virtio_blk.c | 38 ++++++++---- drivers/block/xen-blkfront.c | 3 +- drivers/block/xsysace.c | 3 +- drivers/block/z2ram.c | 3 +- drivers/block/zram/zram_drv.c | 7 +-- drivers/cdrom/gdrom.c | 3 +- drivers/ide/ide-cd.c | 3 +- drivers/ide/ide-gd.c | 3 +- drivers/lightnvm/gennvm.c | 3 +- drivers/md/bcache/super.c | 6 +- drivers/md/dm.c | 3 +- drivers/md/md.c | 5 +- drivers/memstick/core/ms_block.c | 3 +- drivers/memstick/core/mspro_block.c | 3 +- drivers/mmc/card/block.c | 3 +- drivers/mtd/mtd_blkdevs.c | 9 +-- drivers/mtd/ubi/block.c | 3 +- drivers/nvdimm/blk.c | 3 +- drivers/nvdimm/btt.c | 3 +- drivers/nvdimm/pmem.c | 3 +- drivers/nvme/host/core.c | 7 +-- drivers/s390/block/dasd_genhd.c | 3 +- drivers/s390/block/dcssblk.c | 3 +- drivers/s390/block/scm_blk.c | 3 +- drivers/s390/block/xpram.c | 3 +- drivers/sbus/char/jsflash.c | 3 +- drivers/scsi/sd.c | 3 +- drivers/scsi/sr.c | 5 +- drivers/scsi/st.c | 4 +- fs/block_dev.c | 2 +- include/linux/genhd.h | 21 +++---- 66 files changed, 277 insertions(+), 186 deletions(-) -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 01/15] disk: Drop add_disk in favor of device_add_disk
add_disk is now a "convenience" wrapper of device_add_disk. Unwrap it so that callers can be later converted to handle error and attribute group more easily. Callers are converted with coccinelle: @@ expression x; @@ - add_disk(x) + device_add_disk(NULL, x) Removal of add_disk and update of related comments are done manually. Signed-off-by: Fam Zheng <famz at redhat.com> --- arch/m68k/emu/nfblock.c | 2 +- arch/xtensa/platforms/iss/simdisk.c | 2 +- drivers/block/DAC960.c | 2 +- drivers/block/amiflop.c | 2 +- drivers/block/aoe/aoeblk.c | 4 ++-- drivers/block/ataflop.c | 2 +- drivers/block/brd.c | 4 ++-- drivers/block/drbd/drbd_main.c | 2 +- drivers/block/floppy.c | 2 +- drivers/block/hd.c | 2 +- drivers/block/loop.c | 2 +- drivers/block/mg_disk.c | 2 +- drivers/block/nbd.c | 2 +- drivers/block/null_blk.c | 2 +- drivers/block/osdblk.c | 2 +- drivers/block/paride/pcd.c | 2 +- drivers/block/paride/pd.c | 2 +- drivers/block/paride/pf.c | 2 +- drivers/block/pktcdvd.c | 2 +- drivers/block/rbd.c | 2 +- drivers/block/skd_main.c | 2 +- drivers/block/swim.c | 2 +- drivers/block/swim3.c | 2 +- drivers/block/sx8.c | 2 +- drivers/block/umem.c | 2 +- drivers/block/xsysace.c | 2 +- drivers/block/z2ram.c | 2 +- drivers/block/zram/zram_drv.c | 2 +- drivers/cdrom/gdrom.c | 2 +- drivers/lightnvm/gennvm.c | 2 +- drivers/md/bcache/super.c | 4 ++-- drivers/md/dm.c | 2 +- drivers/md/md.c | 4 ++-- drivers/mtd/ubi/block.c | 2 +- drivers/s390/block/xpram.c | 2 +- drivers/sbus/char/jsflash.c | 2 +- drivers/scsi/sr.c | 2 +- drivers/scsi/st.c | 4 ++-- fs/block_dev.c | 2 +- include/linux/genhd.h | 4 ---- 40 files changed, 44 insertions(+), 48 deletions(-) diff --git a/arch/m68k/emu/nfblock.c b/arch/m68k/emu/nfblock.c index e9110b9..573f76d 100644 --- a/arch/m68k/emu/nfblock.c +++ b/arch/m68k/emu/nfblock.c @@ -138,7 +138,7 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize) set_capacity(dev->disk, (sector_t)blocks * (bsize / 512)); dev->disk->queue = dev->queue; - add_disk(dev->disk); + device_add_disk(NULL, dev->disk); list_add_tail(&dev->list, &nfhd_list); diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c index f58a4e6..da000c1 100644 --- a/arch/xtensa/platforms/iss/simdisk.c +++ b/arch/xtensa/platforms/iss/simdisk.c @@ -288,7 +288,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which, dev->gd->private_data = dev; snprintf(dev->gd->disk_name, 32, "simdisk%d", which); set_capacity(dev->gd, 0); - add_disk(dev->gd); + device_add_disk(NULL, dev->gd); dev->procfile = proc_create_data(tmp, 0644, procdir, &fops, dev); return 0; diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 811e11c..9f22a17 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -3175,7 +3175,7 @@ DAC960_Probe(struct pci_dev *dev, const struct pci_device_id *entry) for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) { set_capacity(Controller->disks[disk], disk_size(Controller, disk)); - add_disk(Controller->disks[disk]); + device_add_disk(NULL, Controller->disks[disk]); } DAC960_CreateProcEntries(Controller); return 0; diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 5fd50a2..398a30c 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1738,7 +1738,7 @@ static int __init fd_probe_drives(void) sprintf(disk->disk_name, "fd%d", drive); disk->private_data = &unit[drive]; set_capacity(disk, 880*2); - add_disk(disk); + device_add_disk(NULL, disk); } if ((drives > 0) || (nomem == 0)) { if (drives == 0) diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index ec9d861..24f246b 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -345,7 +345,7 @@ static const struct block_device_operations aoe_bdops = { .owner = THIS_MODULE, }; -/* alloc_disk and add_disk can sleep */ +/* alloc_disk and device_add_disk can sleep */ void aoeblk_gdalloc(void *vp) { @@ -417,7 +417,7 @@ aoeblk_gdalloc(void *vp) spin_unlock_irqrestore(&d->lock, flags); - add_disk(gd); + device_add_disk(NULL, gd); aoedisk_add_sysfs(d); aoedisk_add_debugfs(d); diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 2104b1b..6345731 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1969,7 +1969,7 @@ static int __init atari_floppy_init (void) if (!unit[i].disk->queue) goto Enomem; set_capacity(unit[i].disk, MAX_DISK_SIZE * 2); - add_disk(unit[i].disk); + device_add_disk(NULL, unit[i].disk); } blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 0c76d40..cf98820 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -549,7 +549,7 @@ static struct brd_device *brd_init_one(int i, bool *new) brd = brd_alloc(i); if (brd) { - add_disk(brd->brd_disk); + device_add_disk(NULL, brd->brd_disk); list_add_tail(&brd->brd_list, &brd_devices); } *new = true; @@ -617,7 +617,7 @@ static int __init brd_init(void) /* point of no return */ list_for_each_entry(brd, &brd_devices, brd_list) - add_disk(brd->brd_disk); + device_add_disk(NULL, brd->brd_disk); blk_register_region(MKDEV(RAMDISK_MAJOR, 0), 1UL << MINORBITS, THIS_MODULE, brd_probe, NULL, NULL); diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 100be55..2cc65cd 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2897,7 +2897,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig goto out_idr_remove_vol; } - add_disk(disk); + device_add_disk(NULL, disk); /* inherit the connection state */ device->state.conn = first_connection(resource)->cstate; diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index b71a9c7..627d8ff 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4605,7 +4605,7 @@ static void __exit floppy_module_exit(void) blk_cleanup_queue(disks[drive]->queue); /* - * These disks have not called add_disk(). Don't put down + * These disks have not called device_add_disk(). Don't put down * queue reference in put_disk(). */ if (!(allowed_drive_mask & (1 << drive)) || diff --git a/drivers/block/hd.c b/drivers/block/hd.c index 3abb121..bf1d6f3 100644 --- a/drivers/block/hd.c +++ b/drivers/block/hd.c @@ -767,7 +767,7 @@ static int __init hd_init(void) /* Let them fly */ for (drive = 0; drive < NR_HD; drive++) - add_disk(hd_gendisk[drive]); + device_add_disk(NULL, hd_gendisk[drive]); return 0; diff --git a/drivers/block/loop.c b/drivers/block/loop.c index c9f2107..1d2b75d 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1794,7 +1794,7 @@ static int loop_add(struct loop_device **l, int i) disk->private_data = lo; disk->queue = lo->lo_queue; sprintf(disk->disk_name, "loop%d", i); - add_disk(disk); + device_add_disk(NULL, disk); *l = lo; return lo->lo_number; diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index e937fcf7..23b330e 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -1006,7 +1006,7 @@ static int mg_probe(struct platform_device *plat_dev) set_capacity(host->gd, host->n_sectors); - add_disk(host->gd); + device_add_disk(NULL, host->gd); return err; diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index a9e3980..3b9c194 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1085,7 +1085,7 @@ static int __init nbd_init(void) disk->private_data = &nbd_dev[i]; sprintf(disk->disk_name, "nbd%d", i); nbd_reset(&nbd_dev[i]); - add_disk(disk); + device_add_disk(NULL, disk); } return 0; diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 75a7f88..f90c08e 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -740,7 +740,7 @@ static int null_add_dev(void) disk->queue = nullb->q; strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN); - add_disk(disk); + device_add_disk(NULL, disk); done: mutex_lock(&lock); diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c index 92900f5..e6e9e77 100644 --- a/drivers/block/osdblk.c +++ b/drivers/block/osdblk.c @@ -448,7 +448,7 @@ static int osdblk_init_disk(struct osdblk_device *osdev) /* finally, announce the disk to the world */ set_capacity(disk, obj_size / 512ULL); - add_disk(disk); + device_add_disk(NULL, disk); printk(KERN_INFO "%s: Added of size 0x%llx\n", disk->disk_name, (unsigned long long)obj_size); diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 9336236..87e4886 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c @@ -970,7 +970,7 @@ static int __init pcd_init(void) register_cdrom(&cd->info); cd->disk->private_data = cd; cd->disk->queue = pcd_queue; - add_disk(cd->disk); + device_add_disk(NULL, cd->disk); } } diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 78a39f7..0bc07ad 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -906,7 +906,7 @@ static int pd_detect(void) for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { if (disk->gd) { set_capacity(disk->gd, disk->capacity); - add_disk(disk->gd); + device_add_disk(NULL, disk->gd); found = 1; } } diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index 7a7d977..9e902a5 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -989,7 +989,7 @@ static int __init pf_init(void) continue; disk->private_data = pf; disk->queue = pf_queue; - add_disk(disk); + device_add_disk(NULL, disk); } return 0; } diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 90fa4ac..853a6fc 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2785,7 +2785,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) disk->events = pd->bdev->bd_disk->events; disk->async_events = pd->bdev->bd_disk->async_events; - add_disk(disk); + device_add_disk(NULL, disk); pkt_sysfs_dev_new(pd); pkt_debugfs_dev_new(pd); diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 6c6519f..e1dae3c 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -5160,7 +5160,7 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev) set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); up_write(&rbd_dev->header_rwsem); - add_disk(rbd_dev->disk); + device_add_disk(NULL, rbd_dev->disk); pr_info("%s: added with size 0x%llx\n", rbd_dev->disk->disk_name, (unsigned long long) rbd_dev->mapping.size); diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index 3822eae..a6bd5ca 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -4692,7 +4692,7 @@ static int skd_bdev_getgeo(struct block_device *bdev, struct hd_geometry *geo) static int skd_bdev_attach(struct device *parent, struct skd_device *skdev) { - pr_debug("%s:%s:%d add_disk\n", skdev->name, __func__, __LINE__); + pr_debug("%s:%s:%d device_add_disk\n", skdev->name, __func__, __LINE__); device_add_disk(parent, skdev->disk); return 0; } diff --git a/drivers/block/swim.c b/drivers/block/swim.c index b5afd49..6037b74 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -858,7 +858,7 @@ static int swim_floppy_init(struct swim_priv *swd) swd->unit[drive].disk->private_data = &swd->unit[drive]; swd->unit[drive].disk->queue = swd->queue; set_capacity(swd->unit[drive].disk, 2880); - add_disk(swd->unit[drive].disk); + device_add_disk(NULL, swd->unit[drive].disk); } blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index c264f2d..d6ee4a6 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -1240,7 +1240,7 @@ static int swim3_attach(struct macio_dev *mdev, disk->flags |= GENHD_FL_REMOVABLE; sprintf(disk->disk_name, "fd%d", index); set_capacity(disk, 2880); - add_disk(disk); + device_add_disk(NULL, disk); return 0; } diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index ba4bfe9..d80766c 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -1333,7 +1333,7 @@ static void carm_fsm_task (struct work_struct *work) struct gendisk *disk = port->disk; set_capacity(disk, port->capacity); - add_disk(disk); + device_add_disk(NULL, disk); activated++; } diff --git a/drivers/block/umem.c b/drivers/block/umem.c index be90e15..579fa05 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -1096,7 +1096,7 @@ static int __init mm_init(void) disk->private_data = &cards[i]; disk->queue = cards[i].queue; set_capacity(disk, cards[i].mm_size << 1); - add_disk(disk); + device_add_disk(NULL, disk); } init_battery_timer(); diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index c4328d9..0fe5b28 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c @@ -1057,7 +1057,7 @@ static int ace_setup(struct ace_device *ace) ace_revalidate_disk(ace->gd); /* Make the sysace device 'live' */ - add_disk(ace->gd); + device_add_disk(NULL, ace->gd); return 0; diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 968f9e5..0c4af61 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -364,7 +364,7 @@ z2_init(void) sprintf(z2ram_gendisk->disk_name, "z2ram"); z2ram_gendisk->queue = z2_queue; - add_disk(z2ram_gendisk); + device_add_disk(NULL, z2ram_gendisk); blk_register_region(MKDEV(Z2RAM_MAJOR, 0), Z2MINOR_COUNT, THIS_MODULE, z2_find, NULL, NULL); diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 04365b1..053ea53 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1298,7 +1298,7 @@ static int zram_add(void) zram->disk->queue->limits.discard_zeroes_data = 0; queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zram->disk->queue); - add_disk(zram->disk); + device_add_disk(NULL, zram->disk); ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj, &zram_disk_attr_group); diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index 584bc31..1090205 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -817,7 +817,7 @@ static int probe_gdrom(struct platform_device *devptr) gd.toc = kzalloc(sizeof(struct gdromtoc), GFP_KERNEL); if (!gd.toc) goto probe_fail_toc; - add_disk(gd.disk); + device_add_disk(NULL, gd.disk); return 0; probe_fail_toc: diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index b74174c..f752479 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -90,7 +90,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) blk_queue_max_hw_sectors(tqueue, 8 * dev->ops->max_phys_sect); set_capacity(tdisk, tt->capacity(targetdata)); - add_disk(tdisk); + device_add_disk(NULL, tdisk); t->type = tt; t->disk = tdisk; diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 95a4ca6..5a72f8e 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -866,7 +866,7 @@ void bch_cached_dev_run(struct cached_dev *dc) closure_sync(&cl); } - add_disk(d->disk); + device_add_disk(NULL, d->disk); bd_link_disk_holder(dc->bdev, dc->disk.disk); /* won't show up in the uevent file, use udevadm monitor -e instead * only class / kset properties are persistent */ @@ -1229,7 +1229,7 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u) bcache_device_attach(d, c, u - c->uuids); bch_flash_dev_request_init(d); - add_disk(d->disk); + device_add_disk(NULL, d->disk); if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache")) goto err; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index fa9b1cb..b594364 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1514,7 +1514,7 @@ static struct mapped_device *alloc_dev(int minor) md->disk->queue = md->queue; md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - add_disk(md->disk); + device_add_disk(NULL, md->disk); format_dev_t(md->name, MKDEV(_major, minor)); md->wq = alloc_workqueue("kdmflush", WQ_MEM_RECLAIM, 0); diff --git a/drivers/md/md.c b/drivers/md/md.c index d646f6e..bdc7e1e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5062,11 +5062,11 @@ static int md_alloc(dev_t dev, char *name) */ disk->flags |= GENHD_FL_EXT_DEVT; mddev->gendisk = disk; - /* As soon as we call add_disk(), another thread could get + /* As soon as we call device_add_disk(), another thread could get * through to md_open, so make sure it doesn't get too far */ mutex_lock(&mddev->open_mutex); - add_disk(disk); + device_add_disk(NULL, disk); error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk_to_dev(disk)->kobj, "%s", "md"); diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index ebf46ad..3952ea4 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -445,7 +445,7 @@ int ubiblock_create(struct ubi_volume_info *vi) mutex_unlock(&devices_mutex); /* Must be the last step: anyone can call file ops from now on */ - add_disk(dev->gd); + device_add_disk(NULL, dev->gd); dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)", dev->ubi_num, dev->vol_id, vi->name); return 0; diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c index 288f59a..80c761e 100644 --- a/drivers/s390/block/xpram.c +++ b/drivers/s390/block/xpram.c @@ -377,7 +377,7 @@ static int __init xpram_setup_blkdev(void) disk->queue = xpram_queues[i]; sprintf(disk->disk_name, "slram%d", i); set_capacity(disk, xpram_sizes[i] << 1); - add_disk(disk); + device_add_disk(NULL, disk); } return 0; diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index a40ee1e..ace4859 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c @@ -590,7 +590,7 @@ static int jsfd_init(void) set_capacity(disk, jdp->dsize >> 9); disk->private_data = jdp; disk->queue = jsf_queue; - add_disk(disk); + device_add_disk(NULL, disk); set_disk_ro(disk, 1); } return 0; diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index ed17934..1dd4aaa 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -723,7 +723,7 @@ static int sr_probe(struct device *dev) /* * Initialize block layer runtime PM stuffs before the - * periodic event checking request gets started in add_disk. + * periodic event checking request gets started in device_add_disk. */ blk_pm_runtime_init(sdev->request_queue, dev); diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 7af5226..ebeb1bd 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -4299,8 +4299,8 @@ static int st_probe(struct device *dev) tpnt->disk = disk; disk->private_data = &tpnt->driver; disk->queue = SDp->request_queue; - /* SCSI tape doesn't register this gendisk via add_disk(). Manually - * take queue reference that release_disk() expects. */ + /* SCSI tape doesn't register this gendisk via device_add_disk(). + * Manually take queue reference that release_disk() expects. */ if (!blk_get_queue(disk->queue)) goto out_put_disk; tpnt->driver = &st_template; diff --git a/fs/block_dev.c b/fs/block_dev.c index c3cdde8..336c320d 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1028,7 +1028,7 @@ int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk) WARN_ON_ONCE(!bdev->bd_holder); - /* FIXME: remove the following once add_disk() handles errors */ + /* FIXME: remove the following once device_add_disk() handles errors */ if (WARN_ON(!disk->slave_dir || !bdev->bd_part->holder_dir)) goto out_unlock; diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 1dbf52f..889b1bb 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -414,10 +414,6 @@ extern void part_round_stats(int cpu, struct hd_struct *part); /* block/genhd.c */ extern void device_add_disk(struct device *parent, struct gendisk *disk); -static inline void add_disk(struct gendisk *disk) -{ - device_add_disk(NULL, disk); -} extern void del_gendisk(struct gendisk *gp); extern struct gendisk *get_gendisk(dev_t dev, int *partno); -- 2.7.4
Several operations in register_disk can fail, but the caller currently cannot check for error due to missing return code. Change the function return type and return -errno if any error happens. Also add some documentation. Signed-off-by: Fam Zheng <famz at redhat.com> --- block/genhd.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index fcd6d4f..3dcecaa 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -506,7 +506,15 @@ static int exact_lock(dev_t devt, void *data) return 0; } -static void register_disk(struct device *parent, struct gendisk *disk) +/** + * register_disk - register a gendisk to a parent device + * @parent: parent device for the disk + * @disk: per-device partitioning information + * + * RETURNS: + * 0 on success, -errno on failure. + */ +static int register_disk(struct device *parent, struct gendisk *disk) { struct device *ddev = disk_to_dev(disk); struct block_device *bdev; @@ -521,14 +529,16 @@ static void register_disk(struct device *parent, struct gendisk *disk) /* delay uevents, until we scanned partition table */ dev_set_uevent_suppress(ddev, 1); - if (device_add(ddev)) - return; + err = device_add(ddev); + if (err) + return err; + if (!sysfs_deprecated) { err = sysfs_create_link(block_depr, &ddev->kobj, kobject_name(&ddev->kobj)); if (err) { device_del(ddev); - return; + return err; } } @@ -547,12 +557,16 @@ static void register_disk(struct device *parent, struct gendisk *disk) goto exit; /* No such device (e.g., media were just removed) */ - if (!get_capacity(disk)) + if (!get_capacity(disk)) { + err = -ENOMEDIUM; goto exit; + } bdev = bdget_disk(disk, 0); - if (!bdev) + if (!bdev) { + err = -ENOMEDIUM; goto exit; + } bdev->bd_invalidated = 1; err = blkdev_get(bdev, FMODE_READ, NULL); @@ -570,6 +584,7 @@ exit: while ((part = disk_part_iter_next(&piter))) kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD); disk_part_iter_exit(&piter); + return err; } /** -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 03/15] genhd: Return error from blk_register_region
blk_register_region can fail (-ENOMEM), return the error to the caller. Signed-off-by: Fam Zheng <famz at redhat.com> --- block/genhd.c | 4 ++-- include/linux/genhd.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 3dcecaa..8c7510d 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -474,11 +474,11 @@ static char *bdevt_str(dev_t devt, char *buf) * range must be nonzero * The hash chain is sorted on range, so that subranges can override. */ -void blk_register_region(dev_t devt, unsigned long range, struct module *module, +int blk_register_region(dev_t devt, unsigned long range, struct module *module, struct kobject *(*probe)(dev_t, int *, void *), int (*lock)(dev_t, void *), void *data) { - kobj_map(bdev_map, devt, range, module, probe, lock, data); + return kobj_map(bdev_map, devt, range, module, probe, lock, data); } EXPORT_SYMBOL(blk_register_region); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 889b1bb..b6fd666 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -617,11 +617,11 @@ extern struct gendisk *alloc_disk_node(int minors, int node_id); extern struct gendisk *alloc_disk(int minors); extern struct kobject *get_disk(struct gendisk *disk); extern void put_disk(struct gendisk *disk); -extern void blk_register_region(dev_t devt, unsigned long range, - struct module *module, - struct kobject *(*probe)(dev_t, int *, void *), - int (*lock)(dev_t, void *), - void *data); +extern int blk_register_region(dev_t devt, unsigned long range, + struct module *module, + struct kobject *(*probe)(dev_t, int *, void *), + int (*lock)(dev_t, void *), + void *data); extern void blk_unregister_region(dev_t devt, unsigned long range); extern ssize_t part_size_show(struct device *dev, -- 2.7.4
The kobject_init_and_add call in blk_integrity_add can fail, return the error code in this case, so that it can be handled in the caller. Signed-off-by: Fam Zheng <famz at redhat.com> --- block/blk-integrity.c | 12 ++++++++---- include/linux/genhd.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index d69c5c7..437e09a 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -450,13 +450,17 @@ void blk_integrity_revalidate(struct gendisk *disk) ~BDI_CAP_STABLE_WRITES; } -void blk_integrity_add(struct gendisk *disk) +int blk_integrity_add(struct gendisk *disk) { - if (kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype, - &disk_to_dev(disk)->kobj, "%s", "integrity")) - return; + int rc; + + rc = kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype, + &disk_to_dev(disk)->kobj, "%s", "integrity"); + if (rc) + return rc; kobject_uevent(&disk->integrity_kobj, KOBJ_ADD); + return 0; } void blk_integrity_del(struct gendisk *disk) diff --git a/include/linux/genhd.h b/include/linux/genhd.h index b6fd666..85ce560 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -725,11 +725,11 @@ static inline void part_nr_sects_write(struct hd_struct *part, sector_t size) } #if defined(CONFIG_BLK_DEV_INTEGRITY) -extern void blk_integrity_add(struct gendisk *); +extern int blk_integrity_add(struct gendisk *); extern void blk_integrity_del(struct gendisk *); extern void blk_integrity_revalidate(struct gendisk *); #else /* CONFIG_BLK_DEV_INTEGRITY */ -static inline void blk_integrity_add(struct gendisk *disk) { } +static inline int blk_integrity_add(struct gendisk *disk) { return 0; } static inline void blk_integrity_del(struct gendisk *disk) { } static inline void blk_integrity_revalidate(struct gendisk *disk) { } #endif /* CONFIG_BLK_DEV_INTEGRITY */ -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 05/15] genhd: Return error from disk_{add,alloc}_events
disk_alloc_events and disk_add_events can fail, return the error code so the caller can handle it. Signed-off-by: Fam Zheng <famz at redhat.com> --- block/genhd.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 8c7510d..4316d2d 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -40,8 +40,8 @@ static struct device_type disk_type; static void disk_check_events(struct disk_events *ev, unsigned int *clearing_ptr); -static void disk_alloc_events(struct gendisk *disk); -static void disk_add_events(struct gendisk *disk); +static int disk_alloc_events(struct gendisk *disk); +static int disk_add_events(struct gendisk *disk); static void disk_del_events(struct gendisk *disk); static void disk_release_events(struct gendisk *disk); @@ -1823,17 +1823,17 @@ module_param_cb(events_dfl_poll_msecs, &disk_events_dfl_poll_msecs_param_ops, /* * disk_{alloc|add|del|release}_events - initialize and destroy disk_events. */ -static void disk_alloc_events(struct gendisk *disk) +static int disk_alloc_events(struct gendisk *disk) { struct disk_events *ev; if (!disk->fops->check_events) - return; + return 0; ev = kzalloc(sizeof(*ev), GFP_KERNEL); if (!ev) { pr_warn("%s: failed to initialize events\n", disk->disk_name); - return; + return -ENOMEM; } INIT_LIST_HEAD(&ev->node); @@ -1845,17 +1845,22 @@ static void disk_alloc_events(struct gendisk *disk) INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn); disk->ev = ev; + return 0; } -static void disk_add_events(struct gendisk *disk) +static int disk_add_events(struct gendisk *disk) { + int rc; + if (!disk->ev) - return; + return 0; - /* FIXME: error handling */ - if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) < 0) + rc = sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs); + if (rc) { pr_warn("%s: failed to create sysfs files for events\n", disk->disk_name); + return rc; + } mutex_lock(&disk_events_mutex); list_add_tail(&disk->ev->node, &disk_events); @@ -1866,6 +1871,7 @@ static void disk_add_events(struct gendisk *disk) * unblock kicks it into action. */ __disk_unblock_events(disk, true); + return 0; } static void disk_del_events(struct gendisk *disk) -- 2.7.4
There are a number of places in device_add_disk that can fail, and even more to come as we extend it. Switch the return type of the function, and return the error code when error happens. The WARN_ON is kept because callers are not updated to check the error yet. Signed-off-by: Fam Zheng <famz at redhat.com> --- block/genhd.c | 49 ++++++++++++++++++++++++++++++++++--------------- include/linux/genhd.h | 2 +- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 4316d2d..ffb3929 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -595,9 +595,10 @@ exit: * This function registers the partitioning information in @disk * with the kernel. * - * FIXME: error handling + * RETURNS: + * 0 on success, -errno on failure. */ -void device_add_disk(struct device *parent, struct gendisk *disk) +int device_add_disk(struct device *parent, struct gendisk *disk) { struct backing_dev_info *bdi; dev_t devt; @@ -613,10 +614,8 @@ void device_add_disk(struct device *parent, struct gendisk *disk) disk->flags |= GENHD_FL_UP; retval = blk_alloc_devt(&disk->part0, &devt); - if (retval) { - WARN_ON(1); - return; - } + if (retval) + goto fail; disk_to_dev(disk)->devt = devt; /* ->major and ->first_minor aren't supposed to be @@ -625,16 +624,26 @@ void device_add_disk(struct device *parent, struct gendisk *disk) disk->major = MAJOR(devt); disk->first_minor = MINOR(devt); - disk_alloc_events(disk); + retval = disk_alloc_events(disk); + if (retval) + goto fail; /* Register BDI before referencing it from bdev */ bdi = &disk->queue->backing_dev_info; - bdi_register_owner(bdi, disk_to_dev(disk)); + retval = bdi_register_owner(bdi, disk_to_dev(disk)); + if (retval) + goto fail; - blk_register_region(disk_devt(disk), disk->minors, NULL, - exact_match, exact_lock, disk); - register_disk(parent, disk); - blk_register_queue(disk); + retval = blk_register_region(disk_devt(disk), disk->minors, NULL, + exact_match, exact_lock, disk); + if (retval) + goto fail; + retval = register_disk(parent, disk); + if (retval) + goto fail; + retval = blk_register_queue(disk); + if (retval) + goto fail; /* * Take an extra ref on queue which will be put on disk_release() @@ -644,10 +653,20 @@ void device_add_disk(struct device *parent, struct gendisk *disk) retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj, "bdi"); + if (retval) + goto fail; + + retval = disk_add_events(disk); + if (retval) + goto fail; + + retval = blk_integrity_add(disk); + if (retval) + goto fail; + return 0; +fail: WARN_ON(retval); - - disk_add_events(disk); - blk_integrity_add(disk); + return retval; } EXPORT_SYMBOL(device_add_disk); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 85ce560..991b5ff 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -413,7 +413,7 @@ static inline void free_part_info(struct hd_struct *part) extern void part_round_stats(int cpu, struct hd_struct *part); /* block/genhd.c */ -extern void device_add_disk(struct device *parent, struct gendisk *disk); +extern int device_add_disk(struct device *parent, struct gendisk *disk); extern void del_gendisk(struct gendisk *gp); extern struct gendisk *get_gendisk(dev_t dev, int *partno); -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 07/15] genhd: Add attribute group parameter to device_add_disk
The added parameter attr_group, if not NULL, be added to the new disk. The callers are converted with coccinelle: @@ expression e1, e2; @@ - device_add_disk(e1, e2); + device_add_disk(e1, e2, NULL); So there is not behavior change yet. Signed-off-by: Fam Zheng <famz at redhat.com> --- arch/m68k/emu/nfblock.c | 2 +- arch/powerpc/sysdev/axonram.c | 2 +- arch/um/drivers/ubd_kern.c | 2 +- arch/xtensa/platforms/iss/simdisk.c | 2 +- block/genhd.c | 10 +++++++++- drivers/block/DAC960.c | 2 +- drivers/block/amiflop.c | 2 +- drivers/block/aoe/aoeblk.c | 2 +- drivers/block/ataflop.c | 2 +- drivers/block/brd.c | 4 ++-- drivers/block/cciss.c | 2 +- drivers/block/drbd/drbd_main.c | 2 +- drivers/block/floppy.c | 2 +- drivers/block/hd.c | 2 +- drivers/block/loop.c | 2 +- drivers/block/mg_disk.c | 2 +- drivers/block/mtip32xx/mtip32xx.c | 2 +- drivers/block/nbd.c | 2 +- drivers/block/null_blk.c | 2 +- drivers/block/osdblk.c | 2 +- drivers/block/paride/pcd.c | 2 +- drivers/block/paride/pd.c | 2 +- drivers/block/paride/pf.c | 2 +- drivers/block/pktcdvd.c | 2 +- drivers/block/ps3disk.c | 2 +- drivers/block/ps3vram.c | 2 +- drivers/block/rbd.c | 2 +- drivers/block/rsxx/dev.c | 2 +- drivers/block/skd_main.c | 2 +- drivers/block/sunvdc.c | 2 +- drivers/block/swim.c | 2 +- drivers/block/swim3.c | 2 +- drivers/block/sx8.c | 2 +- drivers/block/umem.c | 2 +- drivers/block/virtio_blk.c | 2 +- drivers/block/xen-blkfront.c | 2 +- drivers/block/xsysace.c | 2 +- drivers/block/z2ram.c | 2 +- drivers/block/zram/zram_drv.c | 2 +- drivers/cdrom/gdrom.c | 2 +- drivers/ide/ide-cd.c | 2 +- drivers/ide/ide-gd.c | 2 +- drivers/lightnvm/gennvm.c | 2 +- drivers/md/bcache/super.c | 4 ++-- drivers/md/dm.c | 2 +- drivers/md/md.c | 2 +- drivers/memstick/core/ms_block.c | 2 +- drivers/memstick/core/mspro_block.c | 2 +- drivers/mmc/card/block.c | 2 +- drivers/mtd/mtd_blkdevs.c | 2 +- drivers/mtd/ubi/block.c | 2 +- drivers/nvdimm/blk.c | 2 +- drivers/nvdimm/btt.c | 2 +- drivers/nvdimm/pmem.c | 2 +- drivers/nvme/host/core.c | 2 +- drivers/s390/block/dasd_genhd.c | 2 +- drivers/s390/block/dcssblk.c | 2 +- drivers/s390/block/scm_blk.c | 2 +- drivers/s390/block/xpram.c | 2 +- drivers/sbus/char/jsflash.c | 2 +- drivers/scsi/sd.c | 2 +- drivers/scsi/sr.c | 2 +- include/linux/genhd.h | 3 ++- 63 files changed, 74 insertions(+), 65 deletions(-) diff --git a/arch/m68k/emu/nfblock.c b/arch/m68k/emu/nfblock.c index 573f76d..29dfdd6 100644 --- a/arch/m68k/emu/nfblock.c +++ b/arch/m68k/emu/nfblock.c @@ -138,7 +138,7 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize) set_capacity(dev->disk, (sector_t)blocks * (bsize / 512)); dev->disk->queue = dev->queue; - device_add_disk(NULL, dev->disk); + device_add_disk(NULL, dev->disk, NULL); list_add_tail(&dev->list, &nfhd_list); diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c index 9144204..6aef6c2 100644 --- a/arch/powerpc/sysdev/axonram.c +++ b/arch/powerpc/sysdev/axonram.c @@ -237,7 +237,7 @@ static int axon_ram_probe(struct platform_device *device) set_capacity(bank->disk, bank->size >> AXON_RAM_SECTOR_SHIFT); blk_queue_make_request(bank->disk->queue, axon_ram_make_request); blk_queue_logical_block_size(bank->disk->queue, AXON_RAM_SECTOR_SIZE); - device_add_disk(&device->dev, bank->disk); + device_add_disk(&device->dev, bank->disk, NULL); bank->irq_id = irq_of_parse_and_map(device->dev.of_node, 0); if (bank->irq_id == NO_IRQ) { diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index f354027..45bbca5 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -829,7 +829,7 @@ static int ubd_disk_register(int major, u64 size, int unit, disk->private_data = &ubd_devs[unit]; disk->queue = ubd_devs[unit].queue; - device_add_disk(parent, disk); + device_add_disk(parent, disk, NULL); *disk_out = disk; return 0; diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c index da000c1..6a3d8c3 100644 --- a/arch/xtensa/platforms/iss/simdisk.c +++ b/arch/xtensa/platforms/iss/simdisk.c @@ -288,7 +288,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which, dev->gd->private_data = dev; snprintf(dev->gd->disk_name, 32, "simdisk%d", which); set_capacity(dev->gd, 0); - device_add_disk(NULL, dev->gd); + device_add_disk(NULL, dev->gd, NULL); dev->procfile = proc_create_data(tmp, 0644, procdir, &fops, dev); return 0; diff --git a/block/genhd.c b/block/genhd.c index ffb3929..a2092e0 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -598,7 +598,8 @@ exit: * RETURNS: * 0 on success, -errno on failure. */ -int device_add_disk(struct device *parent, struct gendisk *disk) +int device_add_disk(struct device *parent, struct gendisk *disk, + struct attribute_group *attr_group) { struct backing_dev_info *bdi; dev_t devt; @@ -660,6 +661,13 @@ int device_add_disk(struct device *parent, struct gendisk *disk) if (retval) goto fail; + if (attr_group) { + retval = sysfs_create_group(&disk_to_dev(disk)->kobj, + attr_group); + if (retval) + goto fail; + } + retval = blk_integrity_add(disk); if (retval) goto fail; diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 9f22a17..abaab30 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -3175,7 +3175,7 @@ DAC960_Probe(struct pci_dev *dev, const struct pci_device_id *entry) for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) { set_capacity(Controller->disks[disk], disk_size(Controller, disk)); - device_add_disk(NULL, Controller->disks[disk]); + device_add_disk(NULL, Controller->disks[disk], NULL); } DAC960_CreateProcEntries(Controller); return 0; diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 398a30c..f00d3b4 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1738,7 +1738,7 @@ static int __init fd_probe_drives(void) sprintf(disk->disk_name, "fd%d", drive); disk->private_data = &unit[drive]; set_capacity(disk, 880*2); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); } if ((drives > 0) || (nomem == 0)) { if (drives == 0) diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 24f246b..4edfff2 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -417,7 +417,7 @@ aoeblk_gdalloc(void *vp) spin_unlock_irqrestore(&d->lock, flags); - device_add_disk(NULL, gd); + device_add_disk(NULL, gd, NULL); aoedisk_add_sysfs(d); aoedisk_add_debugfs(d); diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 6345731..0587aa36 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1969,7 +1969,7 @@ static int __init atari_floppy_init (void) if (!unit[i].disk->queue) goto Enomem; set_capacity(unit[i].disk, MAX_DISK_SIZE * 2); - device_add_disk(NULL, unit[i].disk); + device_add_disk(NULL, unit[i].disk, NULL); } blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, diff --git a/drivers/block/brd.c b/drivers/block/brd.c index cf98820..99f6444 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -549,7 +549,7 @@ static struct brd_device *brd_init_one(int i, bool *new) brd = brd_alloc(i); if (brd) { - device_add_disk(NULL, brd->brd_disk); + device_add_disk(NULL, brd->brd_disk, NULL); list_add_tail(&brd->brd_list, &brd_devices); } *new = true; @@ -617,7 +617,7 @@ static int __init brd_init(void) /* point of no return */ list_for_each_entry(brd, &brd_devices, brd_list) - device_add_disk(NULL, brd->brd_disk); + device_add_disk(NULL, brd->brd_disk, NULL); blk_register_region(MKDEV(RAMDISK_MAJOR, 0), 1UL << MINORBITS, THIS_MODULE, brd_probe, NULL, NULL); diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index db9d6bb..bef9f7f 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1972,7 +1972,7 @@ static int cciss_add_disk(ctlr_info_t *h, struct gendisk *disk, /* allows the interrupt handler to start the queue */ wmb(); h->drv[drv_index]->queue = disk->queue; - device_add_disk(&h->drv[drv_index]->dev, disk); + device_add_disk(&h->drv[drv_index]->dev, disk, NULL); return 0; cleanup_queue: diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 2cc65cd..47aee0e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2897,7 +2897,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig goto out_idr_remove_vol; } - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); /* inherit the connection state */ device->state.conn = first_connection(resource)->cstate; diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 627d8ff..952cad1 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4347,7 +4347,7 @@ static int __init do_floppy_init(void) /* to be cleaned up... */ disks[drive]->private_data = (void *)(long)drive; disks[drive]->flags |= GENHD_FL_REMOVABLE; - device_add_disk(&floppy_device[drive].dev, disks[drive]); + device_add_disk(&floppy_device[drive].dev, disks[drive], NULL); } return 0; diff --git a/drivers/block/hd.c b/drivers/block/hd.c index bf1d6f3..eeb5085 100644 --- a/drivers/block/hd.c +++ b/drivers/block/hd.c @@ -767,7 +767,7 @@ static int __init hd_init(void) /* Let them fly */ for (drive = 0; drive < NR_HD; drive++) - device_add_disk(NULL, hd_gendisk[drive]); + device_add_disk(NULL, hd_gendisk[drive], NULL); return 0; diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 1d2b75d..3c5ad19 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1794,7 +1794,7 @@ static int loop_add(struct loop_device **l, int i) disk->private_data = lo; disk->queue = lo->lo_queue; sprintf(disk->disk_name, "loop%d", i); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); *l = lo; return lo->lo_number; diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index 23b330e..48c67f6 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -1006,7 +1006,7 @@ static int mg_probe(struct platform_device *plat_dev) set_capacity(host->gd, host->n_sectors); - device_add_disk(NULL, host->gd); + device_add_disk(NULL, host->gd, NULL); return err; diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 2aca98e..4048a70 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -4041,7 +4041,7 @@ skip_create_disk: set_capacity(dd->disk, capacity); /* Enable the block device and add it to /dev */ - device_add_disk(&dd->pdev->dev, dd->disk); + device_add_disk(&dd->pdev->dev, dd->disk, NULL); dd->bdev = bdget_disk(dd->disk, 0); /* diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 3b9c194..c31a7df 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1085,7 +1085,7 @@ static int __init nbd_init(void) disk->private_data = &nbd_dev[i]; sprintf(disk->disk_name, "nbd%d", i); nbd_reset(&nbd_dev[i]); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); } return 0; diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index f90c08e..61a7f69 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -740,7 +740,7 @@ static int null_add_dev(void) disk->queue = nullb->q; strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); done: mutex_lock(&lock); diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c index e6e9e77..5683ef4 100644 --- a/drivers/block/osdblk.c +++ b/drivers/block/osdblk.c @@ -448,7 +448,7 @@ static int osdblk_init_disk(struct osdblk_device *osdev) /* finally, announce the disk to the world */ set_capacity(disk, obj_size / 512ULL); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); printk(KERN_INFO "%s: Added of size 0x%llx\n", disk->disk_name, (unsigned long long)obj_size); diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 87e4886..32920f8 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c @@ -970,7 +970,7 @@ static int __init pcd_init(void) register_cdrom(&cd->info); cd->disk->private_data = cd; cd->disk->queue = pcd_queue; - device_add_disk(NULL, cd->disk); + device_add_disk(NULL, cd->disk, NULL); } } diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 0bc07ad..3901529 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -906,7 +906,7 @@ static int pd_detect(void) for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { if (disk->gd) { set_capacity(disk->gd, disk->capacity); - device_add_disk(NULL, disk->gd); + device_add_disk(NULL, disk->gd, NULL); found = 1; } } diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index 9e902a5..c7b2f13 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -989,7 +989,7 @@ static int __init pf_init(void) continue; disk->private_data = pf; disk->queue = pf_queue; - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); } return 0; } diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 853a6fc..3ebec28 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2785,7 +2785,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) disk->events = pd->bdev->bd_disk->events; disk->async_events = pd->bdev->bd_disk->async_events; - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); pkt_sysfs_dev_new(pd); pkt_debugfs_dev_new(pd); diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index 76f33c8..2fdeabc 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c @@ -498,7 +498,7 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev) gendisk->disk_name, priv->model, priv->raw_capacity >> 11, get_capacity(gendisk) >> 11); - device_add_disk(&dev->sbd.core, gendisk); + device_add_disk(&dev->sbd.core, gendisk, NULL); return 0; fail_cleanup_queue: diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 456b4fe..49a2699 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -779,7 +779,7 @@ static int ps3vram_probe(struct ps3_system_bus_device *dev) dev_info(&dev->core, "%s: Using %lu MiB of GPU memory\n", gendisk->disk_name, get_capacity(gendisk) >> 11); - device_add_disk(&dev->core, gendisk); + device_add_disk(&dev->core, gendisk, NULL); return 0; fail_cleanup_queue: diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index e1dae3c..77114cd 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -5160,7 +5160,7 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev) set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); up_write(&rbd_dev->header_rwsem); - device_add_disk(NULL, rbd_dev->disk); + device_add_disk(NULL, rbd_dev->disk, NULL); pr_info("%s: added with size 0x%llx\n", rbd_dev->disk->disk_name, (unsigned long long) rbd_dev->mapping.size); diff --git a/drivers/block/rsxx/dev.c b/drivers/block/rsxx/dev.c index f81d70b..bc26e23 100644 --- a/drivers/block/rsxx/dev.c +++ b/drivers/block/rsxx/dev.c @@ -230,7 +230,7 @@ int rsxx_attach_dev(struct rsxx_cardinfo *card) set_capacity(card->gendisk, card->size8 >> 9); else set_capacity(card->gendisk, 0); - device_add_disk(CARD_TO_DEV(card), card->gendisk); + device_add_disk(CARD_TO_DEV(card), card->gendisk, NULL); card->bdev_attached = 1; } diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index a6bd5ca..4187060 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -4693,7 +4693,7 @@ static int skd_bdev_getgeo(struct block_device *bdev, struct hd_geometry *geo) static int skd_bdev_attach(struct device *parent, struct skd_device *skdev) { pr_debug("%s:%s:%d device_add_disk\n", skdev->name, __func__, __LINE__); - device_add_disk(parent, skdev->disk); + device_add_disk(parent, skdev->disk, NULL); return 0; } diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index cab1573..197c133 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -834,7 +834,7 @@ static int probe_disk(struct vdc_port *port) port->vdisk_size, (port->vdisk_size >> (20 - 9)), port->vio.ver.major, port->vio.ver.minor); - device_add_disk(&port->vio.vdev->dev, g); + device_add_disk(&port->vio.vdev->dev, g, NULL); return 0; } diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 6037b74..a4d3e30 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -858,7 +858,7 @@ static int swim_floppy_init(struct swim_priv *swd) swd->unit[drive].disk->private_data = &swd->unit[drive]; swd->unit[drive].disk->queue = swd->queue; set_capacity(swd->unit[drive].disk, 2880); - device_add_disk(NULL, swd->unit[drive].disk); + device_add_disk(NULL, swd->unit[drive].disk, NULL); } blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index d6ee4a6..39ad51e 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -1240,7 +1240,7 @@ static int swim3_attach(struct macio_dev *mdev, disk->flags |= GENHD_FL_REMOVABLE; sprintf(disk->disk_name, "fd%d", index); set_capacity(disk, 2880); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); return 0; } diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index d80766c..507dea8 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -1333,7 +1333,7 @@ static void carm_fsm_task (struct work_struct *work) struct gendisk *disk = port->disk; set_capacity(disk, port->capacity); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); activated++; } diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 579fa05..44cb01d 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -1096,7 +1096,7 @@ static int __init mm_init(void) disk->private_data = &cards[i]; disk->queue = cards[i].queue; set_capacity(disk, cards[i].mm_size << 1); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); } init_battery_timer(); diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 93b1aaa..4564df5 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -719,7 +719,7 @@ static int virtblk_probe(struct virtio_device *vdev) virtio_device_ready(vdev); - device_add_disk(&vdev->dev, vblk->disk); + device_add_disk(&vdev->dev, vblk->disk, NULL); err = device_create_file(disk_to_dev(vblk->disk), &dev_attr_serial); if (err) goto out_del_disk; diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index be4fea6..2c1fe8d 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2442,7 +2442,7 @@ static void blkfront_connect(struct blkfront_info *info) for (i = 0; i < info->nr_rings; i++) kick_pending_request_queues(&info->rinfo[i]); - device_add_disk(&info->xbdev->dev, info->gd); + device_add_disk(&info->xbdev->dev, info->gd, NULL); info->is_ready = 1; } diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index 0fe5b28..edafc73 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c @@ -1057,7 +1057,7 @@ static int ace_setup(struct ace_device *ace) ace_revalidate_disk(ace->gd); /* Make the sysace device 'live' */ - device_add_disk(NULL, ace->gd); + device_add_disk(NULL, ace->gd, NULL); return 0; diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 0c4af61..19b7188 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -364,7 +364,7 @@ z2_init(void) sprintf(z2ram_gendisk->disk_name, "z2ram"); z2ram_gendisk->queue = z2_queue; - device_add_disk(NULL, z2ram_gendisk); + device_add_disk(NULL, z2ram_gendisk, NULL); blk_register_region(MKDEV(Z2RAM_MAJOR, 0), Z2MINOR_COUNT, THIS_MODULE, z2_find, NULL, NULL); diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 053ea53..20920a2 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1298,7 +1298,7 @@ static int zram_add(void) zram->disk->queue->limits.discard_zeroes_data = 0; queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zram->disk->queue); - device_add_disk(NULL, zram->disk); + device_add_disk(NULL, zram->disk, NULL); ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj, &zram_disk_attr_group); diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index 1090205..89f4028 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -817,7 +817,7 @@ static int probe_gdrom(struct platform_device *devptr) gd.toc = kzalloc(sizeof(struct gdromtoc), GFP_KERNEL); if (!gd.toc) goto probe_fail_toc; - device_add_disk(NULL, gd.disk); + device_add_disk(NULL, gd.disk, NULL); return 0; probe_fail_toc: diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index bf9a2ad..0e16085 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1779,7 +1779,7 @@ static int ide_cd_probe(ide_drive_t *drive) ide_cd_read_toc(drive, &sense); g->fops = &idecd_ops; g->flags |= GENHD_FL_REMOVABLE | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; - device_add_disk(&drive->gendev, g); + device_add_disk(&drive->gendev, g, NULL); return 0; out_free_disk: diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index e823394..04e008e 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c @@ -416,7 +416,7 @@ static int ide_gd_probe(ide_drive_t *drive) if (drive->dev_flags & IDE_DFLAG_REMOVABLE) g->flags = GENHD_FL_REMOVABLE; g->fops = &ide_gd_ops; - device_add_disk(&drive->gendev, g); + device_add_disk(&drive->gendev, g, NULL); return 0; out_free_disk: diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index f752479..08c6cdf 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -90,7 +90,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) blk_queue_max_hw_sectors(tqueue, 8 * dev->ops->max_phys_sect); set_capacity(tdisk, tt->capacity(targetdata)); - device_add_disk(NULL, tdisk); + device_add_disk(NULL, tdisk, NULL); t->type = tt; t->disk = tdisk; diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 5a72f8e..071465a 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -866,7 +866,7 @@ void bch_cached_dev_run(struct cached_dev *dc) closure_sync(&cl); } - device_add_disk(NULL, d->disk); + device_add_disk(NULL, d->disk, NULL); bd_link_disk_holder(dc->bdev, dc->disk.disk); /* won't show up in the uevent file, use udevadm monitor -e instead * only class / kset properties are persistent */ @@ -1229,7 +1229,7 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u) bcache_device_attach(d, c, u - c->uuids); bch_flash_dev_request_init(d); - device_add_disk(NULL, d->disk); + device_add_disk(NULL, d->disk, NULL); if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache")) goto err; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index b594364..8ba15b5 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1514,7 +1514,7 @@ static struct mapped_device *alloc_dev(int minor) md->disk->queue = md->queue; md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - device_add_disk(NULL, md->disk); + device_add_disk(NULL, md->disk, NULL); format_dev_t(md->name, MKDEV(_major, minor)); md->wq = alloc_workqueue("kdmflush", WQ_MEM_RECLAIM, 0); diff --git a/drivers/md/md.c b/drivers/md/md.c index bdc7e1e..16fe7e7 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5066,7 +5066,7 @@ static int md_alloc(dev_t dev, char *name) * through to md_open, so make sure it doesn't get too far */ mutex_lock(&mddev->open_mutex); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk_to_dev(disk)->kobj, "%s", "md"); diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c index aacf584..d5e6c3c 100644 --- a/drivers/memstick/core/ms_block.c +++ b/drivers/memstick/core/ms_block.c @@ -2161,7 +2161,7 @@ static int msb_init_disk(struct memstick_dev *card) set_disk_ro(msb->disk, 1); msb_start(card); - device_add_disk(&card->dev, msb->disk); + device_add_disk(&card->dev, msb->disk, NULL); dbg("Disk added"); return 0; diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index c147227..e26a2b80 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c @@ -1253,7 +1253,7 @@ static int mspro_block_init_disk(struct memstick_dev *card) set_capacity(msb->disk, capacity); dev_dbg(&card->dev, "capacity set %ld\n", capacity); - device_add_disk(&card->dev, msb->disk); + device_add_disk(&card->dev, msb->disk, NULL); msb->active = 1; return 0; diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 48a5dd7..9030023 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2460,7 +2460,7 @@ static int mmc_add_disk(struct mmc_blk_data *md) int ret; struct mmc_card *card = md->queue.card; - device_add_disk(md->parent, md->disk); + device_add_disk(md->parent, md->disk, NULL); md->force_ro.show = force_ro_show; md->force_ro.store = force_ro_store; sysfs_attr_init(&md->force_ro.attr); diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 8d58acf..4ff9381 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -434,7 +434,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) if (new->readonly) set_disk_ro(gd, 1); - device_add_disk(&new->mtd->dev, gd); + device_add_disk(&new->mtd->dev, gd, NULL); if (new->disk_attributes) { ret = sysfs_create_group(&disk_to_dev(gd)->kobj, diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 3952ea4..979e4d4 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -445,7 +445,7 @@ int ubiblock_create(struct ubi_volume_info *vi) mutex_unlock(&devices_mutex); /* Must be the last step: anyone can call file ops from now on */ - device_add_disk(NULL, dev->gd); + device_add_disk(NULL, dev->gd, NULL); dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)", dev->ubi_num, dev->vol_id, vi->name); return 0; diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c index 9faaa96..cb74017 100644 --- a/drivers/nvdimm/blk.c +++ b/drivers/nvdimm/blk.c @@ -287,7 +287,7 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk) disk->flags = GENHD_FL_EXT_DEVT; nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name); set_capacity(disk, 0); - device_add_disk(dev, disk); + device_add_disk(dev, disk, NULL); if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk)) return -ENOMEM; diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 368795a..8e97bc9 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1257,7 +1257,7 @@ static int btt_blk_init(struct btt *btt) btt->btt_queue->queuedata = btt; set_capacity(btt->btt_disk, 0); - device_add_disk(&btt->nd_btt->dev, btt->btt_disk); + device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL); if (btt_meta_size(btt)) { int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt)); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 571a6c7..7f3f611 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -309,7 +309,7 @@ static int pmem_attach_disk(struct device *dev, return -ENOMEM; nvdimm_badblocks_populate(nd_region, &pmem->bb, res); disk->bb = &pmem->bb; - device_add_disk(dev, disk); + device_add_disk(dev, disk, NULL); if (devm_add_action_or_reset(dev, pmem_release_disk, disk)) return -ENOMEM; diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 7ff2e82..23a795f 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1686,7 +1686,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) if (ns->type == NVME_NS_LIGHTNVM) return; - device_add_disk(ctrl->device, ns->disk); + device_add_disk(ctrl->device, ns->disk, NULL); if (sysfs_create_group(&disk_to_dev(ns->disk)->kobj, &nvme_ns_attr_group)) pr_warn("%s: failed to create sysfs group for identification\n", diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c index e2fa759..cf5e081 100644 --- a/drivers/s390/block/dasd_genhd.c +++ b/drivers/s390/block/dasd_genhd.c @@ -75,7 +75,7 @@ int dasd_gendisk_alloc(struct dasd_block *block) gdp->queue = block->request_queue; block->gdp = gdp; set_capacity(block->gdp, 0); - device_add_disk(&base->cdev->dev, block->gdp); + device_add_disk(&base->cdev->dev, block->gdp, NULL); return 0; } diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 9d66b4f..376e0fd 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -655,7 +655,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char goto put_dev; get_device(&dev_info->dev); - device_add_disk(&dev_info->dev, dev_info->gd); + device_add_disk(&dev_info->dev, dev_info->gd, NULL); switch (dev_info->segment_type) { case SEG_TYPE_SR: diff --git a/drivers/s390/block/scm_blk.c b/drivers/s390/block/scm_blk.c index 9f16ea6..6dba6eb 100644 --- a/drivers/s390/block/scm_blk.c +++ b/drivers/s390/block/scm_blk.c @@ -530,7 +530,7 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev) /* 512 byte sectors */ set_capacity(bdev->gendisk, scmdev->size >> 9); - device_add_disk(&scmdev->dev, bdev->gendisk); + device_add_disk(&scmdev->dev, bdev->gendisk, NULL); return 0; out_queue: diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c index 80c761e..65cca0a 100644 --- a/drivers/s390/block/xpram.c +++ b/drivers/s390/block/xpram.c @@ -377,7 +377,7 @@ static int __init xpram_setup_blkdev(void) disk->queue = xpram_queues[i]; sprintf(disk->disk_name, "slram%d", i); set_capacity(disk, xpram_sizes[i] << 1); - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); } return 0; diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index ace4859..1c823fa 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c @@ -590,7 +590,7 @@ static int jsfd_init(void) set_capacity(disk, jdp->dsize >> 9); disk->private_data = jdp; disk->queue = jsf_queue; - device_add_disk(NULL, disk); + device_add_disk(NULL, disk, NULL); set_disk_ro(disk, 1); } return 0; diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index d3e852a..eb8e67f 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3000,7 +3000,7 @@ static void sd_probe_async(void *data, async_cookie_t cookie) } blk_pm_runtime_init(sdp->request_queue, dev); - device_add_disk(dev, gd); + device_add_disk(dev, gd, NULL); if (sdkp->capacity) sd_dif_config_host(sdkp); diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 1dd4aaa..e9619a6 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -729,7 +729,7 @@ static int sr_probe(struct device *dev) dev_set_drvdata(dev, cd); disk->flags |= GENHD_FL_REMOVABLE; - device_add_disk(&sdev->sdev_gendev, disk); + device_add_disk(&sdev->sdev_gendev, disk, NULL); sdev_printk(KERN_DEBUG, sdev, "Attached scsi CD-ROM %s\n", cd->cdi.name); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 991b5ff..510e332 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -413,7 +413,8 @@ static inline void free_part_info(struct hd_struct *part) extern void part_round_stats(int cpu, struct hd_struct *part); /* block/genhd.c */ -extern int device_add_disk(struct device *parent, struct gendisk *disk); +extern int device_add_disk(struct device *parent, struct gendisk *disk, + struct attribute_group *attr_group); extern void del_gendisk(struct gendisk *gp); extern struct gendisk *get_gendisk(dev_t dev, int *partno); -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 08/15] nvme: Pass attribute group to device_add_disk
Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Signed-off-by: Fam Zheng <famz at redhat.com> --- drivers/nvme/host/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 23a795f..1921cb2 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1686,11 +1686,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) if (ns->type == NVME_NS_LIGHTNVM) return; - device_add_disk(ctrl->device, ns->disk, NULL); - if (sysfs_create_group(&disk_to_dev(ns->disk)->kobj, - &nvme_ns_attr_group)) - pr_warn("%s: failed to create sysfs group for identification\n", - ns->disk->disk_name); + device_add_disk(ctrl->device, ns->disk, &nvme_ns_attr_group); return; out_free_disk: kfree(disk); -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 09/15] virtio-blk: Pass attribute group to device_add_disk
Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Meanwhile, handle error of device_add_disk. Signed-off-by: Fam Zheng <famz at redhat.com> --- drivers/block/virtio_blk.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 4564df5..ff60d82 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -522,10 +522,10 @@ virtblk_cache_type_show(struct device *dev, struct device_attribute *attr, return snprintf(buf, 40, "%s\n", virtblk_cache_types[writeback]); } -static const struct device_attribute dev_attr_cache_type_ro +static struct device_attribute dev_attr_cache_type_ro __ATTR(cache_type, S_IRUGO, virtblk_cache_type_show, NULL); -static const struct device_attribute dev_attr_cache_type_rw +static struct device_attribute dev_attr_cache_type_rw __ATTR(cache_type, S_IRUGO|S_IWUSR, virtblk_cache_type_show, virtblk_cache_type_store); @@ -550,6 +550,26 @@ static struct blk_mq_ops virtio_mq_ops = { static unsigned int virtblk_queue_depth; module_param_named(queue_depth, virtblk_queue_depth, uint, 0444); +static struct attribute *virtblk_attrs_ro[] = { + &dev_attr_serial.attr, + &dev_attr_cache_type_ro.attr, + NULL +}; + +static struct attribute *virtblk_attrs_rw[] = { + &dev_attr_serial.attr, + &dev_attr_cache_type_rw.attr, + NULL +}; + +static struct attribute_group virtblk_attr_group_ro = { + .attrs = virtblk_attrs_ro, +}; + +static struct attribute_group virtblk_attr_group_rw = { + .attrs = virtblk_attrs_rw, +}; + static int virtblk_probe(struct virtio_device *vdev) { struct virtio_blk *vblk; @@ -560,6 +580,7 @@ static int virtblk_probe(struct virtio_device *vdev) u32 v, blk_size, sg_elems, opt_io_size; u16 min_io_size; u8 physical_block_exp, alignment_offset; + struct attribute_group *attr_group; if (!vdev->config->get) { dev_err(&vdev->dev, "%s failure: config access disabled\n", @@ -719,19 +740,14 @@ static int virtblk_probe(struct virtio_device *vdev) virtio_device_ready(vdev); - device_add_disk(&vdev->dev, vblk->disk, NULL); - err = device_create_file(disk_to_dev(vblk->disk), &dev_attr_serial); - if (err) - goto out_del_disk; - if (virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) - err = device_create_file(disk_to_dev(vblk->disk), - &dev_attr_cache_type_rw); + attr_group = &virtblk_attr_group_rw; else - err = device_create_file(disk_to_dev(vblk->disk), - &dev_attr_cache_type_ro); + attr_group = &virtblk_attr_group_ro; + err = device_add_disk(&vdev->dev, vblk->disk, attr_group); if (err) goto out_del_disk; + return 0; out_del_disk: -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 10/15] mtd: Pass attribute group to device_add_disk
Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Signed-off-by: Fam Zheng <famz at redhat.com> --- drivers/mtd/mtd_blkdevs.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 4ff9381..fc9265d 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -434,13 +434,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) if (new->readonly) set_disk_ro(gd, 1); - device_add_disk(&new->mtd->dev, gd, NULL); - - if (new->disk_attributes) { - ret = sysfs_create_group(&disk_to_dev(gd)->kobj, - new->disk_attributes); - WARN_ON(ret); - } + device_add_disk(&new->mtd->dev, gd, new->disk_attributes); return 0; error4: blk_cleanup_queue(new->rq); -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 11/15] zram: Pass attribute group to device_add_disk
Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Meanwhile, update the error check code and message. Signed-off-by: Fam Zheng <famz at redhat.com> --- drivers/block/zram/zram_drv.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 20920a2..2331788 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1298,13 +1298,10 @@ static int zram_add(void) zram->disk->queue->limits.discard_zeroes_data = 0; queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zram->disk->queue); - device_add_disk(NULL, zram->disk, NULL); + ret = device_add_disk(NULL, zram->disk, &zram_disk_attr_group); - ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj, - &zram_disk_attr_group); if (ret < 0) { - pr_err("Error creating sysfs group for device %d\n", - device_id); + pr_err("Error creating disk %d\n", device_id); goto out_free_disk; } strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 12/15] mtip: Pass attribute group to device_add_disk
Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Meanwhile, update the error check code and message. Signed-off-by: Fam Zheng <famz at redhat.com> --- drivers/block/mtip32xx/mtip32xx.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 4048a70..504c549 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -2702,26 +2702,14 @@ static const struct file_operations mtip_flags_fops = { .llseek = no_llseek, }; -/* - * Create the sysfs related attributes. - * - * @dd Pointer to the driver data structure. - * @kobj Pointer to the kobj for the block device. - * - * return value - * 0 Operation completed successfully. - * -EINVAL Invalid parameter. - */ -static int mtip_hw_sysfs_init(struct driver_data *dd, struct kobject *kobj) -{ - if (!kobj || !dd) - return -EINVAL; +static struct attribute *mtip_dev_attrs[] = { + &dev_attr_status.attr, + NULL +}; - if (sysfs_create_file(kobj, &dev_attr_status.attr)) - dev_warn(&dd->pdev->dev, - "Error creating 'status' sysfs entry\n"); - return 0; -} +static struct attribute_group mtip_attr_group = { + .attrs = mtip_dev_attrs, +}; /* * Remove the sysfs related attributes. @@ -3918,7 +3906,6 @@ static int mtip_block_initialize(struct driver_data *dd) int rv = 0, wait_for_rebuild = 0; sector_t capacity; unsigned int index = 0; - struct kobject *kobj; if (dd->disk) goto skip_create_disk; /* hw init done, before rebuild */ @@ -4041,18 +4028,9 @@ skip_create_disk: set_capacity(dd->disk, capacity); /* Enable the block device and add it to /dev */ - device_add_disk(&dd->pdev->dev, dd->disk, NULL); + device_add_disk(&dd->pdev->dev, dd->disk, &mtip_attr_group); dd->bdev = bdget_disk(dd->disk, 0); - /* - * Now that the disk is active, initialize any sysfs attributes - * managed by the protocol layer. - */ - kobj = kobject_get(&disk_to_dev(dd->disk)->kobj); - if (kobj) { - mtip_hw_sysfs_init(dd, kobj); - kobject_put(kobj); - } if (dd->mtip_svc_handler) { set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag); -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 13/15] aoeblk: Pass attribute group to device_add_disk
Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Signed-off-by: Fam Zheng <famz at redhat.com> --- drivers/block/aoe/aoeblk.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 4edfff2..d1b7541 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -177,7 +177,7 @@ static struct attribute *aoe_attrs[] = { NULL, }; -static const struct attribute_group attr_group = { +static struct attribute_group attr_group = { .attrs = aoe_attrs, }; @@ -219,11 +219,6 @@ aoedisk_rm_debugfs(struct aoedev *d) d->debugfs = NULL; } -static int -aoedisk_add_sysfs(struct aoedev *d) -{ - return sysfs_create_group(&disk_to_dev(d->gd)->kobj, &attr_group); -} void aoedisk_rm_sysfs(struct aoedev *d) { @@ -417,8 +412,7 @@ aoeblk_gdalloc(void *vp) spin_unlock_irqrestore(&d->lock, flags); - device_add_disk(NULL, gd, NULL); - aoedisk_add_sysfs(d); + device_add_disk(NULL, gd, &attr_group); aoedisk_add_debugfs(d); spin_lock_irqsave(&d->lock, flags); -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 14/15] axonram: Pass attribute group to device_add_disk
Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Meanwhile, handle the error of device_add_disk. Signed-off-by: Fam Zheng <famz at redhat.com> --- arch/powerpc/sysdev/axonram.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c index 6aef6c2..23109e3 100644 --- a/arch/powerpc/sysdev/axonram.c +++ b/arch/powerpc/sysdev/axonram.c @@ -158,6 +158,15 @@ static const struct block_device_operations axon_ram_devops = { .direct_access = axon_ram_direct_access }; +static struct attribute *axon_attrs[] = { + &dev_attr_ecc.attr, + NULL, +}; + +static struct attribute_group axon_attr_group = { + .attrs = axon_attrs, +}; + /** * axon_ram_probe - probe() method for platform driver * @device: see platform_driver method @@ -237,7 +246,12 @@ static int axon_ram_probe(struct platform_device *device) set_capacity(bank->disk, bank->size >> AXON_RAM_SECTOR_SHIFT); blk_queue_make_request(bank->disk->queue, axon_ram_make_request); blk_queue_logical_block_size(bank->disk->queue, AXON_RAM_SECTOR_SIZE); - device_add_disk(&device->dev, bank->disk, NULL); + rc = device_add_disk(&device->dev, bank->disk, &axon_attr_group); + if (rc != 0) { + dev_err(&device->dev, "Cannot create disk\n"); + rc = -EFAULT; + goto failed; + } bank->irq_id = irq_of_parse_and_map(device->dev.of_node, 0); if (bank->irq_id == NO_IRQ) { @@ -255,13 +269,6 @@ static int axon_ram_probe(struct platform_device *device) goto failed; } - rc = device_create_file(&device->dev, &dev_attr_ecc); - if (rc != 0) { - dev_err(&device->dev, "Cannot create sysfs file\n"); - rc = -EFAULT; - goto failed; - } - azfs_minor += bank->disk->minors; return 0; -- 2.7.4
Fam Zheng
2016-Aug-17 07:15 UTC
[PATCH 15/15] block: Add FIXME comment to handle device_add_disk error
Done with coccinelle: @@ expression e1, e2, e3; identifier rc; @@ ( rc = device_add_disk(e1, e2, e3); | + /* FIXME: handle error. */ device_add_disk(e1, e2, e3); ) Signed-off-by: Fam Zheng <famz at redhat.com> --- arch/m68k/emu/nfblock.c | 1 + arch/um/drivers/ubd_kern.c | 1 + arch/xtensa/platforms/iss/simdisk.c | 1 + drivers/block/DAC960.c | 1 + drivers/block/amiflop.c | 1 + drivers/block/aoe/aoeblk.c | 1 + drivers/block/ataflop.c | 1 + drivers/block/brd.c | 2 ++ drivers/block/cciss.c | 1 + drivers/block/drbd/drbd_main.c | 1 + drivers/block/floppy.c | 1 + drivers/block/hd.c | 1 + drivers/block/loop.c | 1 + drivers/block/mg_disk.c | 1 + drivers/block/mtip32xx/mtip32xx.c | 1 + drivers/block/nbd.c | 1 + drivers/block/null_blk.c | 1 + drivers/block/osdblk.c | 1 + drivers/block/paride/pcd.c | 1 + drivers/block/paride/pd.c | 1 + drivers/block/paride/pf.c | 1 + drivers/block/pktcdvd.c | 1 + drivers/block/ps3disk.c | 1 + drivers/block/ps3vram.c | 1 + drivers/block/rbd.c | 1 + drivers/block/rsxx/dev.c | 1 + drivers/block/skd_main.c | 1 + drivers/block/sunvdc.c | 1 + drivers/block/swim.c | 1 + drivers/block/swim3.c | 1 + drivers/block/sx8.c | 1 + drivers/block/umem.c | 1 + drivers/block/xen-blkfront.c | 1 + drivers/block/xsysace.c | 1 + drivers/block/z2ram.c | 1 + drivers/cdrom/gdrom.c | 1 + drivers/ide/ide-cd.c | 1 + drivers/ide/ide-gd.c | 1 + drivers/lightnvm/gennvm.c | 1 + drivers/md/bcache/super.c | 2 ++ drivers/md/dm.c | 1 + drivers/md/md.c | 1 + drivers/memstick/core/ms_block.c | 1 + drivers/memstick/core/mspro_block.c | 1 + drivers/mmc/card/block.c | 1 + drivers/mtd/mtd_blkdevs.c | 1 + drivers/mtd/ubi/block.c | 1 + drivers/nvdimm/blk.c | 1 + drivers/nvdimm/btt.c | 1 + drivers/nvdimm/pmem.c | 1 + drivers/nvme/host/core.c | 1 + drivers/s390/block/dasd_genhd.c | 1 + drivers/s390/block/dcssblk.c | 1 + drivers/s390/block/scm_blk.c | 1 + drivers/s390/block/xpram.c | 1 + drivers/sbus/char/jsflash.c | 1 + drivers/scsi/sd.c | 1 + drivers/scsi/sr.c | 1 + 58 files changed, 60 insertions(+) diff --git a/arch/m68k/emu/nfblock.c b/arch/m68k/emu/nfblock.c index 29dfdd6..ec45cb6 100644 --- a/arch/m68k/emu/nfblock.c +++ b/arch/m68k/emu/nfblock.c @@ -138,6 +138,7 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize) set_capacity(dev->disk, (sector_t)blocks * (bsize / 512)); dev->disk->queue = dev->queue; + /* FIXME: handle error. */ device_add_disk(NULL, dev->disk, NULL); list_add_tail(&dev->list, &nfhd_list); diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 45bbca5..3725af0 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -829,6 +829,7 @@ static int ubd_disk_register(int major, u64 size, int unit, disk->private_data = &ubd_devs[unit]; disk->queue = ubd_devs[unit].queue; + /* FIXME: handle error. */ device_add_disk(parent, disk, NULL); *disk_out = disk; diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c index 6a3d8c3..b9a1a37 100644 --- a/arch/xtensa/platforms/iss/simdisk.c +++ b/arch/xtensa/platforms/iss/simdisk.c @@ -288,6 +288,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which, dev->gd->private_data = dev; snprintf(dev->gd->disk_name, 32, "simdisk%d", which); set_capacity(dev->gd, 0); + /* FIXME: handle error. */ device_add_disk(NULL, dev->gd, NULL); dev->procfile = proc_create_data(tmp, 0644, procdir, &fops, dev); diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index abaab30..f6121d3 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -3175,6 +3175,7 @@ DAC960_Probe(struct pci_dev *dev, const struct pci_device_id *entry) for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) { set_capacity(Controller->disks[disk], disk_size(Controller, disk)); + /* FIXME: handle error. */ device_add_disk(NULL, Controller->disks[disk], NULL); } DAC960_CreateProcEntries(Controller); diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index f00d3b4..48de00b 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1738,6 +1738,7 @@ static int __init fd_probe_drives(void) sprintf(disk->disk_name, "fd%d", drive); disk->private_data = &unit[drive]; set_capacity(disk, 880*2); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); } if ((drives > 0) || (nomem == 0)) { diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index d1b7541..6e7a128 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -412,6 +412,7 @@ aoeblk_gdalloc(void *vp) spin_unlock_irqrestore(&d->lock, flags); + /* FIXME: handle error. */ device_add_disk(NULL, gd, &attr_group); aoedisk_add_debugfs(d); diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 0587aa36..f3a2974 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1969,6 +1969,7 @@ static int __init atari_floppy_init (void) if (!unit[i].disk->queue) goto Enomem; set_capacity(unit[i].disk, MAX_DISK_SIZE * 2); + /* FIXME: handle error. */ device_add_disk(NULL, unit[i].disk, NULL); } diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 99f6444..5bb5bd4 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -549,6 +549,7 @@ static struct brd_device *brd_init_one(int i, bool *new) brd = brd_alloc(i); if (brd) { + /* FIXME: handle error. */ device_add_disk(NULL, brd->brd_disk, NULL); list_add_tail(&brd->brd_list, &brd_devices); } @@ -617,6 +618,7 @@ static int __init brd_init(void) /* point of no return */ list_for_each_entry(brd, &brd_devices, brd_list) + /* FIXME: handle error. */ device_add_disk(NULL, brd->brd_disk, NULL); blk_register_region(MKDEV(RAMDISK_MAJOR, 0), 1UL << MINORBITS, diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index bef9f7f..45eac78 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1972,6 +1972,7 @@ static int cciss_add_disk(ctlr_info_t *h, struct gendisk *disk, /* allows the interrupt handler to start the queue */ wmb(); h->drv[drv_index]->queue = disk->queue; + /* FIXME: handle error. */ device_add_disk(&h->drv[drv_index]->dev, disk, NULL); return 0; diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 47aee0e..3e4e195 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2897,6 +2897,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig goto out_idr_remove_vol; } + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); /* inherit the connection state */ diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 952cad1..4eb6125 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4347,6 +4347,7 @@ static int __init do_floppy_init(void) /* to be cleaned up... */ disks[drive]->private_data = (void *)(long)drive; disks[drive]->flags |= GENHD_FL_REMOVABLE; + /* FIXME: handle error. */ device_add_disk(&floppy_device[drive].dev, disks[drive], NULL); } diff --git a/drivers/block/hd.c b/drivers/block/hd.c index eeb5085..64d8ee9 100644 --- a/drivers/block/hd.c +++ b/drivers/block/hd.c @@ -767,6 +767,7 @@ static int __init hd_init(void) /* Let them fly */ for (drive = 0; drive < NR_HD; drive++) + /* FIXME: handle error. */ device_add_disk(NULL, hd_gendisk[drive], NULL); return 0; diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 3c5ad19..533839b 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1794,6 +1794,7 @@ static int loop_add(struct loop_device **l, int i) disk->private_data = lo; disk->queue = lo->lo_queue; sprintf(disk->disk_name, "loop%d", i); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); *l = lo; return lo->lo_number; diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index 48c67f6..81f289a 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -1006,6 +1006,7 @@ static int mg_probe(struct platform_device *plat_dev) set_capacity(host->gd, host->n_sectors); + /* FIXME: handle error. */ device_add_disk(NULL, host->gd, NULL); return err; diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 504c549..83dc3dc 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -4028,6 +4028,7 @@ skip_create_disk: set_capacity(dd->disk, capacity); /* Enable the block device and add it to /dev */ + /* FIXME: handle error. */ device_add_disk(&dd->pdev->dev, dd->disk, &mtip_attr_group); dd->bdev = bdget_disk(dd->disk, 0); diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index c31a7df..e619529 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1085,6 +1085,7 @@ static int __init nbd_init(void) disk->private_data = &nbd_dev[i]; sprintf(disk->disk_name, "nbd%d", i); nbd_reset(&nbd_dev[i]); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); } diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 61a7f69..ed4523d 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -740,6 +740,7 @@ static int null_add_dev(void) disk->queue = nullb->q; strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); done: diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c index 5683ef4..8313e4b 100644 --- a/drivers/block/osdblk.c +++ b/drivers/block/osdblk.c @@ -448,6 +448,7 @@ static int osdblk_init_disk(struct osdblk_device *osdev) /* finally, announce the disk to the world */ set_capacity(disk, obj_size / 512ULL); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); printk(KERN_INFO "%s: Added of size 0x%llx\n", diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 32920f8..108655d 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c @@ -970,6 +970,7 @@ static int __init pcd_init(void) register_cdrom(&cd->info); cd->disk->private_data = cd; cd->disk->queue = pcd_queue; + /* FIXME: handle error. */ device_add_disk(NULL, cd->disk, NULL); } } diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 3901529..9e3a4d5 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -906,6 +906,7 @@ static int pd_detect(void) for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { if (disk->gd) { set_capacity(disk->gd, disk->capacity); + /* FIXME: handle error. */ device_add_disk(NULL, disk->gd, NULL); found = 1; } diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index c7b2f13..c7b5202 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -989,6 +989,7 @@ static int __init pf_init(void) continue; disk->private_data = pf; disk->queue = pf_queue; + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); } return 0; diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 3ebec28..c281812 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2785,6 +2785,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) disk->events = pd->bdev->bd_disk->events; disk->async_events = pd->bdev->bd_disk->async_events; + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); pkt_sysfs_dev_new(pd); diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index 2fdeabc..715ac8a 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c @@ -498,6 +498,7 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev) gendisk->disk_name, priv->model, priv->raw_capacity >> 11, get_capacity(gendisk) >> 11); + /* FIXME: handle error. */ device_add_disk(&dev->sbd.core, gendisk, NULL); return 0; diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 49a2699..d82d87a 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -779,6 +779,7 @@ static int ps3vram_probe(struct ps3_system_bus_device *dev) dev_info(&dev->core, "%s: Using %lu MiB of GPU memory\n", gendisk->disk_name, get_capacity(gendisk) >> 11); + /* FIXME: handle error. */ device_add_disk(&dev->core, gendisk, NULL); return 0; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 77114cd..dcc073e 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -5160,6 +5160,7 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev) set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); up_write(&rbd_dev->header_rwsem); + /* FIXME: handle error. */ device_add_disk(NULL, rbd_dev->disk, NULL); pr_info("%s: added with size 0x%llx\n", rbd_dev->disk->disk_name, (unsigned long long) rbd_dev->mapping.size); diff --git a/drivers/block/rsxx/dev.c b/drivers/block/rsxx/dev.c index bc26e23..e0dba88 100644 --- a/drivers/block/rsxx/dev.c +++ b/drivers/block/rsxx/dev.c @@ -230,6 +230,7 @@ int rsxx_attach_dev(struct rsxx_cardinfo *card) set_capacity(card->gendisk, card->size8 >> 9); else set_capacity(card->gendisk, 0); + /* FIXME: handle error. */ device_add_disk(CARD_TO_DEV(card), card->gendisk, NULL); card->bdev_attached = 1; } diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index 4187060..0eadda5 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -4693,6 +4693,7 @@ static int skd_bdev_getgeo(struct block_device *bdev, struct hd_geometry *geo) static int skd_bdev_attach(struct device *parent, struct skd_device *skdev) { pr_debug("%s:%s:%d device_add_disk\n", skdev->name, __func__, __LINE__); + /* FIXME: handle error. */ device_add_disk(parent, skdev->disk, NULL); return 0; } diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 197c133..b2b10e1 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -834,6 +834,7 @@ static int probe_disk(struct vdc_port *port) port->vdisk_size, (port->vdisk_size >> (20 - 9)), port->vio.ver.major, port->vio.ver.minor); + /* FIXME: handle error. */ device_add_disk(&port->vio.vdev->dev, g, NULL); return 0; diff --git a/drivers/block/swim.c b/drivers/block/swim.c index a4d3e30..82dde18 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -858,6 +858,7 @@ static int swim_floppy_init(struct swim_priv *swd) swd->unit[drive].disk->private_data = &swd->unit[drive]; swd->unit[drive].disk->queue = swd->queue; set_capacity(swd->unit[drive].disk, 2880); + /* FIXME: handle error. */ device_add_disk(NULL, swd->unit[drive].disk, NULL); } diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index 39ad51e..9d52396 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -1240,6 +1240,7 @@ static int swim3_attach(struct macio_dev *mdev, disk->flags |= GENHD_FL_REMOVABLE; sprintf(disk->disk_name, "fd%d", index); set_capacity(disk, 2880); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); return 0; diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index 507dea8..4f49a97 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -1333,6 +1333,7 @@ static void carm_fsm_task (struct work_struct *work) struct gendisk *disk = port->disk; set_capacity(disk, port->capacity); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); activated++; } diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 44cb01d..016a0db 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -1096,6 +1096,7 @@ static int __init mm_init(void) disk->private_data = &cards[i]; disk->queue = cards[i].queue; set_capacity(disk, cards[i].mm_size << 1); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); } diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 2c1fe8d..68737bd 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2442,6 +2442,7 @@ static void blkfront_connect(struct blkfront_info *info) for (i = 0; i < info->nr_rings; i++) kick_pending_request_queues(&info->rinfo[i]); + /* FIXME: handle error. */ device_add_disk(&info->xbdev->dev, info->gd, NULL); info->is_ready = 1; diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index edafc73..7683337 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c @@ -1057,6 +1057,7 @@ static int ace_setup(struct ace_device *ace) ace_revalidate_disk(ace->gd); /* Make the sysace device 'live' */ + /* FIXME: handle error. */ device_add_disk(NULL, ace->gd, NULL); return 0; diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 19b7188..b3e2718 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -364,6 +364,7 @@ z2_init(void) sprintf(z2ram_gendisk->disk_name, "z2ram"); z2ram_gendisk->queue = z2_queue; + /* FIXME: handle error. */ device_add_disk(NULL, z2ram_gendisk, NULL); blk_register_region(MKDEV(Z2RAM_MAJOR, 0), Z2MINOR_COUNT, THIS_MODULE, z2_find, NULL, NULL); diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index 89f4028..a4a569f 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -817,6 +817,7 @@ static int probe_gdrom(struct platform_device *devptr) gd.toc = kzalloc(sizeof(struct gdromtoc), GFP_KERNEL); if (!gd.toc) goto probe_fail_toc; + /* FIXME: handle error. */ device_add_disk(NULL, gd.disk, NULL); return 0; diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 0e16085..d6b6558 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1779,6 +1779,7 @@ static int ide_cd_probe(ide_drive_t *drive) ide_cd_read_toc(drive, &sense); g->fops = &idecd_ops; g->flags |= GENHD_FL_REMOVABLE | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; + /* FIXME: handle error. */ device_add_disk(&drive->gendev, g, NULL); return 0; diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index 04e008e..6b1758b 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c @@ -416,6 +416,7 @@ static int ide_gd_probe(ide_drive_t *drive) if (drive->dev_flags & IDE_DFLAG_REMOVABLE) g->flags = GENHD_FL_REMOVABLE; g->fops = &ide_gd_ops; + /* FIXME: handle error. */ device_add_disk(&drive->gendev, g, NULL); return 0; diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index 08c6cdf..a4ff352 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -90,6 +90,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) blk_queue_max_hw_sectors(tqueue, 8 * dev->ops->max_phys_sect); set_capacity(tdisk, tt->capacity(targetdata)); + /* FIXME: handle error. */ device_add_disk(NULL, tdisk, NULL); t->type = tt; diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 071465a..391fbd2 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -866,6 +866,7 @@ void bch_cached_dev_run(struct cached_dev *dc) closure_sync(&cl); } + /* FIXME: handle error. */ device_add_disk(NULL, d->disk, NULL); bd_link_disk_holder(dc->bdev, dc->disk.disk); /* won't show up in the uevent file, use udevadm monitor -e instead @@ -1229,6 +1230,7 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u) bcache_device_attach(d, c, u - c->uuids); bch_flash_dev_request_init(d); + /* FIXME: handle error. */ device_add_disk(NULL, d->disk, NULL); if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache")) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 8ba15b5..14da668 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1514,6 +1514,7 @@ static struct mapped_device *alloc_dev(int minor) md->disk->queue = md->queue; md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); + /* FIXME: handle error. */ device_add_disk(NULL, md->disk, NULL); format_dev_t(md->name, MKDEV(_major, minor)); diff --git a/drivers/md/md.c b/drivers/md/md.c index 16fe7e7..1343590 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5066,6 +5066,7 @@ static int md_alloc(dev_t dev, char *name) * through to md_open, so make sure it doesn't get too far */ mutex_lock(&mddev->open_mutex); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); error = kobject_init_and_add(&mddev->kobj, &md_ktype, diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c index d5e6c3c..888cb51 100644 --- a/drivers/memstick/core/ms_block.c +++ b/drivers/memstick/core/ms_block.c @@ -2161,6 +2161,7 @@ static int msb_init_disk(struct memstick_dev *card) set_disk_ro(msb->disk, 1); msb_start(card); + /* FIXME: handle error. */ device_add_disk(&card->dev, msb->disk, NULL); dbg("Disk added"); return 0; diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index e26a2b80..75d11cb 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c @@ -1253,6 +1253,7 @@ static int mspro_block_init_disk(struct memstick_dev *card) set_capacity(msb->disk, capacity); dev_dbg(&card->dev, "capacity set %ld\n", capacity); + /* FIXME: handle error. */ device_add_disk(&card->dev, msb->disk, NULL); msb->active = 1; return 0; diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 9030023..a824f44 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2460,6 +2460,7 @@ static int mmc_add_disk(struct mmc_blk_data *md) int ret; struct mmc_card *card = md->queue.card; + /* FIXME: handle error. */ device_add_disk(md->parent, md->disk, NULL); md->force_ro.show = force_ro_show; md->force_ro.store = force_ro_store; diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index fc9265d..e37e547 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -434,6 +434,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) if (new->readonly) set_disk_ro(gd, 1); + /* FIXME: handle error. */ device_add_disk(&new->mtd->dev, gd, new->disk_attributes); return 0; error4: diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 979e4d4..8c8b8dc 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -445,6 +445,7 @@ int ubiblock_create(struct ubi_volume_info *vi) mutex_unlock(&devices_mutex); /* Must be the last step: anyone can call file ops from now on */ + /* FIXME: handle error. */ device_add_disk(NULL, dev->gd, NULL); dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)", dev->ubi_num, dev->vol_id, vi->name); diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c index cb74017..2601609 100644 --- a/drivers/nvdimm/blk.c +++ b/drivers/nvdimm/blk.c @@ -287,6 +287,7 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk) disk->flags = GENHD_FL_EXT_DEVT; nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name); set_capacity(disk, 0); + /* FIXME: handle error. */ device_add_disk(dev, disk, NULL); if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk)) diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 8e97bc9..f64d775 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1257,6 +1257,7 @@ static int btt_blk_init(struct btt *btt) btt->btt_queue->queuedata = btt; set_capacity(btt->btt_disk, 0); + /* FIXME: handle error. */ device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL); if (btt_meta_size(btt)) { int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt)); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 7f3f611..2ab0dd8 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -309,6 +309,7 @@ static int pmem_attach_disk(struct device *dev, return -ENOMEM; nvdimm_badblocks_populate(nd_region, &pmem->bb, res); disk->bb = &pmem->bb; + /* FIXME: handle error. */ device_add_disk(dev, disk, NULL); if (devm_add_action_or_reset(dev, pmem_release_disk, disk)) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 1921cb2..a3d7f82 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1686,6 +1686,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) if (ns->type == NVME_NS_LIGHTNVM) return; + /* FIXME: handle error. */ device_add_disk(ctrl->device, ns->disk, &nvme_ns_attr_group); return; out_free_disk: diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c index cf5e081..eec1856 100644 --- a/drivers/s390/block/dasd_genhd.c +++ b/drivers/s390/block/dasd_genhd.c @@ -75,6 +75,7 @@ int dasd_gendisk_alloc(struct dasd_block *block) gdp->queue = block->request_queue; block->gdp = gdp; set_capacity(block->gdp, 0); + /* FIXME: handle error. */ device_add_disk(&base->cdev->dev, block->gdp, NULL); return 0; } diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 376e0fd..41af886 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -655,6 +655,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char goto put_dev; get_device(&dev_info->dev); + /* FIXME: handle error. */ device_add_disk(&dev_info->dev, dev_info->gd, NULL); switch (dev_info->segment_type) { diff --git a/drivers/s390/block/scm_blk.c b/drivers/s390/block/scm_blk.c index 6dba6eb..1c7950f 100644 --- a/drivers/s390/block/scm_blk.c +++ b/drivers/s390/block/scm_blk.c @@ -530,6 +530,7 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev) /* 512 byte sectors */ set_capacity(bdev->gendisk, scmdev->size >> 9); + /* FIXME: handle error. */ device_add_disk(&scmdev->dev, bdev->gendisk, NULL); return 0; diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c index 65cca0a..7725c24 100644 --- a/drivers/s390/block/xpram.c +++ b/drivers/s390/block/xpram.c @@ -377,6 +377,7 @@ static int __init xpram_setup_blkdev(void) disk->queue = xpram_queues[i]; sprintf(disk->disk_name, "slram%d", i); set_capacity(disk, xpram_sizes[i] << 1); + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); } diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index 1c823fa..1e8403c 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c @@ -590,6 +590,7 @@ static int jsfd_init(void) set_capacity(disk, jdp->dsize >> 9); disk->private_data = jdp; disk->queue = jsf_queue; + /* FIXME: handle error. */ device_add_disk(NULL, disk, NULL); set_disk_ro(disk, 1); } diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index eb8e67f..bd4862d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3000,6 +3000,7 @@ static void sd_probe_async(void *data, async_cookie_t cookie) } blk_pm_runtime_init(sdp->request_queue, dev); + /* FIXME: handle error. */ device_add_disk(dev, gd, NULL); if (sdkp->capacity) sd_dif_config_host(sdkp); diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index e9619a6..5b869da 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -729,6 +729,7 @@ static int sr_probe(struct device *dev) dev_set_drvdata(dev, cd); disk->flags |= GENHD_FL_REMOVABLE; + /* FIXME: handle error. */ device_add_disk(&sdev->sdev_gendev, disk, NULL); sdev_printk(KERN_DEBUG, sdev, -- 2.7.4
kbuild test robot
2016-Aug-17 08:13 UTC
[PATCH 08/15] nvme: Pass attribute group to device_add_disk
Hi Fam, [auto build test WARNING on linus/master] [also build test WARNING on v4.8-rc2 next-20160817] [cannot apply to linux/master] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Fam-Zheng/Fix-issue-with-KOBJ_ADD-uevent-versus-disk-attributes/20160817-152900 config: powerpc-allmodconfig (attached as .config) compiler: powerpc64-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609 reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All warnings (new ones prefixed by >>): drivers/nvme/host/core.c: In function 'nvme_alloc_ns':>> drivers/nvme/host/core.c:1689:42: warning: passing argument 3 of 'device_add_disk' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]device_add_disk(ctrl->device, ns->disk, &nvme_ns_attr_group); ^ In file included from include/linux/blkdev.h:9:0, from drivers/nvme/host/core.c:15: include/linux/genhd.h:416:12: note: expected 'struct attribute_group *' but argument is of type 'const struct attribute_group *' extern int device_add_disk(struct device *parent, struct gendisk *disk, ^ vim +1689 drivers/nvme/host/core.c 1673 disk->private_data = ns; 1674 disk->queue = ns->queue; 1675 disk->flags = GENHD_FL_EXT_DEVT; 1676 sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance, ns->instance); 1677 1678 if (nvme_revalidate_disk(ns->disk)) 1679 goto out_free_disk; 1680 1681 mutex_lock(&ctrl->namespaces_mutex); 1682 list_add_tail(&ns->list, &ctrl->namespaces); 1683 mutex_unlock(&ctrl->namespaces_mutex); 1684 1685 kref_get(&ctrl->kref); 1686 if (ns->type == NVME_NS_LIGHTNVM) 1687 return; 1688> 1689 device_add_disk(ctrl->device, ns->disk, &nvme_ns_attr_group);1690 return; 1691 out_free_disk: 1692 kfree(disk); 1693 out_free_queue: 1694 blk_cleanup_queue(ns->queue); 1695 out_release_instance: 1696 ida_simple_remove(&ctrl->ns_ida, ns->instance); 1697 out_free_ns: --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation -------------- next part -------------- A non-text attachment was scrubbed... Name: .config.gz Type: application/octet-stream Size: 49909 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20160817/75a7e7e4/attachment-0001.obj>
Cornelia Huck
2016-Aug-17 08:49 UTC
[PATCH 06/15] genhd: Add return code to device_add_disk
On Wed, 17 Aug 2016 15:15:06 +0800 Fam Zheng <famz at redhat.com> wrote:> @@ -613,10 +614,8 @@ void device_add_disk(struct device *parent, struct gendisk *disk) > disk->flags |= GENHD_FL_UP; > > retval = blk_alloc_devt(&disk->part0, &devt); > - if (retval) { > - WARN_ON(1); > - return; > - } > + if (retval) > + goto fail; > disk_to_dev(disk)->devt = devt; > > /* ->major and ->first_minor aren't supposed to be > @@ -625,16 +624,26 @@ void device_add_disk(struct device *parent, struct gendisk *disk) > disk->major = MAJOR(devt); > disk->first_minor = MINOR(devt); > > - disk_alloc_events(disk); > + retval = disk_alloc_events(disk); > + if (retval) > + goto fail; > > /* Register BDI before referencing it from bdev */ > bdi = &disk->queue->backing_dev_info; > - bdi_register_owner(bdi, disk_to_dev(disk)); > + retval = bdi_register_owner(bdi, disk_to_dev(disk)); > + if (retval) > + goto fail; > > - blk_register_region(disk_devt(disk), disk->minors, NULL, > - exact_match, exact_lock, disk); > - register_disk(parent, disk); > - blk_register_queue(disk); > + retval = blk_register_region(disk_devt(disk), disk->minors, NULL, > + exact_match, exact_lock, disk); > + if (retval) > + goto fail; > + retval = register_disk(parent, disk); > + if (retval) > + goto fail; > + retval = blk_register_queue(disk); > + if (retval) > + goto fail; > > /* > * Take an extra ref on queue which will be put on disk_release() > @@ -644,10 +653,20 @@ void device_add_disk(struct device *parent, struct gendisk *disk) > > retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj, > "bdi"); > + if (retval) > + goto fail; > + > + retval = disk_add_events(disk); > + if (retval) > + goto fail; > + > + retval = blk_integrity_add(disk); > + if (retval) > + goto fail; > + return 0; > +fail: > WARN_ON(retval); > - > - disk_add_events(disk); > - blk_integrity_add(disk); > + return retval; > }Noticed this when trying to figure out whether the error handling in virtio_blk was correct: Shouldn't you try to cleanup/rewind so that any structures are in a sane state after failure? The caller doesn't know where device_add_disk failed, and calling del_gendisk unconditionally like virtio_blk does is probably not the right thing to do (at the very least, I don't think unregistering a device that has not been registered is likely to work).
Sergey Senozhatsky
2016-Aug-18 01:59 UTC
[PATCH 11/15] zram: Pass attribute group to device_add_disk
Hello, On (08/17/16 15:15), Fam Zheng wrote: [..]> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c > index 20920a2..2331788 100644 > --- a/drivers/block/zram/zram_drv.c > +++ b/drivers/block/zram/zram_drv.c > @@ -1298,13 +1298,10 @@ static int zram_add(void) > zram->disk->queue->limits.discard_zeroes_data = 0; > queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zram->disk->queue); > > - device_add_disk(NULL, zram->disk, NULL); > + ret = device_add_disk(NULL, zram->disk, &zram_disk_attr_group); > > - ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj, > - &zram_disk_attr_group); > if (ret < 0) { > - pr_err("Error creating sysfs group for device %d\n", > - device_id); > + pr_err("Error creating disk %d\n", device_id); > goto out_free_disk; > } > strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor));I like the previous "Error creating sysfs group for device" string better, than "Error creating disk", because the latter one is much less informative. do you want to do something like below? int device_add_disk(struct device *parent, struct gendisk *disk, ... if (attr_group) { retval = sysfs_create_group(&disk_to_dev(disk)->kobj, attr_group); + pr_err("Error creating sysfs group for device ...\n", ...); if (retval) goto fail; } -ss
Sergey Senozhatsky
2016-Aug-18 02:36 UTC
[PATCH 15/15] block: Add FIXME comment to handle device_add_disk error
On (08/17/16 15:15), Fam Zheng wrote: [..]> ( > rc = device_add_disk(e1, e2, e3); > | > + /* FIXME: handle error. */ > device_add_disk(e1, e2, e3);or use __must_check for device_add_disk() function? /* which is _attribute__((warn_unused_result)) */ -ss
Michael S. Tsirkin
2016-Sep-04 04:18 UTC
[PATCH 09/15] virtio-blk: Pass attribute group to device_add_disk
On Wed, Aug 17, 2016 at 03:15:09PM +0800, Fam Zheng wrote:> Previously after device_add_disk returns, the KOBJ_ADD uevent is already > emitted. Adding attributes after that is a poor usage of kobject, and > in practice may result in race conditions with userspace, for > example udev checks availability of certain attributes and initializes > /dev entries conditionally. > > device_add_disk can handle adding attribute group better, so use it. > > Meanwhile, handle error of device_add_disk. > > Signed-off-by: Fam Zheng <famz at redhat.com>Feel free to merge this with the rest of patchset Acked-by: Michael S. Tsirkin <mst at redhat.com>> --- > drivers/block/virtio_blk.c | 38 +++++++++++++++++++++++++++----------- > 1 file changed, 27 insertions(+), 11 deletions(-) > > diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c > index 4564df5..ff60d82 100644 > --- a/drivers/block/virtio_blk.c > +++ b/drivers/block/virtio_blk.c > @@ -522,10 +522,10 @@ virtblk_cache_type_show(struct device *dev, struct device_attribute *attr, > return snprintf(buf, 40, "%s\n", virtblk_cache_types[writeback]); > } > > -static const struct device_attribute dev_attr_cache_type_ro > +static struct device_attribute dev_attr_cache_type_ro > __ATTR(cache_type, S_IRUGO, > virtblk_cache_type_show, NULL); > -static const struct device_attribute dev_attr_cache_type_rw > +static struct device_attribute dev_attr_cache_type_rw > __ATTR(cache_type, S_IRUGO|S_IWUSR, > virtblk_cache_type_show, virtblk_cache_type_store); > > @@ -550,6 +550,26 @@ static struct blk_mq_ops virtio_mq_ops = { > static unsigned int virtblk_queue_depth; > module_param_named(queue_depth, virtblk_queue_depth, uint, 0444); > > +static struct attribute *virtblk_attrs_ro[] = { > + &dev_attr_serial.attr, > + &dev_attr_cache_type_ro.attr, > + NULL > +}; > + > +static struct attribute *virtblk_attrs_rw[] = { > + &dev_attr_serial.attr, > + &dev_attr_cache_type_rw.attr, > + NULL > +}; > + > +static struct attribute_group virtblk_attr_group_ro = { > + .attrs = virtblk_attrs_ro, > +}; > + > +static struct attribute_group virtblk_attr_group_rw = { > + .attrs = virtblk_attrs_rw, > +}; > + > static int virtblk_probe(struct virtio_device *vdev) > { > struct virtio_blk *vblk; > @@ -560,6 +580,7 @@ static int virtblk_probe(struct virtio_device *vdev) > u32 v, blk_size, sg_elems, opt_io_size; > u16 min_io_size; > u8 physical_block_exp, alignment_offset; > + struct attribute_group *attr_group; > > if (!vdev->config->get) { > dev_err(&vdev->dev, "%s failure: config access disabled\n", > @@ -719,19 +740,14 @@ static int virtblk_probe(struct virtio_device *vdev) > > virtio_device_ready(vdev); > > - device_add_disk(&vdev->dev, vblk->disk, NULL); > - err = device_create_file(disk_to_dev(vblk->disk), &dev_attr_serial); > - if (err) > - goto out_del_disk; > - > if (virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) > - err = device_create_file(disk_to_dev(vblk->disk), > - &dev_attr_cache_type_rw); > + attr_group = &virtblk_attr_group_rw; > else > - err = device_create_file(disk_to_dev(vblk->disk), > - &dev_attr_cache_type_ro); > + attr_group = &virtblk_attr_group_ro; > + err = device_add_disk(&vdev->dev, vblk->disk, attr_group); > if (err) > goto out_del_disk; > + > return 0; > > out_del_disk: > -- > 2.7.4
Possibly Parallel Threads
- [PATCH 11/15] zram: Pass attribute group to device_add_disk
- [PATCH 11/15] zram: Pass attribute group to device_add_disk
- [PATCH 00/15] Fix issue with KOBJ_ADD uevent versus disk attributes
- [PATCH 00/15] Fix issue with KOBJ_ADD uevent versus disk attributes
- [PATCH 09/15] virtio-blk: Pass attribute group to device_add_disk