From bbe4224615edd1ce9c7d0060b577bffa483aaf05 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 23 May 2012 22:54:47 +0000 Subject: [PATCH] Cleanup and fix of data overrite with WRITE SAME git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4319 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 14 +++++++++++--- scst/src/scst_lib.c | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 9a1d1ff1b..7f76a7d95 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1156,9 +1156,17 @@ static bool vdisk_parse_offset(struct vdisk_cmd_params *p, struct scst_cmd *cmd) TRACE_ENTRY(); if (unlikely(!(cmd->op_flags & SCST_INFO_VALID))) { - PRINT_ERROR("Unknown opcode 0x%02x", cmd->cdb[0]); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_invalid_opcode)); + /* + * Let's ignore reporting T10/04-262r7 16-byte and 12-byte ATA + * pass-thru commands to not pollute logs (udev(?) checks them + * for some reason). If somebody has their description, please, + * update scst_scsi_op_table. + */ + if ((cmd->cdb[0] != 0x85) && (cmd->cdb[0] != 0xa1)) + PRINT_ERROR("Unknown opcode 0x%02x", cmd->cdb[0]); + else + TRACE(TRACE_MINOR, "Unknown opcode 0x%02x", cmd->cdb[0]); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_opcode)); res = false; goto out; } diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index dc32c30b2..bb5712f4f 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4495,7 +4495,8 @@ static int scst_ws_push_single_write(struct scst_write_same_priv *wsp, if ((ws_cmd->cdb[1] & 0x6) == 0) { TRACE_DBG("Using direct ws_sg %p (cnt %d)", ws_sg, ws_sg_cnt); sg = ws_sg; - sg_cnt = ws_sg_cnt; + EXTRACHECKS_BUG_ON(blocks > ws_sg_cnt); + sg_cnt = blocks; goto set_add; }