block shift cleanups and fixes

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4912 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2013-07-04 04:26:21 +00:00
parent 6e31fd8306
commit 0043f510cb
4 changed files with 18 additions and 6 deletions

View File

@@ -166,7 +166,7 @@ static int tape_attach(struct scst_device *dev)
}
dev->block_size = TAPE_DEF_BLOCK_SIZE;
dev->block_shift = scst_calc_block_shift(dev->block_size);
dev->block_shift = -1; /* not used */
buffer = kmalloc(buffer_size, GFP_KERNEL);
if (!buffer) {
@@ -223,7 +223,7 @@ static int tape_attach(struct scst_device *dev)
res = -ENODEV;
goto out_free_buf;
}
dev->block_shift = scst_calc_block_shift(dev->block_size);
dev->block_shift = -1; /* not used */
obtain:
res = scst_obtain_device_parameters(dev, NULL);
@@ -270,7 +270,7 @@ static void tape_set_block_size(struct scst_cmd *cmd, int block_size)
* there are existing commands.
*/
dev->block_size = block_size;
dev->block_shift = scst_calc_block_shift(dev->block_size);
dev->block_shift = -1; /* not used */
return;
}

View File

@@ -1053,7 +1053,7 @@ static void dev_user_set_block_size(struct scst_cmd *cmd, int block_size)
struct scst_user_dev *udev = cmd->dev->dh_priv;
dev->block_size = udev->def_block_size;
}
dev->block_shift = scst_calc_block_shift(dev->block_size);
dev->block_shift = -1; /* not used */
TRACE_EXIT();
return;
@@ -2591,7 +2591,16 @@ static int dev_user_attach(struct scst_device *sdev)
}
sdev->block_size = dev->def_block_size;
sdev->block_shift = scst_calc_block_shift(sdev->block_size);
switch (sdev->type) {
case TYPE_DISK:
case TYPE_ROM:
case TYPE_MOD:
sdev->block_shift = scst_calc_block_shift(sdev->block_size);
break;
default:
sdev->block_shift = -1; /* not used */
break;
}
sdev->dh_priv = dev;
sdev->tst = dev->tst;

View File

@@ -6995,6 +6995,8 @@ static inline int scst_generic_parse(struct scst_cmd *cmd, const int timeout[3])
TRACE_ENTRY();
EXTRACHECKS_BUG_ON(block_shift < 0);
/*
* SCST sets good defaults for cmd->data_direction and cmd->bufflen,
* therefore change them only if necessary

View File

@@ -1596,7 +1596,8 @@ static int scst_tgt_pre_exec(struct scst_cmd *cmd)
do_zero = true;
}
if (do_zero) {
if ((cmd->write_len & ((1 << cmd->dev->block_shift) - 1)) == 0) {
if (!(cmd->op_flags & SCST_TRANSFER_LEN_TYPE_FIXED) ||
(cmd->write_len & ((1 << cmd->dev->block_shift) - 1)) == 0) {
scst_check_restore_sg_buff(cmd);
scst_zero_write_rest(cmd);
} else {