nvme: Support user mode processing of ZNS Zone Changed AEN
PATCH 1/1 nvme: Support user mode processing of ZNS Zone Changed AEN
From: Clay Mayers <[email protected]>
The ZNS Zone-Descriptor-Changes AEN is of type notify and uses CQE.DW1 to convey the namespace of the log page to read. Unhandled notify AENs now generate an NVME_AEN uevent and include the value of CQE.DW1 as a new property when non-zero.
All unhandled notify events are include to avoid command set specific code in the aen handling. This support is planned to be used by both zone based applications and another unreleased device with an alternate command set.
--- drivers/nvme/host/core.c | 19 +++++++++++-------- drivers/nvme/host/nvme.h | 1 + 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/nvme/host/core.c +11 -8
@@ -4615,17 +4615,20 @@ static void nvme_change_uevent(struct nvme_ctrl *ctrl, char *envdata)static void nvme_aen_uevent (struct nvme_ctrl *ctrl) { -char *envp[2 ] = {NULL ,NULL }; +char *envp[3 ] = {NULL ,NULL ,NULL };u32 aen_result = ctrl->aen_result; +u32 aen_data = ctrl->aen_data; ctrl->aen_result =0 ; + ctrl->aen_data =0 ;if (!aen_result)return ; envp[0 ] =kasprintf (GFP_KERNEL ,"NVME_AEN=%#08x" , aen_result); -if (!envp[0 ]) -return ; -kobject_uevent_env (&ctrl->device->kobj,KOBJ_CHANGE , envp); + envp[1 ] =kasprintf (GFP_KERNEL ,"NVME_AEN_DATA=%#08x" , aen_data); +if (envp[0 ] && envp[1 ]) +kobject_uevent_env (&ctrl->device->kobj,KOBJ_CHANGE , envp); +kfree (envp[1 ]);kfree (envp[0 ]); }
@@ -4748,11 +4751,9 @@ static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)queue_work (nvme_wq, &ctrl->ana_work);break ;#endif -case NVME_AER_NOTICE_DISC_CHANGED : +default : ctrl->aen_result = result;break ; -default : -dev_warn (ctrl->device,"async event result %08x\n" , result); }return requeue; }
@@ -4799,8 +4800,10 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,break ; } -if (requeue) +if (requeue) { + ctrl->aen_data =le64_to_cpu (res->u64) >>32 ;queue_work (nvme_wq, &ctrl->async_event_work); + } }EXPORT_SYMBOL_GPL (nvme_complete_async_event);
drivers/nvme/host/nvme.h +1 -0
@@ -299,6 +299,7 @@ struct nvme_ctrl {u16 cctemp;u32 oaes;u32 aen_result; +u32 aen_data;u32 ctratt;unsigned int shutdown_timeout;unsigned int kato;
Signature · 1 line
2.27.0
Sagi Grimberg
maintainerQuoted 5 lines
The ZNS Zone-Descriptor-Changes AEN is of type notify and uses CQE.DW1 to convey the namespace of the log page to read. Unhandled notify AENs now generate an
NVME_AENuevent and include the value of CQE.DW1 as a new property when non-zero.
But you always send it...
Quoted 5 lines
All unhandled notify events are include to avoid command set specific code in the aen handling. This support is planned to be used by both zone based applications and another unreleased device with an alternate command set.
This needs to be split into two patches.
Quoted 37 lines
Signed-off-by Clay Mayers <[email protected]>--- drivers/nvme/host/core.c | 19 +++++++++++-------- drivers/nvme/host/nvme.h | 1 + 2 files changed, 12 insertions(+), 8 deletions(-)drivers/nvme/host/core.c +7
-4@@ -4615,17 +4615,20 @@ static void nvme_change_uevent(struct nvme_ctrl *ctrl, char *envdata)static void nvme_aen_uevent (struct nvme_ctrl *ctrl) { -char *envp[2 ] = {NULL ,NULL }; +char *envp[3 ] = {NULL ,NULL ,NULL };u32 aen_result = ctrl->aen_result; +u32 aen_data = ctrl->aen_data; ctrl->aen_result =0 ; + ctrl->aen_data =0 ;if (!aen_result)return ; envp[0 ] =kasprintf (GFP_KERNEL ,"NVME_AEN=%#08x" , aen_result); -if (!envp[0 ]) -return ; -kobject_uevent_env (&ctrl->device->kobj,KOBJ_CHANGE , envp); + envp[1 ] =kasprintf (GFP_KERNEL ,"NVME_AEN_DATA=%#08x" , aen_data); +if (envp[0 ] && envp[1 ]) +kobject_uevent_env (&ctrl->device->kobj,KOBJ_CHANGE , envp); +kfree (envp[1 ]);kfree (envp[0 ]); }
drivers/nvme/host/core.c static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result) · line 4755
Quoted 9 lines
drivers/nvme/host/core.c +1
-3@@ -4748,11 +4751,9 @@ static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)queue_work (nvme_wq, &ctrl->ana_work);break ;#endif -case NVME_AER_NOTICE_DISC_CHANGED : +default : ctrl->aen_result = result;break ; -default : -dev_warn (ctrl->device,"async event result %08x\n" , result);
I'd keep the log... and also don't know if we want to pass any unknown possible spam to userspace... not sure that being blindly forward compatible is the right choice here.
drivers/nvme/host/core.c void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, · line 4804
Quoted 10 lines
drivers/nvme/host/core.c +2
-1}return requeue; }@@ -4799,8 +4800,10 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,break ; } -if (requeue) +if (requeue) { + ctrl->aen_data =le64_to_cpu (res->u64) >>32 ;
Please use a helper for that.aen_data is not a great name... maybe use a union for that for the specific aen subtype?
Maybe it'd be better that zoned namespace aen is handled explicitly and passes a AEN_NSID env veriable to the uevent.
Quoted 17 lines
drivers/nvme/host/core.c +1
-0queue_work (nvme_wq, &ctrl->async_event_work); + } }EXPORT_SYMBOL_GPL (nvme_complete_async_event);drivers/nvme/host/nvme.h +1
-0@@ -299,6 +299,7 @@ struct nvme_ctrl {u16 cctemp;u32 oaes;u32 aen_result; +u32 aen_data;u32 ctratt;unsigned int shutdown_timeout;unsigned int kato;
Quoted 9 lines
From: Sagi Grimberg <[email protected]>
Sent: Thursday, September 29, 2022 1:19 AMQuoted 4 lines
The ZNS Zone-Descriptor-Changes AEN is of type notify and uses CQE.DW1 to convey the namespace of the log page to read. Unhandled notify AENs now generate an
NVME_AENuevent and include the value of CQE.DW1 as a new property when non-zero.But you always send it...
Thanks for the quick review and catching my mistake.
Quoted 9 lines
Quoted 6 lines
All unhandled notify events are include to avoid command set specific code in the aen handling. This support is planned to be used by both zone based applications and another unreleased device with an alternate command set.
This needs to be split into two patches.
It will be split in two for V2