[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BYAPR04MB5749EE1549B30FCECEC1154B86230@BYAPR04MB5749.namprd04.prod.outlook.com>
Date: Fri, 3 Jan 2020 06:16:39 +0000
From: Chaitanya Kulkarni <Chaitanya.Kulkarni@....com>
To: Balbir Singh <sblbir@...zon.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
"linux-nvme@...ts.infradead.org" <linux-nvme@...ts.infradead.org>
CC: "axboe@...nel.dk" <axboe@...nel.dk>,
"ssomesh@...zon.com" <ssomesh@...zon.com>,
"jejb@...ux.ibm.com" <jejb@...ux.ibm.com>,
"hch@....de" <hch@....de>, "mst@...hat.com" <mst@...hat.com>
Subject: Re: [resend v1 1/5] block/genhd: Notify udev about capacity change
On 01/01/2020 11:53 PM, Balbir Singh wrote:
> Allow block/genhd to notify user space (via udev) about disk size changes
> using a new helper disk_set_capacity(), which is a wrapper on top
> of set_capacity(). disk_set_capacity() will only notify via udev if
> the current capacity or the target capacity is not zero.
>
> Suggested-by: Christoph Hellwig<hch@....de>
> Signed-off-by: Someswarudu Sangaraju<ssomesh@...zon.com>
> Signed-off-by: Balbir Singh<sblbir@...zon.com>
> ---
Since disk_set_capacity(() is on the same line as set_capacity()
we should follow the same convention, which is :-
1. Avoid exporting symbol.
2. Mark new function in-line.
Unless there is a very specific reason for breaking the pattern.
Why not this (totally untested but easy convey above comment)
on the top of this patch ?
# git diff
diff --git a/block/genhd.c b/block/genhd.c
index 94faec98607b..ff6268970ddc 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -46,25 +46,6 @@ static void disk_add_events(struct gendisk *disk);
static void disk_del_events(struct gendisk *disk);
static void disk_release_events(struct gendisk *disk);
-/*
- * Set disk capacity and notify if the size is not currently
- * zero and will not be set to zero
- */
-void disk_set_capacity(struct gendisk *disk, sector_t size)
-{
- sector_t capacity = get_capacity(disk);
-
- set_capacity(disk, size);
- if (capacity != 0 && size != 0) {
- char *envp[] = { "RESIZE=1", NULL };
-
- kobject_uevent_env(&disk_to_dev(disk)->kobj,
KOBJ_CHANGE, envp);
- }
-}
-
-EXPORT_SYMBOL_GPL(disk_set_capacity);
-
-
void part_inc_in_flight(struct request_queue *q, struct hd_struct
*part, int rw)
{
if (queue_is_mq(q))
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index d5e87d7cc357..5e595a28f893 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -469,6 +469,22 @@ static inline void set_capacity(struct gendisk
*disk, sector_t size)
disk->part0.nr_sects = size;
}
+/*
+ * Set disk capacity and notify if the size is not currently
+ * zero and will not be set to zero
+ */
+static inline void disk_set_capacity(struct gendisk *disk, sector_t size)
+{
+ sector_t capacity = get_capacity(disk);
+
+ set_capacity(disk, size);
+ if (capacity != 0 && size != 0) {
+ char *envp[] = { "RESIZE=1", NULL };
+
+ kobject_uevent_env(&disk_to_dev(disk)->kobj,
KOBJ_CHANGE, envp);
+ }
+}
+
#ifdef CONFIG_SOLARIS_X86_PARTITION
Powered by blists - more mailing lists