[PATCH v2 00/12] gendisk: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
the uevent when attributes are added. [1] https://lkml.org/lkml/2016/6/28/550 Fam Zheng (12): genhd: Add "gen_uevent" parameter to add_disk genhd: Honor gen_uevent and add disk_gen_uevents virtio-blk: Generate uevent after attribute available axonrom: Generate uevent after attribut

[PATCH v2 01/12] genhd: Add "gen_uevent" parameter to add_disk

2016-06-29 Thread Fam Zheng
The parameter will be used to control whether add_disk should generate the KOBJ_ADD uevent already. Signed-off-by: Fam Zheng --- arch/m68k/emu/nfblock.c | 2 +- arch/powerpc/sysdev/axonram.c | 2 +- arch/um/drivers/ubd_kern.c | 2 +- arch

[PATCH v2 02/12] genhd: Honor gen_uevent and add disk_gen_uevents

2016-06-29 Thread Fam Zheng
In add_disk(), don't send uevent to userspace when gen_uevent is true; also export the refactored function disk_gen_uevents for later use. Signed-off-by: Fam Zheng --- block/genhd.c | 23 +++ include/linux/genhd.h | 1 + 2 files changed, 20 insertions(

[PATCH v2 03/12] virtio-blk: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
number of virtio-blk disks. Also in systemd, there used to be a related workaround in udev rules called 'WAIT_FOR="serial"', but it is removed in later versions. Now let's generate a KOBJ_CHANGE event after the attributes are ready. Signed-off-by: Fam Zheng --- drivers

[PATCH v2 04/12] axonrom: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- arch/powerpc/sysdev/axonram.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --

[PATCH v2 05/12] aoeblk: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- drivers/block/aoe/aoeblk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --

[PATCH v2 06/12] mtip32xx: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- drivers/block/mtip32xx/mtip32xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)

[PATCH v2 07/12] pktcdvd: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- drivers/block/pktcdvd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --

[PATCH v2 08/12] zram: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- drivers/block/zram/zram_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --

[PATCH v2 09/12] md: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- drivers/md/md.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drive

[PATCH v2 10/12] mmc: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- drivers/mmc/card/block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --

[PATCH v2 11/12] mtd: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- drivers/mtd/mtd_blkdevs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --

[PATCH v2 12/12] nvme: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
It is documented that KOBJ_ADD should be generated after the object's attributes and children are ready. We can achieve this with the new disk_gen_uevents interface. Signed-off-by: Fam Zheng --- drivers/nvme/host/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --

Re: [PATCH v2 00/12] gendisk: Generate uevent after attribute available

2016-06-29 Thread Fam Zheng
On Wed, 06/29 23:24, Christoph Hellwig wrote: > On Thu, Jun 30, 2016 at 09:59:41AM +0800, Fam Zheng wrote: > > Documentation/kobject.txt: > > > Use the KOBJ_ADD action for when the kobject is first added to the kernel. > > > This should be done only after any attributes

Re: [PATCH v2 00/12] gendisk: Generate uevent after attribute available

2016-06-30 Thread Fam Zheng
On Wed, 06/29 23:38, Christoph Hellwig wrote: > On Thu, Jun 30, 2016 at 02:35:54PM +0800, Fam Zheng wrote: > > also more code and less flexible IMO. For example, we need at least two > > variants, for attribute_group and device_attribute separately, right? > > Yes, or

Re: [PATCH v2 04/12] axonrom: Generate uevent after attribute available

2016-06-30 Thread Fam Zheng
On Thu, 06/30 15:10, Dan Williams wrote: > On Wed, Jun 29, 2016 at 6:59 PM, Fam Zheng wrote: > > It is documented that KOBJ_ADD should be generated after the object's > > attributes and children are ready. We can achieve this with the new > > disk_gen_uevents interf

[PATCH 00/15] Fix issue with KOBJ_ADD uevent versus disk attributes

2016-08-17 Thread Fam Zheng
r 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

