lkml.org 
[lkml]   [2020]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [resend v1 1/5] block/genhd: Notify udev about capacity change
Date
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@lst.de>
> Signed-off-by: Someswarudu Sangaraju<ssomesh@amazon.com>
> Signed-off-by: Balbir Singh<sblbir@amazon.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


\
 
 \ /
  Last update: 2020-01-03 07:17    [W:0.280 / U:4.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site