nvme/target: Change max_nsid in subsystem due to ns_disable if needed
Subsystems (2)
Sagi Grimberg
maintainerPATCH v2 1/1 nvme/target: Change max_nsid in subsystem due to ns_disable if needed
From: Roy Shterman <[email protected]>
In case we disable namespaces which has the nsid like subsystem max_nsid we need to search for the next largest nsid in this subsystem. If the subsystem don't has more namespaces we set it to 0, else we take nsid from the last namespace in namespaces list because the list is sorted while inserting.
---
Changes from v1:
- Fixed compilation glitch
- moved max_nsid to a dedicated function
drivers/nvme/target/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/nvme/target/core.c +16 -0
@@ -57,6 +57,18 @@ u16 nvmet_copy_from_sgl(struct nvmet_req *req, off_t off, void *buf, size_t len)return 0 ; } +static void nvmet_subsys_update_max_nsid (struct nvmet_subsys *subsys) +{ +if (list_empty (&subsys->namespaces)) { + subsys->max_nsid =0 ; + }else { +struct nvmet_ns *ns = + list_last_entry(&subsys->namespaces, struct nvmet_ns, dev_link); + + subsys->max_nsid = ns->nsid; + } +} +static u32 nvmet_async_event_result (struct nvmet_async_event *aen) {return aen->event_type | (aen->event_info <<8 ) | (aen->log_page <<16 );
@@ -334,6 +346,10 @@ void nvmet_ns_disable(struct nvmet_ns *ns) ns->enabled = false;list_del_rcu (&ns->dev_link); + +if (ns->nsid == subsys->max_nsid) +nvmet_subsys_update_max_nsid (subsys); +mutex_unlock (&subsys->lock);/*
Signature · 1 line
2.7.4
PATCH v2 1/1 nvme/target: Change max_nsid in subsystem due to ns_disable if needed
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH v2 1/1 nvme/target: Change max_nsid in subsystem due to ns_disable if needed
In reply to Sagi Grimbergdrivers/nvme/target/core.c u16 nvmet_copy_from_sgl(struct nvmet_req *req, off_t off, void *buf, size_t len) · line 69
Quoted 8 lines
drivers/nvme/target/core.c +8
-0+if (list_empty (&subsys->namespaces)) { + subsys->max_nsid =0 ; + }else { +struct nvmet_ns *ns = + list_last_entry(&subsys->namespaces, struct nvmet_ns, dev_link); + + subsys->max_nsid = ns->nsid; + }
The line is still too long, but I'll fix it up.