[PATCH 01/15] disk: Drop add_disk in favor of device_add_disk

2016-08-17 Thread Fam Zheng
d_disk and update of related comments are done manually. Signed-off-by: Fam Zheng --- 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

[PATCH 02/15] genhd: Return error from register_disk()

2016-08-17 Thread Fam Zheng
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 --- block/genhd.c | 27

[PATCH 03/15] genhd: Return error from blk_register_region

2016-08-17 Thread Fam Zheng
blk_register_region can fail (-ENOMEM), return the error to the caller. Signed-off-by: Fam Zheng --- 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

[PATCH 04/15] block: Return error from blk_integrity_add

2016-08-17 Thread Fam Zheng
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 --- block/blk-integrity.c | 12 include/linux/genhd.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions

[PATCH 05/15] genhd: Return error from disk_{add,alloc}_events

2016-08-17 Thread Fam Zheng
disk_alloc_events and disk_add_events can fail, return the error code so the caller can handle it. Signed-off-by: Fam Zheng --- 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

[PATCH 06/15] genhd: Add return code to device_add_disk

2016-08-17 Thread Fam Zheng
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

[PATCH 07/15] genhd: Add attribute group parameter to device_add_disk

2016-08-17 Thread Fam Zheng
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 --- arch/m68k/emu

[PATCH 08/15] nvme: Pass attribute group to device_add_disk

2016-08-17 Thread Fam Zheng
conditionally. device_add_disk can handle adding attribute group better, so use it. Signed-off-by: Fam Zheng --- 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

[PATCH 09/15] virtio-blk: Pass attribute group to device_add_disk

2016-08-17 Thread Fam Zheng
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 --- drivers/block/virtio_blk.c | 38 +++--- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers

[PATCH 10/15] mtd: Pass attribute group to device_add_disk

2016-08-17 Thread Fam Zheng
conditionally. device_add_disk can handle adding attribute group better, so use it. Signed-off-by: Fam Zheng --- 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

[PATCH 11/15] zram: Pass attribute group to device_add_disk

2016-08-17 Thread Fam Zheng
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 --- drivers/block/zram/zram_drv.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b

[PATCH 12/15] mtip: Pass attribute group to device_add_disk

2016-08-17 Thread Fam Zheng
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 --- drivers/block/mtip32xx/mtip32xx.c | 38 -- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git

[PATCH 13/15] aoeblk: Pass attribute group to device_add_disk

2016-08-17 Thread Fam Zheng
conditionally. device_add_disk can handle adding attribute group better, so use it. Signed-off-by: Fam Zheng --- 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

[PATCH 14/15] axonram: Pass attribute group to device_add_disk

2016-08-17 Thread Fam Zheng
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 --- arch/powerpc/sysdev/axonram.c | 23 +++ 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/sysdev

[PATCH 15/15] block: Add FIXME comment to handle device_add_disk error

2016-08-17 Thread Fam Zheng
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 --- arch/m68k/emu/nfblock.c | 1 + arch/um/drivers/ubd_kern.c

Re: [PATCH 06/15] genhd: Add return code to device_add_disk

2016-08-17 Thread Fam Zheng
On Wed, 08/17 10:49, Cornelia Huck wrote: > On Wed, 17 Aug 2016 15:15:06 +0800 > Fam Zheng wrote: > > > @@ -613,10 +614,8 @@ void device_add_disk(struct device *parent, struct > > gendisk *disk) > > disk->flags |= GENHD_FL_UP; > > > > r

Re: [PATCH 06/15] genhd: Add return code to device_add_disk

2016-08-17 Thread Fam Zheng
On Wed, 08/17 11:06, Cornelia Huck wrote: > On Wed, 17 Aug 2016 16:48:23 +0800 > Fam Zheng wrote: > > > On Wed, 08/17 10:49, Cornelia Huck wrote: > > > On Wed, 17 Aug 2016 15:15:06 +0800 > > > Fam Zheng wrote: > > > > > > > @@ -613,1