From patchwork Thu Nov 26 00:25:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: babu moger X-Patchwork-Id: 63036 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAQ0Rmen017345 for ; Thu, 26 Nov 2009 00:27:48 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 6C25461A627; Wed, 25 Nov 2009 19:27:47 -0500 (EST) Received: from int-mx01.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id nAQ0RklI005883 for ; Wed, 25 Nov 2009 19:27:46 -0500 Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.12]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAQ0RknX017071 for ; Wed, 25 Nov 2009 19:27:46 -0500 Received: from na3sys009aog113.obsmtp.com (na3sys009aog113.obsmtp.com [74.125.149.209]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAQ0RTNu016334 for ; Wed, 25 Nov 2009 19:27:30 -0500 Received: from source ([147.145.40.20]) by na3sys009aob113.postini.com ([74.125.148.12]) with SMTP ID DSNKSw3LbCctEtsTGbG7AwbZv3iMAbD5a/yj@postini.com; Wed, 25 Nov 2009 16:27:30 PST Received: from milmhbs0.lsil.com (mhbs.lsil.com [147.145.1.30]) by mail0.lsil.com (8.12.11/8.12.11) with ESMTP id nAQ0RJcG019211; Wed, 25 Nov 2009 16:27:19 -0800 (PST) Received: from coshub01.lsi.com (coshub01.co.lsil.com [172.21.36.64]) by milmhbs0.lsil.com (8.12.11/8.12.11) with ESMTP id nAQ0RKG1025299; Wed, 25 Nov 2009 16:27:20 -0800 Received: from cosmail01.lsi.com ([172.21.36.24]) by coshub01.lsi.com ([172.21.36.64]) with mapi; Wed, 25 Nov 2009 17:27:18 -0700 From: "Moger, Babu" To: Hannes Reinecke , James Bottomley Date: Wed, 25 Nov 2009 17:25:41 -0700 Thread-Topic: [PATCH] multipath: Evaluate request result and sense code Thread-Index: AcppE1VxQ3c/5aisQXe+nJ6JBUQi0AFG6dFD Message-ID: References: <20091119122503.413AD3A174@ochil.suse.de> In-Reply-To: <20091119122503.413AD3A174@ochil.suse.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.12 X-Scanned-By: MIMEDefang 2.39 X-RedHat-Spam-Score: -1.333 (AWL) X-MIME-Autoconverted: from quoted-printable to 8bit by listman.util.phx.redhat.com id nAQ0RklI005883 X-loop: dm-devel@redhat.com Cc: "dm-devel@redhat.com" , "linux-scsi@vger.kernel.org" Subject: [dm-devel] RE: [PATCH] multipath: Evaluate request result and sense code X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index dce971d..460e11f 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #define DM_MSG_PREFIX "multipath" @@ -101,6 +102,7 @@ struct multipath { struct dm_mpath_io { struct pgpath *pgpath; size_t nr_bytes; + char sense[SCSI_SENSE_BUFFERSIZE]; }; typedef int (*action_fn) (struct pgpath *pgpath); @@ -913,6 +915,9 @@ static int multipath_map(struct dm_target *ti, struct request *clone, map_context->ptr = mpio; clone->cmd_flags |= REQ_FAILFAST_TRANSPORT; + /* Always attach a sense buffer */ + if (!clone->sense) + clone->sense = mpio->sense; r = map_io(m, clone, mpio, 0); if (r < 0 || r == DM_MAPIO_REQUEUE) mempool_free(mpio, m->mpio_pool); @@ -1192,6 +1197,42 @@ static void activate_path(struct work_struct *work) } /* + * Evaluate scsi return code + */ +static int eval_scsi_error(int result, char *sense, int sense_len) +{ + struct scsi_sense_hdr sshdr; + int r = DM_ENDIO_REQUEUE; + + if (host_byte(result) != DID_OK) + return r; + + if (msg_byte(result) != COMMAND_COMPLETE) + return r; + + if (status_byte(result) == RESERVATION_CONFLICT) + /* Do not retry here, possible data corruption */ + return -EIO; + + if (status_byte(result) == CHECK_CONDITION && + !scsi_normalize_sense(sense, sense_len, &sshdr)) { + + switch (sshdr.sense_key) { + case MEDIUM_ERROR: + case DATA_PROTECT: + case BLANK_CHECK: + case COPY_ABORTED: + case VOLUME_OVERFLOW: + case MISCOMPARE: + r = -EIO; + break; + } The above sense key list does not cover all the cases(at least for my case). For example, I have these requirements for my storage. 1. For certain check conditions I should be reporting I/O error immediately without retrying on other paths. You have covered some cases here but we a have bigger list. 2. For few other check condtions I should be calling activate_path instead of failing the path. So, I am thinking it may be better to handle this with scsi device handlers(may be providing a new scsi_dh interface and fallback to default handling if the device handler does not handle the sense). I am not sure if this is feasible but something to think about. + } + + return r;