Skip to contentSkip to conversation

nvme: add a dedicated .c file for sysfs interface

PATCH In review Max Gurtovoy 3 participants 4 messages Apr 24, 2023 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: add a dedicated .c file for sysfs interface

The core.c file became long and hard to maintain. Create a dedicated file to centralize the sysfs functionality. This is a common practice to separate sysfs/configfs related logic from the main driver logic .c file. For example, in the nvmet module the configfs interface has its own dedicated file.

---

changes from RFC:
- Removed RCF tag
- updated copyrights mistake
- fix License copy/paste bug (Sagi)

---
 drivers/nvme/host/Makefile |   2 +-
 drivers/nvme/host/core.c   | 650 +-----------------------------------
 drivers/nvme/host/nvme.h   |   4 +
 drivers/nvme/host/sysfs.c  | 655 +++++++++++++++++++++++++++++++++++++
 4 files changed, 662 insertions(+), 649 deletions(-)
 create mode 100644 drivers/nvme/host/sysfs.c
drivers/nvme/host/Makefile +1 -1
index e27202d22c7d..d3fc5063e4be 100644
@@ -10,7 +10,7 @@ obj-$(CONFIG_NVME_FC)			+= nvme-fc.o
 obj-$(CONFIG_NVME_TCP)			+= nvme-tcp.o
 obj-$(CONFIG_NVME_APPLE)		+= nvme-apple.o
 
-nvme-core-y				+= core.o ioctl.o
+nvme-core-y				+= core.o ioctl.o sysfs.o
 nvme-core-$(CONFIG_NVME_VERBOSE_ERRORS)	+= constants.o
 nvme-core-$(CONFIG_TRACING)		+= trace.o
 nvme-core-$(CONFIG_NVME_MULTIPATH)	+= multipath.o
drivers/nvme/host/core.c +2 -648

674 lines not on this page · raw message

drivers/nvme/host/nvme.h +4 -0
index bf46f122e9e1..f49a142e5013 100644
@@ -860,7 +860,11 @@ extern const struct attribute_group *nvme_ns_id_attr_groups[];
 extern const struct pr_ops nvme_pr_ops;
 extern const struct block_device_operations nvme_ns_head_ops;
 extern const struct attribute_group nvme_dev_attrs_group;
+extern const struct attribute_group *nvme_subsys_attrs_groups[];
+extern const struct attribute_group *nvme_dev_attr_groups[];
+extern const struct block_device_operations nvme_bdev_ops;
 
+void nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl);
 struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
 #ifdef CONFIG_NVME_MULTIPATH
 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
drivers/nvme/host/sysfs.c new file +655 -0

655 lines not on this page · raw message

Signature · 1 line
2.18.1
maintainer
#1 lore raw

I'd rephrase the title:
"nvme: move sysfs code to a dedicated sysfs.c file"

Also add a short comment that the patch does not include any functional changes.

#2 lore raw
Quoted 5 lines · Sagi Grimberg

I'd rephrase the title:
"nvme: move sysfs code to a dedicated sysfs.c file"

Also add a short comment that the patch does not include any functional changes.

Sure. Will do.

Will wait for some more comments and reviews before sending v2.

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Max Gurtovoy
Quoted 5 lines · Max Gurtovoy

The core.c file became long and hard to maintain. Create a dedicated file to centralize the sysfs functionality. This is a common practice to separate sysfs/configfs related logic from the main driver logic .c file. For example, in the nvmet module the configfs interface has its own dedicated file.

This move sounds appropriate, and change looks good.