* [PATCH 0/4] add ro state control function for nvdimm drivers
@ 2021-10-27 12:09 Huaisheng Ye
2021-10-27 12:09 ` [PATCH 1/4] libnvdimm: add a ro state control function for nvdimm Huaisheng Ye
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Huaisheng Ye @ 2021-10-27 12:09 UTC (permalink / raw)
To: dan.j.williams, hch, vishal.l.verma, dave.jiang, ira.weiny
Cc: nvdimm, linux-kernel, Huaisheng Ye
libndctl failed to pass for the reason of writing pmem disk when running
ndctl testing.
Here is the error message below,
namespace6.0: failed to write /dev/pmem6
check_namespaces: namespace6.0 validate_bdev failed
ndctl-test1 failed: -6
Commit 98f49b63e84d4ee1a5c327d0b5f4e8699f6c70fe removes set_device_ro and
e00adcadf3af7a8335026d71ab9f0e0a922191ac adds a new set_read_only method
to allow for driver-specific processing when changing the block device's
read-only state.
Current drivers nd_pmem, nd_blk and nd_btt don't have the capability to
enable or disable write protect (read-only) state. Without that,
blkdev_roset just modifies the value of bd_read_only of struct block_device
and returns success to ioctl of block device. Error would happen when writing
read-only disk next.
Add ro state control function in libnvdimm for this purpose, and implement
set_read_only for BLKROSET.
Huaisheng Ye (4):
libnvdimm: add a ro state control function for nvdimm
libnvdimm/pmem: implement ->set_read_only to hook into BLKROSET
processing
libnvdimm/blk: implement ->set_read_only to hook into BLKROSET
processing
libnvdimm/btt: implement ->set_read_only to hook into BLKROSET
processing
drivers/nvdimm/blk.c | 1 +
drivers/nvdimm/btt.c | 1 +
drivers/nvdimm/bus.c | 17 +++++++++++++++++
drivers/nvdimm/nd.h | 1 +
drivers/nvdimm/pmem.c | 1 +
5 files changed, 21 insertions(+)
--
2.27.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] libnvdimm: add a ro state control function for nvdimm
2021-10-27 12:09 [PATCH 0/4] add ro state control function for nvdimm drivers Huaisheng Ye
@ 2021-10-27 12:09 ` Huaisheng Ye
2021-10-27 12:09 ` [PATCH 2/4] libnvdimm/pmem: implement ->set_read_only to hook into BLKROSET processing Huaisheng Ye
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Huaisheng Ye @ 2021-10-27 12:09 UTC (permalink / raw)
To: dan.j.williams, hch, vishal.l.verma, dave.jiang, ira.weiny
Cc: nvdimm, linux-kernel, Huaisheng Ye
libndctl failed to pass when writing pmem disk.
Here is the error message below,
namespace6.0: failed to write /dev/pmem6
check_namespaces: namespace6.0 validate_bdev failed
ndctl-test1 failed: -6
Commit 98f49b63e84d4ee1a5c327d0b5f4e8699f6c70fe removes set_device_ro and
e00adcadf3af7a8335026d71ab9f0e0a922191ac adds a new set_read_only method
to allow for driver-specific processing when changing the block device's
read-only state.
Current drivers nd_pmem, nd_blk and nd_btt don't have the capability to
enable or disable write protect (read-only) state. Without that,
blkdev_roset just modifies the value of bd_read_only of struct block_device
and returns success to ioctl of block device. Error would happen when writing
read-only disk next.
Add ro state control function in libnvdimm for this purpose.
Signed-off-by: Huaisheng Ye <huaisheng.ye@intel.com>
---
drivers/nvdimm/bus.c | 17 +++++++++++++++++
drivers/nvdimm/nd.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 9dc7f3edd42b..299dd5e11ae7 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -636,6 +636,23 @@ void nvdimm_check_and_set_ro(struct gendisk *disk)
}
EXPORT_SYMBOL(nvdimm_check_and_set_ro);
+int nd_set_ro(struct block_device *bdev, bool ro)
+{
+ struct gendisk *disk = bdev->bd_disk;
+ struct device *dev = disk_to_dev(disk)->parent;
+ int disk_ro = get_disk_ro(disk);
+
+ /* nothing to change with ro state */
+ if (disk_ro == ro)
+ return 0;
+
+ dev_info(dev, "set %s to read-%s\n",
+ disk->disk_name, ro ? "only" : "write");
+ set_disk_ro(disk, ro);
+ return 0;
+}
+EXPORT_SYMBOL(nd_set_ro);
+
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 5467ebbb4a6b..f1cf3eb21292 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -512,6 +512,7 @@ void nvdimm_bus_lock(struct device *dev);
void nvdimm_bus_unlock(struct device *dev);
bool is_nvdimm_bus_locked(struct device *dev);
void nvdimm_check_and_set_ro(struct gendisk *disk);
+int nd_set_ro(struct block_device *bdev, bool ro);
void nvdimm_drvdata_release(struct kref *kref);
void put_ndd(struct nvdimm_drvdata *ndd);
int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd);
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] libnvdimm/pmem: implement ->set_read_only to hook into BLKROSET processing
2021-10-27 12:09 [PATCH 0/4] add ro state control function for nvdimm drivers Huaisheng Ye
2021-10-27 12:09 ` [PATCH 1/4] libnvdimm: add a ro state control function for nvdimm Huaisheng Ye
@ 2021-10-27 12:09 ` Huaisheng Ye
2021-10-27 12:09 ` [PATCH 3/4] libnvdimm/blk: " Huaisheng Ye
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Huaisheng Ye @ 2021-10-27 12:09 UTC (permalink / raw)
To: dan.j.williams, hch, vishal.l.verma, dave.jiang, ira.weiny
Cc: nvdimm, linux-kernel, Huaisheng Ye
Implement the ->set_read_only method for nd_pmem.
Signed-off-by: Huaisheng Ye <huaisheng.ye@intel.com>
---
drivers/nvdimm/pmem.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index ef4950f80832..38ede1f44f5f 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -282,6 +282,7 @@ static const struct block_device_operations pmem_fops = {
.owner = THIS_MODULE,
.submit_bio = pmem_submit_bio,
.rw_page = pmem_rw_page,
+ .set_read_only = nd_set_ro,
};
static int pmem_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff,
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] libnvdimm/blk: implement ->set_read_only to hook into BLKROSET processing
2021-10-27 12:09 [PATCH 0/4] add ro state control function for nvdimm drivers Huaisheng Ye
2021-10-27 12:09 ` [PATCH 1/4] libnvdimm: add a ro state control function for nvdimm Huaisheng Ye
2021-10-27 12:09 ` [PATCH 2/4] libnvdimm/pmem: implement ->set_read_only to hook into BLKROSET processing Huaisheng Ye
@ 2021-10-27 12:09 ` Huaisheng Ye
2021-10-27 12:09 ` [PATCH 4/4] libnvdimm/btt: " Huaisheng Ye
2021-11-09 8:14 ` [PATCH 0/4] add ro state control function for nvdimm drivers Christoph Hellwig
4 siblings, 0 replies; 6+ messages in thread
From: Huaisheng Ye @ 2021-10-27 12:09 UTC (permalink / raw)
To: dan.j.williams, hch, vishal.l.verma, dave.jiang, ira.weiny
Cc: nvdimm, linux-kernel, Huaisheng Ye
Implement the ->set_read_only method for nd_blk.
Signed-off-by: Huaisheng Ye <huaisheng.ye@intel.com>
---
drivers/nvdimm/blk.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c
index 088d3dd6f6fa..9d76980ebff7 100644
--- a/drivers/nvdimm/blk.c
+++ b/drivers/nvdimm/blk.c
@@ -226,6 +226,7 @@ static int nsblk_rw_bytes(struct nd_namespace_common *ndns,
static const struct block_device_operations nd_blk_fops = {
.owner = THIS_MODULE,
.submit_bio = nd_blk_submit_bio,
+ .set_read_only = nd_set_ro,
};
static void nd_blk_release_disk(void *disk)
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] libnvdimm/btt: implement ->set_read_only to hook into BLKROSET processing
2021-10-27 12:09 [PATCH 0/4] add ro state control function for nvdimm drivers Huaisheng Ye
` (2 preceding siblings ...)
2021-10-27 12:09 ` [PATCH 3/4] libnvdimm/blk: " Huaisheng Ye
@ 2021-10-27 12:09 ` Huaisheng Ye
2021-11-09 8:14 ` [PATCH 0/4] add ro state control function for nvdimm drivers Christoph Hellwig
4 siblings, 0 replies; 6+ messages in thread
From: Huaisheng Ye @ 2021-10-27 12:09 UTC (permalink / raw)
To: dan.j.williams, hch, vishal.l.verma, dave.jiang, ira.weiny
Cc: nvdimm, linux-kernel, Huaisheng Ye
Implement the ->set_read_only method for nd_btt.
Signed-off-by: Huaisheng Ye <huaisheng.ye@intel.com>
---
drivers/nvdimm/btt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 92dec4952297..91fcdac7858f 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1514,6 +1514,7 @@ static const struct block_device_operations btt_fops = {
.submit_bio = btt_submit_bio,
.rw_page = btt_rw_page,
.getgeo = btt_getgeo,
+ .set_read_only = nd_set_ro,
};
static int btt_blk_init(struct btt *btt)
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] add ro state control function for nvdimm drivers
2021-10-27 12:09 [PATCH 0/4] add ro state control function for nvdimm drivers Huaisheng Ye
` (3 preceding siblings ...)
2021-10-27 12:09 ` [PATCH 4/4] libnvdimm/btt: " Huaisheng Ye
@ 2021-11-09 8:14 ` Christoph Hellwig
4 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-11-09 8:14 UTC (permalink / raw)
To: Huaisheng Ye
Cc: dan.j.williams, hch, vishal.l.verma, dave.jiang, ira.weiny,
nvdimm, linux-kernel
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-09 8:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 12:09 [PATCH 0/4] add ro state control function for nvdimm drivers Huaisheng Ye
2021-10-27 12:09 ` [PATCH 1/4] libnvdimm: add a ro state control function for nvdimm Huaisheng Ye
2021-10-27 12:09 ` [PATCH 2/4] libnvdimm/pmem: implement ->set_read_only to hook into BLKROSET processing Huaisheng Ye
2021-10-27 12:09 ` [PATCH 3/4] libnvdimm/blk: " Huaisheng Ye
2021-10-27 12:09 ` [PATCH 4/4] libnvdimm/btt: " Huaisheng Ye
2021-11-09 8:14 ` [PATCH 0/4] add ro state control function for nvdimm drivers Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).