Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1464377

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

From Fam Zheng <famz@redhat.com>
Newsgroups linux.kernel
Subject [PATCH 11/15] zram: Pass attribute group to device_add_disk
Date 2016-08-17 09:30 +0200
Message-ID <s73su-6je-3@gated-at.bofh.it> (permalink)
References <s73iN-6e4-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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@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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/15] Fix issue with KOBJ_ADD uevent versus disk attributes Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
  [PATCH 04/15] block: Return error from blk_integrity_add Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
  [PATCH 03/15] genhd: Return error from blk_register_region Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
  [PATCH 12/15] mtip: Pass attribute group to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
  [PATCH 02/15] genhd: Return error from register_disk() Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
  [PATCH 01/15] disk: Drop add_disk in favor of device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
  [PATCH 14/15] axonram: Pass attribute group to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
  [PATCH 13/15] aoeblk: Pass attribute group to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
  [PATCH 15/15] block: Add FIXME comment to handle device_add_disk error Fam Zheng <famz@redhat.com> - 2016-08-17 09:20 +0200
    Re: [PATCH 15/15] block: Add FIXME comment to handle device_add_disk  error Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-08-18 04:40 +0200
  [PATCH 10/15] mtd: Pass attribute group to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:30 +0200
  [PATCH 08/15] nvme: Pass attribute group to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:30 +0200
  [PATCH 06/15] genhd: Add return code to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:30 +0200
    Re: [PATCH 06/15] genhd: Add return code to device_add_disk Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-08-17 10:50 +0200
      Re: [PATCH 06/15] genhd: Add return code to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 11:00 +0200
        Re: [PATCH 06/15] genhd: Add return code to device_add_disk Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-08-17 11:10 +0200
          Re: [PATCH 06/15] genhd: Add return code to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 11:30 +0200
            Re: [PATCH 06/15] genhd: Add return code to device_add_disk Ed Cashin <ed.cashin@acm.org> - 2016-08-18 03:40 +0200
  [PATCH 11/15] zram: Pass attribute group to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:30 +0200
    Re: [PATCH 11/15] zram: Pass attribute group to device_add_disk Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-08-18 04:00 +0200
      Re: [PATCH 11/15] zram: Pass attribute group to device_add_disk Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-08-18 04:10 +0200
  [PATCH 09/15] virtio-blk: Pass attribute group to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:30 +0200
  [PATCH 05/15] genhd: Return error from disk_{add,alloc}_events Fam Zheng <famz@redhat.com> - 2016-08-17 09:30 +0200
  [PATCH 07/15] genhd: Add attribute group parameter to device_add_disk Fam Zheng <famz@redhat.com> - 2016-08-17 09:30 +0200

csiph-web