public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: nab@linux-iscsi.org
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH,RFC] target: fix block limits VPD emulation
Date: Wed, 10 Nov 2010 16:04:32 -0500	[thread overview]
Message-ID: <20101110210432.GC24988@infradead.org> (raw)

Just because our target supports TP the initiator doesn't have.
Handle short block limit VPD requests even if TP is supported.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: lio-core-2.6/drivers/target/target_core_cdb.c
===================================================================
--- lio-core-2.6.orig/drivers/target/target_core_cdb.c	2010-11-09 12:12:21.908196346 +0100
+++ lio-core-2.6/drivers/target/target_core_cdb.c	2010-11-09 12:15:14.691529680 +0100
@@ -497,20 +497,18 @@ target_emulate_evpd_b0(struct se_cmd *cm
 	if (DEV_ATTRIB(dev)->emulate_tpu || DEV_ATTRIB(dev)->emulate_tpws)
 		have_tp = 1;
 
-	if (have_tp) {
-		if (cmd->data_length < (0x3c + 4)) {
-			printk(KERN_INFO "Received data_length: %u"
-				" too small for TPE=1 EVPD 0xb0\n",
-				cmd->data_length);
-			return -1;
-		}
-	} else {
-		if (cmd->data_length < (0x10 + 4)) {
-			printk(KERN_INFO "Received data_length: %u"
-				" too small for TPE=1 EVPD 0xb0\n",
-				cmd->data_length);
-			return -1;
-		}
+	if (cmd->data_length < (0x10 + 4)) {
+		printk(KERN_INFO "Received data_length: %u"
+			" too small for EVPD 0xb0\n",
+			cmd->data_length);
+		return -1;
+	}
+
+	if (have_tp && cmd->data_length < (0x3c + 4)) {
+		printk(KERN_INFO "Received data_length: %u"
+			" too small for TPE=1 EVPD 0xb0\n",
+			cmd->data_length);
+		have_tp = 0;
 	}
 
 	buf[0] = dev->transport->get_device_type(dev);
@@ -532,7 +530,11 @@ target_emulate_evpd_b0(struct se_cmd *cm
 	 */
 	put_unaligned_be32(DEV_ATTRIB(dev)->optimal_sectors, &buf[12]);
 
-	if (!have_tp)
+	/*
+	 * Exit now if we don't support TP or the initiator sent a too
+	 * short buffer.
+	 */
+	if (!have_tp || cmd->data_length < (0x3c + 4))
 		return 0;
 
 	/*

             reply	other threads:[~2010-11-10 21:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-10 21:04 Christoph Hellwig [this message]
2010-11-11  7:52 ` [PATCH,RFC] target: fix block limits VPD emulation Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101110210432.GC24988@infradead.org \
    --to=hch@infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox