nvme: add a dedicated .c file for sysfs interface
RFC 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.
---
I have introduced this patch as RFC to get more opinions from maintainers if they also think this can help with maintaining and extending the core code in the future.
--- drivers/nvme/host/Makefile | 2 +- drivers/nvme/host/core.c | 650 +----------------------------------- drivers/nvme/host/nvme.h | 4 + drivers/nvme/host/sysfs.c | 657 +++++++++++++++++++++++++++++++++++++ 4 files changed, 664 insertions(+), 649 deletions(-) create mode 100644 drivers/nvme/host/sysfs.c
drivers/nvme/host/Makefile +1 -1
@@ -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
@@ -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 +657 -0
657 lines not on this page · raw message
Signature · 1 line
2.18.1
Sagi Grimberg
maintainerQuoted 6 lines
The
core.cfile 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.
Don't mind having it..
[...]
drivers/nvme/host/sysfs.c line 1
Quoted 7 lines
drivers/nvme/host/sysfs.c new file +1
-0@@ -0,0 +1,657 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
Linux-OpenIB ?
drivers/nvme/host/sysfs.c line 5
Quoted 4 lines
drivers/nvme/host/sysfs.c new file +4
-0+/* +* Sysfs interface for the NVMe core driver. +* +* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Not an expert in this matter, but does copy-pasting full hunk of code from one file to a new one qualify for copyrights claims?
Quoted 11 lines · Sagi Grimberg
Quoted 6 lines
The
core.cfile 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.Don't mind having it..
[...]
Quoted 10 lines
drivers/nvme/host/sysfs.c line 1
Quoted 7 lines
drivers/nvme/host/sysfs.c new file +1
-0@@ -0,0 +1,657 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB Linux-OpenIB ?
copy/paste bug.
should be only // SPDX-License-Identifier: GPL-2.0
Quoted 8 lines
Quoted 5 lines
drivers/nvme/host/sysfs.c new file +4
-0+/* +* Sysfs interface for the NVMe core driver. +* +* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Not an expert in this matter, but does copy-pasting full hunk of code from one file to a new one qualify for copyrights claims?
I'm not an expert as well. I'll remove it. Don't really care )
Jens Axboe
maintainerQuoted 10 lines · Sagi Grimberg
drivers/nvme/host/sysfs.c line 1
Quoted 7 lines
drivers/nvme/host/sysfs.c new file +1
-0@@ -0,0 +1,657 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB Linux-OpenIB ?
Quoted 7 lines
drivers/nvme/host/sysfs.c line 5
Quoted 4 lines
drivers/nvme/host/sysfs.c new file +4
-0+/* +* Sysfs interface for the NVMe core driver. +* +* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. Not an expert in this matter, but does copy-pasting full hunk of code from one file to a new one qualify for copyrights claims?
IANAL, but that seems bogus for sure. Adding a copyright claim for just moving code is nonsense.
Signature · 1 line
Jens Axboe
Quoted 16 lines · Jens Axboe
Quoted 15 lines · Sagi Grimberg
drivers/nvme/host/sysfs.c line 1
Quoted 7 lines
drivers/nvme/host/sysfs.c new file +1
-0@@ -0,0 +1,657 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB Linux-OpenIB ?
Quoted 4 lines
drivers/nvme/host/sysfs.c new file +4
-0+/* +* Sysfs interface for the NVMe core driver. +* +* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Quoted 6 lines
Quoted 2 lines
Not an expert in this matter, but does copy-pasting full hunk of code from one file to a new one qualify for copyrights claims?
IANAL, but that seems bogus for sure. Adding a copyright claim for just moving code is nonsense.
My bad, as I mentioned to Sagi I will remove it.
I wanted to get feedback on the concept.
If the only comments I get is for copyright then we're good I guess ?
Jens Axboe
maintainerQuoted 1 line · Max Gurtovoy
If the only comments I get is for copyright then we're good I guess ?
Didn't closely review it, but conceptually I agree with the change. Declutters core.c and usually there's little need to touch the sysfs bits.
Signature · 1 line
Jens Axboe
Quoted 7 lines · Jens Axboe
Quoted 1 line · Max Gurtovoy
If the only comments I get is for copyright then we're good I guess ?
Didn't closely review it, but conceptually I agree with the change. Declutters
core.cand usually there's little need to touch the sysfs bits.
Ok. Let me send it again with fixing the copyright and removing the RFC and the concept agreed.