cxlflash: Add ioctl drain
PATCH 8/29 cxlflash: Add ioctl drain
Create the ability to drain ioctls by wrapping the ioctl handler call in a read semaphore and then implementing a small routine that obtains the write semaphore, effectively creating a wait point for all currently executing ioctls.
Signed-off-by Matthew R. Ochs <[email protected]>
Signed-off-by Manoj N. Kumar <[email protected]>
--- drivers/scsi/cxlflash/common.h | 2 + drivers/scsi/cxlflash/main.c | 18 +++++-- drivers/scsi/cxlflash/superpipe.c | 104 +++++++++++++++++++++++--------------- 3 files changed, 81 insertions(+), 43 deletions(-)
drivers/scsi/cxlflash/common.h +2 -0
@@ -16,6 +16,7 @@#define _CXLFLASH_COMMON_H#include <linux/list.h> +#include <linux/rwsem.h> #include <linux/types.h> #include <scsi/scsi.h> #include <scsi/scsi_device.h>
@@ -110,6 +111,7 @@ struct cxlflash_cfg {atomic_t recovery_threads;struct mutex ctx_recovery_mutex;struct mutex ctx_tbl_list_mutex; +struct rw_semaphore ioctl_rwsem;struct ctx_info *ctx_tbl[MAX_CONTEXT ];struct list_head ctx_err_recovery;/* contexts w/ recovery pending */ struct file_operations cxl_fops;
drivers/scsi/cxlflash/main.c +15 -3
@@ -2311,6 +2311,7 @@ static int cxlflash_probe(struct pci_dev *pdev, cfg->lr_port =-1 ;mutex_init (&cfg->ctx_tbl_list_mutex);mutex_init (&cfg->ctx_recovery_mutex); +init_rwsem (&cfg->ioctl_rwsem);INIT_LIST_HEAD (&cfg->ctx_err_recovery);INIT_LIST_HEAD (&cfg->lluns);
@@ -2365,6 +2366,19 @@ out_remove: }/** +* drain_ioctls() - wait until all currently executing ioctls have completed +* @cfg: Internal structure associated with the host. +* +* Obtain write access to read/write semaphore that wraps ioctl +* handling to 'drain' ioctls currently executing. +*/ +static void drain_ioctls (struct cxlflash_cfg *cfg) +{ +down_write (&cfg->ioctl_rwsem); +up_write (&cfg->ioctl_rwsem); +} + +/** * cxlflash_pci_error_detected() - called when a PCI error is detected * @pdev: PCI device struct. * @state: PCI channel state.
@@ -2383,16 +2397,14 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev,switch (state) {case pci_channel_io_frozen: cfg->state =STATE_LIMBO ; - -/* Turn off legacy I/O */ scsi_block_requests (cfg->host); +drain_ioctls (cfg); rc =cxlflash_mark_contexts_error (cfg);if (unlikely (rc))dev_err (dev,"%s: Failed to mark user contexts!(%d)\n" , __func__, rc);term_mc (cfg,UNDO_START );stop_afu (cfg); -return PCI_ERS_RESULT_NEED_RESET ;case pci_channel_io_perm_failure: cfg->state =STATE_FAILTERM ;
drivers/scsi/cxlflash/superpipe.c +64 -40
148 lines not on this page · raw message
Signature · 1 line
2.1.0