[PATCH 4/4] nvmet: Add feature close connection from target side
Sagi Grimberg
sagi at grimberg.me
Mon Nov 13 12:21:43 PST 2017
Hi Israel,
> This allows the user to close any connection from target side
> by writing to the file "force_close" at the controller folder.
> Full path:
> /config/nvmet/subsystems/<SUBSYSTEM_NAME>/controllers/<CTRL_ID>/force_close
>
> Signed-off-by: Israel Rukshin <israelr at mellanox.com>
> Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
> ---
> drivers/nvme/target/configfs.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
> index 2413df6..90e5925 100644
> --- a/drivers/nvme/target/configfs.c
> +++ b/drivers/nvme/target/configfs.c
> @@ -496,10 +496,23 @@ static ssize_t nvmet_ctrl_trsvcid_show(struct config_item *item, char *page)
>
> CONFIGFS_ATTR_RO(nvmet_ctrl_, trsvcid);
>
> +static ssize_t nvmet_ctrl_force_close_store(struct config_item *item,
> + const char *page, size_t count)
Maybe simply 'delete' is a better attribute name?
> +{
> + struct nvmet_ctrl *ctrl = to_nvmet_ctrl(item);
> +
> + ctrl->ops->delete_ctrl(ctrl);
> +
What guarantees that calling delete_ctrl is safe here? Controllers can
be freed under various conditions (client disconnect, fatal_error,
device removal). What protects from user initiated force_close hitting
a use-after-free condition?
More information about the Linux-nvme
mailing list