dm-bow: Fix 5.15 compatibility issue 95/291795/1 accepted/tizen/unified/20230424.185352
authorJaehoon Chung <jh80.chung@samsung.com>
Fri, 21 Apr 2023 08:27:15 +0000 (17:27 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Fri, 21 Apr 2023 08:27:15 +0000 (17:27 +0900)
https://patchwork.kernel.org/project/linux-block/patch/20210804094147.459763-8-hch@lst.de/

delays registering the gendisk, so move creating our sysfs nodes until
resume.

Orignal-Author: Paul Lawrence <paullawrence@google.com>
Origin: https://android.googlesource.com/kernel/common/+/88e27b17aab604fb2d486e538b2ef55cd967a430%5E%21/#F0
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ib328a4b1f989cdd7359c186668417f85d633b29a
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/md/dm-bow.c

index 6f2711d..bc0df92 100644 (file)
@@ -694,7 +694,6 @@ static int dm_bow_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        struct bow_context *bc;
        struct bow_range *br;
        int ret;
-       struct mapped_device *md = dm_table_get_md(ti->table);
 
        if (argc < 1) {
                ti->error = "Invalid argument count";
@@ -735,14 +734,6 @@ static int dm_bow_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        }
 
        init_completion(&bc->kobj_holder.completion);
-       ret = kobject_init_and_add(&bc->kobj_holder.kobj, &bow_ktype,
-                                  &disk_to_dev(dm_disk(md))->kobj, "%s",
-                                  "bow");
-       if (ret) {
-               ti->error = "Cannot create sysfs node";
-               goto bad;
-       }
-
        mutex_init(&bc->ranges_lock);
        bc->ranges = RB_ROOT;
        bc->bufio = dm_bufio_client_create(bc->dev->bdev, bc->block_size, 1, 0,
@@ -799,6 +790,22 @@ bad:
        return ret;
 }
 
+void dm_bow_resume(struct dm_target *ti)
+{
+       struct mapped_device *md = dm_table_get_md(ti->table);
+       struct bow_context *bc = ti->private;
+       int ret;
+
+       if (bc->kobj_holder.kobj.state_initialized)
+               return;
+
+       ret = kobject_init_and_add(&bc->kobj_holder.kobj, &bow_ktype,
+                                  &disk_to_dev(dm_disk(md))->kobj, "%s",
+                                  "bow");
+       if (ret)
+               ti->error = "Cannot create sysfs node";
+}
+
 /****** Handle writes ******/
 
 static int prepare_unchanged_range(struct bow_context *bc, struct bow_range *br,
@@ -1272,6 +1279,7 @@ static struct target_type bow_target = {
        .version = {1, 2, 0},
        .module = THIS_MODULE,
        .ctr    = dm_bow_ctr,
+       .resume = dm_bow_resume,
        .dtr    = dm_bow_dtr,
        .map    = dm_bow_map,
        .status = dm_bow_status,