Message ID | 20201110210708.5912-1-javier@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [V3] nvme: enable ro namespace for ZNS without append | expand |
On Tue, Nov 10, 2020 at 10:07:08PM +0100, javier@javigon.com wrote: > - if (id->nsattr & NVME_NS_ATTR_RO) > + if (id->nsattr & NVME_NS_ATTR_RO || test_bit(NVME_NS_FORCE_RO, &ns->flags)) > set_disk_ro(disk, true); If the FORCE_RO flag is set, the disk is set to read-only. If that flag is later cleared, nothing clears the disk's read-only setting. > + /* Refresh effects log page to check for changes on append support */ > + status = nvme_get_effects_log(ns->ctrl, ns->head->ids.csi, &ns->head->effects); That function just returns the cached log; no refresh occurs there.
>> - if (id->nsattr & NVME_NS_ATTR_RO) >> + if (id->nsattr & NVME_NS_ATTR_RO || test_bit(NVME_NS_FORCE_RO, &ns->flags)) >> set_disk_ro(disk, true); > > If the FORCE_RO flag is set, the disk is set to read-only. If that flag > is later cleared, nothing clears the disk's read-only setting. Yea, that is true also for the non-force case, but before it broke BLKROSET so I reverted that. We can use this FORCE_RO for BLKROSET as well I think...
On Tue, Nov 10, 2020 at 05:41:15PM -0800, Sagi Grimberg wrote: > >>> - if (id->nsattr & NVME_NS_ATTR_RO) >>> + if (id->nsattr & NVME_NS_ATTR_RO || test_bit(NVME_NS_FORCE_RO, &ns->flags)) >>> set_disk_ro(disk, true); >> >> If the FORCE_RO flag is set, the disk is set to read-only. If that flag >> is later cleared, nothing clears the disk's read-only setting. > > Yea, that is true also for the non-force case, but before it broke > BLKROSET so I reverted that. We can use this FORCE_RO for BLKROSET as > well I think... Let me prioritize the hard r/o setting. mkp actually has an older patch that did just that which I'll resurrect.
>>>> - if (id->nsattr & NVME_NS_ATTR_RO) >>>> + if (id->nsattr & NVME_NS_ATTR_RO || test_bit(NVME_NS_FORCE_RO, &ns->flags)) >>>> set_disk_ro(disk, true); >>> >>> If the FORCE_RO flag is set, the disk is set to read-only. If that flag >>> is later cleared, nothing clears the disk's read-only setting. >> >> Yea, that is true also for the non-force case, but before it broke >> BLKROSET so I reverted that. We can use this FORCE_RO for BLKROSET as >> well I think... > > Let me prioritize the hard r/o setting. mkp actually has an older patch > that did just that which I'll resurrect. Sounds good.
On 11.11.2020 00:36, Sagi Grimberg wrote: > >>>>>- if (id->nsattr & NVME_NS_ATTR_RO) >>>>>+ if (id->nsattr & NVME_NS_ATTR_RO || test_bit(NVME_NS_FORCE_RO, &ns->flags)) >>>>> set_disk_ro(disk, true); >>>> >>>>If the FORCE_RO flag is set, the disk is set to read-only. If that flag >>>>is later cleared, nothing clears the disk's read-only setting. >>> >>>Yea, that is true also for the non-force case, but before it broke >>>BLKROSET so I reverted that. We can use this FORCE_RO for BLKROSET as >>>well I think... >> >>Let me prioritize the hard r/o setting. mkp actually has an older patch >>that did just that which I'll resurrect. > >Sounds good. Cool. I'll repost fixing the log page update. I can then rebase on the patches you send for this - or you can put them on top if it is easier. Thanks!
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index fff90200497c..8a224a6f2473 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2083,7 +2083,7 @@ static void nvme_update_disk_info(struct gendisk *disk, nvme_config_discard(disk, ns); nvme_config_write_zeroes(disk, ns); - if (id->nsattr & NVME_NS_ATTR_RO) + if (id->nsattr & NVME_NS_ATTR_RO || test_bit(NVME_NS_FORCE_RO, &ns->flags)) set_disk_ro(disk, true); } @@ -2951,8 +2951,7 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi, return nvme_submit_sync_cmd(ctrl->admin_q, &c, log, size); } -static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, - struct nvme_effects_log **log) +int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log) { struct nvme_cel *cel = xa_load(&ctrl->cels, csi); int ret; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 83fb30e317e0..857fca95f016 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -449,6 +449,7 @@ struct nvme_ns { #define NVME_NS_REMOVING 0 #define NVME_NS_DEAD 1 #define NVME_NS_ANA_PENDING 2 +#define NVME_NS_FORCE_RO 3 struct nvme_fault_inject fault_inject; @@ -638,6 +639,7 @@ int nvme_delete_ctrl(struct nvme_ctrl *ctrl); int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi, void *log, size_t size, u64 offset); +int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log); struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk, struct nvme_ns_head **head, int *srcu_idx); void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx); diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index 67e87e9f306f..47679a90795c 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -54,13 +54,22 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf) struct nvme_id_ns_zns *id; int status; + /* Refresh effects log page to check for changes on append support */ + status = nvme_get_effects_log(ns->ctrl, ns->head->ids.csi, &ns->head->effects); + if (status) + return status; + /* Driver requires zone append support */ - if (!(le32_to_cpu(log->iocs[nvme_cmd_zone_append]) & - NVME_CMD_EFFECTS_CSUPP)) { + if ((le32_to_cpu(log->iocs[nvme_cmd_zone_append]) & NVME_CMD_EFFECTS_CSUPP)) { + if (test_and_clear_bit(NVME_NS_FORCE_RO, &ns->flags)) + dev_warn(ns->ctrl->device, + "append supported for zoned namespace:%d. Remove read-only mode\n", + ns->head->ns_id); + } else { + set_bit(NVME_NS_FORCE_RO, &ns->flags); dev_warn(ns->ctrl->device, - "append not supported for zoned namespace:%d\n", - ns->head->ns_id); - return -EINVAL; + "append not supported for zoned namespace:%d. Forcing to read-only mode\n", + ns->head->ns_id); } /* Lazily query controller append limit for the first zoned namespace */