Merge branch 'svn-trunk'

This commit is contained in:
Bart Van Assche
2019-02-11 19:16:26 -08:00
11 changed files with 85 additions and 91 deletions
+2 -8
View File
@@ -563,8 +563,6 @@ struct scst_dev_type
unsigned no_proc:1;
unsigned exec_sync:1;
unsigned pr_cmds_notifications:1;
int threads_num;
@@ -607,9 +605,6 @@ execution in the atomic (non-sleeping) context.
<item> <bf/no_proc/ - true, if no /proc files should be automatically
created by SCST for this dev handler
<item> <bf/exec_sync/ - should be true, if exec() is synchronous. This
is a hint to SCST core to optimize commands order management.
<item> <bf/pr_cmds_notifications/ - should be set if the device wants to
receive notification of Persistent Reservation commands (PR OUT only)
Note: The notifications will not be sent if the command failed.
@@ -682,9 +677,8 @@ Returns:
mid-level.
</itemize>
If this function provides sync execution, you should set
exec_sync flag and consider to setup dedicated threads by
setting <it/threads_num/ > 0.
If this function provides sync execution, you should consider to setup
dedicated threads by setting <it/threads_num/ > 0.
Optional, if not set, the commands will be sent directly to SCSI
device.
+12 -20
View File
@@ -448,17 +448,16 @@ enum scst_exec_context {
** Return codes for dev handler's exec()
*************************************************************/
/*
* The cmd is completed, go to other ones. It doesn't necessary to be really
* completed, it can still be being processed. This code means that SCST
* core should start performing post processing actions for this cmd, like
* increase SN and reactivate deferred commands, if allowed, and start
* processing other commands.
*/
#define SCST_EXEC_COMPLETED 0
enum scst_exec_res {
/*
* The device handler has finished executing the command or has
* started executing the command asynchronously.
*/
SCST_EXEC_COMPLETED = 0,
/* The cmd should continue staying on the EXEC phase */
#define SCST_EXEC_NOT_COMPLETED 1
/* Pass through the command to the SCSI mid-level. */
SCST_EXEC_NOT_COMPLETED = 1,
};
/*************************************************************
** Session initialization phases
@@ -1381,12 +1380,6 @@ struct scst_dev_type {
unsigned no_proc:1;
#endif
/*
* Should be true, if exec() is synchronous. This is a hint to SCST core
* to optimize commands order management.
*/
unsigned exec_sync:1;
/*
* Should be set if the device wants to receive notification of
* Persistent Reservation commands (PR OUT only)
@@ -1454,9 +1447,8 @@ struct scst_dev_type {
* - SCST_EXEC_NOT_COMPLETED - the cmd should be sent to SCSI
* mid-level.
*
* If this function provides sync execution, you should set
* exec_sync flag and consider to setup dedicated threads by
* setting threads_num > 0.
* If this function provides sync execution, you should to set up
* dedicated threads by setting threads_num > 0.
*
* Dev handlers implementing internal queuing in their exec() callback
* should call scst_check_local_events() just before the actual
@@ -1465,7 +1457,7 @@ struct scst_dev_type {
* OPTIONAL, if not set, the commands will be sent directly to SCSI
* device.
*/
int (*exec)(struct scst_cmd *cmd);
enum scst_exec_res (*exec)(struct scst_cmd *cmd);
/*
* Called to notify dev handler about the result of cmd execution
+7 -6
View File
@@ -45,10 +45,10 @@
static int disk_attach(struct scst_device *dev);
static void disk_detach(struct scst_device *dev);
static int disk_parse(struct scst_cmd *cmd);
static int disk_perf_exec(struct scst_cmd *cmd);
static enum scst_exec_res disk_perf_exec(struct scst_cmd *cmd);
static int disk_done(struct scst_cmd *cmd);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
static int disk_exec(struct scst_cmd *cmd);
static enum scst_exec_res disk_exec(struct scst_cmd *cmd);
static bool disk_on_sg_tablesize_low(struct scst_cmd *cmd);
#endif
@@ -396,9 +396,10 @@ out_complete:
}
/* Executes command and split CDB, if necessary */
static int disk_exec(struct scst_cmd *cmd)
static enum scst_exec_res disk_exec(struct scst_cmd *cmd)
{
int res, rc;
enum scst_exec_res res;
int rc;
struct disk_work work;
struct scst_device *dev = cmd->dev;
unsigned int offset, cur_len; /* in blocks */
@@ -583,9 +584,9 @@ out_error:
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) */
static int disk_perf_exec(struct scst_cmd *cmd)
static enum scst_exec_res disk_perf_exec(struct scst_cmd *cmd)
{
int res;
enum scst_exec_res res;
int opcode = cmd->cdb[0];
TRACE_ENTRY();
+3 -3
View File
@@ -45,7 +45,7 @@ static int modisk_attach(struct scst_device *);
static void modisk_detach(struct scst_device *);
static int modisk_parse(struct scst_cmd *);
static int modisk_done(struct scst_cmd *);
static int modisk_perf_exec(struct scst_cmd *);
static enum scst_exec_res modisk_perf_exec(struct scst_cmd *);
static struct scst_dev_type modisk_devtype = {
.name = MODISK_NAME,
@@ -308,9 +308,9 @@ static int modisk_done(struct scst_cmd *cmd)
return res;
}
static int modisk_perf_exec(struct scst_cmd *cmd)
static enum scst_exec_res modisk_perf_exec(struct scst_cmd *cmd)
{
int res = SCST_EXEC_NOT_COMPLETED;
enum scst_exec_res res = SCST_EXEC_NOT_COMPLETED;
int opcode = cmd->cdb[0];
TRACE_ENTRY();
+3 -3
View File
@@ -50,7 +50,7 @@ static int tape_attach(struct scst_device *);
static void tape_detach(struct scst_device *);
static int tape_parse(struct scst_cmd *);
static int tape_done(struct scst_cmd *);
static int tape_perf_exec(struct scst_cmd *);
static enum scst_exec_res tape_perf_exec(struct scst_cmd *);
static struct scst_dev_type tape_devtype = {
.name = TAPE_NAME,
@@ -336,9 +336,9 @@ out:
return res;
}
static int tape_perf_exec(struct scst_cmd *cmd)
static enum scst_exec_res tape_perf_exec(struct scst_cmd *cmd)
{
int res = SCST_EXEC_NOT_COMPLETED;
enum scst_exec_res res = SCST_EXEC_NOT_COMPLETED;
int opcode = cmd->cdb[0];
TRACE_ENTRY();
+2 -2
View File
@@ -913,10 +913,10 @@ out:
return;
}
static int dev_user_exec(struct scst_cmd *cmd)
static enum scst_exec_res dev_user_exec(struct scst_cmd *cmd)
{
struct scst_user_cmd *ucmd = cmd->dh_priv;
int res = SCST_EXEC_COMPLETED;
enum scst_exec_res res = SCST_EXEC_COMPLETED;
TRACE_ENTRY();
+18 -16
View File
@@ -331,10 +331,10 @@ static int vcdrom_get_supported_opcodes(struct scst_cmd *cmd,
static int vdisk_parse(struct scst_cmd *);
static int vcdrom_parse(struct scst_cmd *);
static int non_fileio_parse(struct scst_cmd *);
static int fileio_exec(struct scst_cmd *cmd);
static int vcdrom_exec(struct scst_cmd *cmd);
static int blockio_exec(struct scst_cmd *cmd);
static int nullio_exec(struct scst_cmd *cmd);
static enum scst_exec_res fileio_exec(struct scst_cmd *cmd);
static enum scst_exec_res vcdrom_exec(struct scst_cmd *cmd);
static enum scst_exec_res blockio_exec(struct scst_cmd *cmd);
static enum scst_exec_res nullio_exec(struct scst_cmd *cmd);
static void blockio_on_alua_state_change_start(struct scst_device *dev,
enum scst_tg_state old_state, enum scst_tg_state new_state);
static void blockio_on_alua_state_change_finish(struct scst_device *dev,
@@ -760,7 +760,6 @@ static vdisk_op_fn nullio_ops[256];
static struct scst_dev_type vdisk_file_devtype = {
.name = "vdisk_fileio",
.type = TYPE_DISK,
.exec_sync = 1,
.threads_num = -1,
.parse_atomic = 1,
.dev_done_atomic = 1,
@@ -922,7 +921,6 @@ static struct scst_dev_type vdisk_null_devtype = {
static struct scst_dev_type vcdrom_devtype = {
.name = "vcdrom",
.type = TYPE_ROM,
.exec_sync = 1,
.threads_num = -1,
.parse_atomic = 1,
.dev_done_atomic = 1,
@@ -3094,7 +3092,8 @@ static int fileio_alloc_and_parse(struct scst_cmd *cmd)
TRACE_ENTRY();
p = kmem_cache_zalloc(vdisk_cmd_param_cachep, cmd->cmd_gfp_mask);
p = kmem_cache_zalloc(vdisk_cmd_param_cachep,
in_interrupt() ? GFP_ATOMIC : cmd->cmd_gfp_mask);
if (!p) {
scst_set_busy(cmd);
goto out_err;
@@ -3161,9 +3160,10 @@ out:
return res;
}
static int vdev_do_job(struct scst_cmd *cmd, const vdisk_op_fn *ops)
static enum scst_exec_res vdev_do_job(struct scst_cmd *cmd,
const vdisk_op_fn *ops)
{
int res;
enum scst_exec_res res;
uint8_t *cdb = cmd->cdb;
int opcode = cdb[0];
struct vdisk_cmd_params *p = cmd->dh_priv;
@@ -3225,7 +3225,7 @@ out_invalid_opcode:
goto out_compl;
}
static int fileio_exec(struct scst_cmd *cmd)
static enum scst_exec_res fileio_exec(struct scst_cmd *cmd)
{
struct scst_vdisk_dev *virt_dev = cmd->dev->dh_priv;
const vdisk_op_fn *ops = virt_dev->vdev_devt->devt_priv;
@@ -3269,6 +3269,8 @@ static void fileio_async_complete(struct kiocb *iocb, long ret, long ret2)
struct vdisk_cmd_params *p = container_of(iocb, typeof(*p), async.iocb);
struct scst_cmd *cmd = p->cmd;
WARN_ON_ONCE(ret >= 0 && ret != cmd->bufflen);
if (ret < 0 &&
scst_cmd_get_data_direction(cmd) & SCST_DATA_WRITE)
scst_set_cmd_error(cmd,
@@ -3458,12 +3460,12 @@ out:
return res;
}
static int blockio_exec(struct scst_cmd *cmd)
static enum scst_exec_res blockio_exec(struct scst_cmd *cmd)
{
struct scst_vdisk_dev *virt_dev = cmd->dev->dh_priv;
const vdisk_op_fn *ops = virt_dev->vdev_devt->devt_priv;
struct vdisk_cmd_params p;
int res;
enum scst_exec_res res;
EXTRACHECKS_BUG_ON(!ops);
@@ -3504,12 +3506,12 @@ err:
goto out;
}
static int nullio_exec(struct scst_cmd *cmd)
static enum scst_exec_res nullio_exec(struct scst_cmd *cmd)
{
struct scst_vdisk_dev *virt_dev = cmd->dev->dh_priv;
const vdisk_op_fn *ops = virt_dev->vdev_devt->devt_priv;
struct vdisk_cmd_params p;
int res;
enum scst_exec_res res;
EXTRACHECKS_BUG_ON(!ops);
@@ -3532,9 +3534,9 @@ err:
goto out;
}
static int vcdrom_exec(struct scst_cmd *cmd)
static enum scst_exec_res vcdrom_exec(struct scst_cmd *cmd)
{
int res = SCST_EXEC_COMPLETED;
enum scst_exec_res res = SCST_EXEC_COMPLETED;
int opcode = cmd->cdb[0];
struct scst_vdisk_dev *virt_dev = cmd->dev->dh_priv;
+6 -4
View File
@@ -1616,9 +1616,10 @@ out:
return;
}
int scst_cm_ext_copy_exec(struct scst_cmd *ec_cmd)
enum scst_exec_res scst_cm_ext_copy_exec(struct scst_cmd *ec_cmd)
{
int res = SCST_EXEC_COMPLETED, rc;
enum scst_exec_res res = SCST_EXEC_COMPLETED;
int rc;
struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors;
TRACE_ENTRY();
@@ -2273,9 +2274,10 @@ out:
return;
}
int scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd)
enum scst_exec_res scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd)
{
int res = SCST_EXEC_COMPLETED, action;
enum scst_exec_res res = SCST_EXEC_COMPLETED;
int action;
TRACE_ENTRY();
+2 -2
View File
@@ -6859,9 +6859,9 @@ out_finish:
goto out;
}
int scst_cmp_wr_local(struct scst_cmd *cmd)
enum scst_exec_res scst_cmp_wr_local(struct scst_cmd *cmd)
{
int res = SCST_EXEC_COMPLETED;
enum scst_exec_res res = SCST_EXEC_COMPLETED;
struct scst_cwr_priv *cwrp;
uint8_t read16_cdb[16];
struct scst_cmd *rcmd;
+6 -5
View File
@@ -862,7 +862,7 @@ void scst_unthrottle_cmd(struct scst_cmd *cmd);
int scst_do_internal_parsing(struct scst_cmd *cmd);
int scst_parse_descriptors(struct scst_cmd *cmd);
int scst_cmp_wr_local(struct scst_cmd *cmd);
enum scst_exec_res scst_cmp_wr_local(struct scst_cmd *cmd);
int scst_pr_init(struct scst_device *dev);
void scst_pr_cleanup(struct scst_device *dev);
@@ -912,8 +912,8 @@ bool scst_cm_on_del_lun(struct scst_acg_dev *acg_dev,
int scst_cm_parse_descriptors(struct scst_cmd *cmd);
void scst_cm_free_descriptors(struct scst_cmd *cmd);
int scst_cm_ext_copy_exec(struct scst_cmd *cmd);
int scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd);
enum scst_exec_res scst_cm_ext_copy_exec(struct scst_cmd *cmd);
enum scst_exec_res scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
void sess_cm_list_id_cleanup_work_fn(void *p);
@@ -965,11 +965,12 @@ static inline int scst_cm_parse_descriptors(struct scst_cmd *cmd)
}
static inline void scst_cm_free_descriptors(struct scst_cmd *cmd) {}
static inline int scst_cm_ext_copy_exec(struct scst_cmd *cmd)
static inline enum scst_exec_res scst_cm_ext_copy_exec(struct scst_cmd *cmd)
{
return SCST_EXEC_NOT_COMPLETED;
}
static inline int scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd)
static inline enum scst_exec_res scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd)
{
return SCST_EXEC_NOT_COMPLETED;
}
+24 -22
View File
@@ -953,7 +953,7 @@ int scst_pre_parse(struct scst_cmd *cmd)
#ifdef CONFIG_SCST_STRICT_SERIALIZING
cmd->inc_expected_sn_on_done = 1;
#else
cmd->inc_expected_sn_on_done = devt->exec_sync || cmd->cmd_naca ||
cmd->inc_expected_sn_on_done = cmd->cmd_naca ||
(!dev->has_own_order_mgmt &&
(dev->queue_alg == SCST_QUEUE_ALG_0_RESTRICTED_REORDER ||
cmd->queue_type == SCST_CMD_QUEUE_ORDERED));
@@ -1327,7 +1327,7 @@ set_res:
* be because of the SCST_TGT_DEV_AFTER_* optimization, but during
* parsing data_direction can change, so we need to recheck.
*/
if (unlikely(scst_cmd_atomic(cmd) &&
if (unlikely(scst_cmd_atomic(cmd) && cmd->status == 0 &&
!(cmd->data_direction & SCST_DATA_WRITE))) {
TRACE_DBG_FLAG(TRACE_DEBUG|TRACE_MINOR, "Atomic context and "
"non-WRITE data direction, rescheduling (cmd %p)", cmd);
@@ -2247,9 +2247,9 @@ static void scst_cmd_done_local(struct scst_cmd *cmd, int next_state,
return;
}
static int scst_report_luns_local(struct scst_cmd *cmd)
static enum scst_exec_res scst_report_luns_local(struct scst_cmd *cmd)
{
int res = SCST_EXEC_COMPLETED;
enum scst_exec_res res = SCST_EXEC_COMPLETED;
int dev_cnt = 0;
int buffer_size;
int i;
@@ -2348,9 +2348,9 @@ out_put_err:
goto out_compl;
}
static int scst_request_sense_local(struct scst_cmd *cmd)
static enum scst_exec_res scst_request_sense_local(struct scst_cmd *cmd)
{
int res = SCST_EXEC_COMPLETED;
enum scst_exec_res res = SCST_EXEC_COMPLETED;
struct scst_tgt_dev *tgt_dev = cmd->tgt_dev;
uint8_t *buffer;
int buffer_size = 0, sl = 0;
@@ -2720,9 +2720,9 @@ out_err_put:
goto out_compl;
}
static int scst_maintenance_in(struct scst_cmd *cmd)
static enum scst_exec_res scst_maintenance_in(struct scst_cmd *cmd)
{
int res;
enum scst_exec_res res;
TRACE_ENTRY();
@@ -2742,9 +2742,9 @@ static int scst_maintenance_in(struct scst_cmd *cmd)
return res;
}
static int scst_reserve_local(struct scst_cmd *cmd)
static enum scst_exec_res scst_reserve_local(struct scst_cmd *cmd)
{
int res = SCST_EXEC_NOT_COMPLETED;
enum scst_exec_res res = SCST_EXEC_NOT_COMPLETED;
struct scst_device *dev;
struct scst_lksb pr_lksb;
@@ -2818,9 +2818,9 @@ out_done:
goto out;
}
static int scst_release_local(struct scst_cmd *cmd)
static enum scst_exec_res scst_release_local(struct scst_cmd *cmd)
{
int res = SCST_EXEC_NOT_COMPLETED;
enum scst_exec_res res = SCST_EXEC_NOT_COMPLETED;
struct scst_device *dev;
struct scst_lksb pr_lksb;
@@ -2894,7 +2894,7 @@ out_done:
}
/* No locks, no IRQ or IRQ-disabled context allowed */
static int scst_persistent_reserve_in_local(struct scst_cmd *cmd)
static enum scst_exec_res scst_persistent_reserve_in_local(struct scst_cmd *cmd)
{
struct scst_device *dev;
struct scst_tgt_dev *tgt_dev;
@@ -3002,9 +3002,10 @@ out_unsup_act:
}
/* No locks, no IRQ or IRQ-disabled context allowed */
static int scst_persistent_reserve_out_local(struct scst_cmd *cmd)
static enum scst_exec_res
scst_persistent_reserve_out_local(struct scst_cmd *cmd)
{
int res = SCST_EXEC_COMPLETED;
enum scst_exec_res res = SCST_EXEC_COMPLETED;
struct scst_device *dev;
struct scst_tgt_dev *tgt_dev;
struct scst_session *session;
@@ -3401,9 +3402,9 @@ out:
}
/* cmd must be additionally referenced to not die inside */
static int scst_do_real_exec(struct scst_cmd *cmd)
static enum scst_exec_res scst_do_real_exec(struct scst_cmd *cmd)
{
int res = SCST_EXEC_NOT_COMPLETED;
enum scst_exec_res res = SCST_EXEC_NOT_COMPLETED;
int rc;
struct scst_device *dev = cmd->dev;
struct scst_dev_type *devt = cmd->devt;
@@ -3523,7 +3524,7 @@ out_done:
goto out;
}
typedef int (*scst_local_exec_fn)(struct scst_cmd *cmd);
typedef enum scst_exec_res (*scst_local_exec_fn)(struct scst_cmd *cmd);
static scst_local_exec_fn scst_local_fns[256] = {
[RESERVE] = scst_reserve_local,
@@ -3540,9 +3541,9 @@ static scst_local_exec_fn scst_local_fns[256] = {
[MAINTENANCE_IN] = scst_maintenance_in,
};
static int scst_do_local_exec(struct scst_cmd *cmd)
static enum scst_exec_res scst_do_local_exec(struct scst_cmd *cmd)
{
int res;
enum scst_exec_res res;
struct scst_tgt_dev *tgt_dev = cmd->tgt_dev;
TRACE_ENTRY();
@@ -3577,9 +3578,10 @@ out_done:
goto out;
}
static int scst_local_exec(struct scst_cmd *cmd)
static enum scst_exec_res scst_local_exec(struct scst_cmd *cmd)
{
int res, rc;
enum scst_exec_res res;
int rc;
TRACE_ENTRY();