From patchwork Mon Aug 17 17:46:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: babu moger X-Patchwork-Id: 42112 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 n7HHlsGJ002943 for ; Mon, 17 Aug 2009 17:47:54 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 CB15E619350; Mon, 17 Aug 2009 13:47:53 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n7HHlphq019307 for ; Mon, 17 Aug 2009 13:47:51 -0400 Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n7HHlo5u017695 for ; Mon, 17 Aug 2009 13:47:50 -0400 Received: from exprod7og105.obsmtp.com (exprod7og105.obsmtp.com [64.18.2.163]) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n7HHlLH8031417 for ; Mon, 17 Aug 2009 13:47:24 -0400 Received: from source ([147.145.40.20]) by exprod7ob105.postini.com ([64.18.6.12]) with SMTP ID DSNKSomXp3iI2X14VMrWNqILGEBGOkfLIyax@postini.com; Mon, 17 Aug 2009 10:47:34 PDT 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 n7HHlG0k022001; Mon, 17 Aug 2009 10:47:17 -0700 (PDT) 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 n7HHlK8w008331; Mon, 17 Aug 2009 10:47:20 -0700 Received: from cosmail01.lsi.com ([172.21.36.24]) by coshub01.lsi.com ([172.21.36.64]) with mapi; Mon, 17 Aug 2009 11:47:16 -0600 From: "Moger, Babu" To: Linux SCSI Mailing list , device-mapper development Date: Mon, 17 Aug 2009 11:46:58 -0600 Thread-Topic: [PATCH] scsi_dh: Adding more debug options for scsi rdac handler Thread-Index: AcofYreLZbdsSbUmQMuUnXwvwMO/YQ== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: C4UF Gv5y I2lc Jxfe KeqQ ML0b Myb6 N2r7 N3bm X4In ZaaC a9hV eaJK fNBP i4lG lNnU; 3; ZABtAC0AZABlAHYAZQBsAEAAcgBlAGQAaABhAHQALgBjAG8AbQA7AGwAaQBuAHUAeAAtAHMAYwBzAGkAQAB2AGcAZQByAC4AawBlAHIAbgBlAGwALgBvAHIAZwA7AHMAZQBrAGgAYQByAGEAbgBAAHUAcwAuAGkAYgBtAC4AYwBvAG0A; Sosha1_v1; 7; {27176CBB-A702-4F63-9E23-67B7E7C3BE8D}; YgBhAGIAdQAuAG0AbwBnAGUAcgBAAGwAcwBpAC4AYwBvAG0A; Mon, 17 Aug 2009 17:46:58 GMT; WwBQAEEAVABDAEgAXQAgAHMAYwBzAGkAXwBkAGgAOgAgAEEAZABkAGkAbgBnACAAbQBvAHIAZQAgAGQAZQBiAHUAZwAgAG8AcAB0AGkAbwBuAHMAIABmAG8AcgAgAHMAYwBzAGkAIAByAGQAYQBjACAAaABhAG4AZABsAGUAcgA= x-cr-puzzleid: {27176CBB-A702-4F63-9E23-67B7E7C3BE8D} acceptlanguage: en-US MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 X-Scanned-By: MIMEDefang 2.39 X-RedHat-Spam-Score: -3.778 X-MIME-Autoconverted: from quoted-printable to 8bit by listman.util.phx.redhat.com id n7HHlphq019307 X-loop: dm-devel@redhat.com Cc: "Dachepalli, Sudhir" , "Chauhan, Vijay" , "Stankey, Robert" Subject: [dm-devel] [PATCH] scsi_dh: Adding more debug options for scsi rdac handler 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 From: Babu Moger Hi All, This patch adds more debugging options to scsi rdac device handler. This patch can considerably reduce the time taken to debug issues in big configurations also very helpful in addressing the support issues. Here are the summary of changes. - Added a bit mask "module parameter" rdac_logging with 2 bits for each type of logging. - currently defined only two types of logging(failover and sense logging). Can be enhanced later if required. - Only failover logging is enabled for now which is equivalent of current logging. Signed-off-by: Babu Moger Reviewed-by: Vijay Chauhan Reviewed-by: Bob Stankey --- -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel --- linux-2.6.31-rc5/drivers/scsi/device_handler/scsi_dh_rdac.c.orig 2009-08-05 16:30:51.000000000 -0500 +++ linux-2.6.31-rc5/drivers/scsi/device_handler/scsi_dh_rdac.c 2009-08-17 09:15:03.000000000 -0500 @@ -135,6 +135,8 @@ struct rdac_controller { struct rdac_pg_legacy legacy; struct rdac_pg_expanded expanded; } mode_select; + u8 index; + u8 array_name[31]; }; struct c8_inquiry { u8 peripheral_info; @@ -198,6 +200,31 @@ static const char *lun_state[] = static LIST_HEAD(ctlr_list); static DEFINE_SPINLOCK(list_lock); +/* + * module parameter to enable rdac debug logging. + * 2 bits for each type of logging, only two types defined for now + * Can be enhanced if required at later point + */ +static int rdac_logging = 1; +module_param(rdac_logging, int, S_IRUGO|S_IWUSR); +MODULE_PARM_DESC(rdac_logging, "A bit mask of rdac logging levels, " + "Default is 1 - failover logging enabled, " + "set it to 0xF to enable all the logs"); + +#define RDAC_LOG_FAILOVER 0 +#define RDAC_LOG_SENSE 2 + +#define RDAC_LOG_BITS 2 + +#define RDAC_LOG_LEVEL(SHIFT) \ + ((rdac_logging >> (SHIFT)) & ((1 << (RDAC_LOG_BITS)) - 1)) + +#define RDAC_DEBUG(SHIFT, sdev, f, arg...) \ +do { \ + if (unlikely(RDAC_LOG_LEVEL(SHIFT))) \ + sdev_printk(KERN_INFO, sdev, RDAC_NAME ": " f "\n", ## arg); \ +} while (0); + static inline struct rdac_dh_data *get_rdac_data(struct scsi_device *sdev) { struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data; @@ -324,6 +351,13 @@ static struct rdac_controller *get_contr /* initialize fields of controller */ memcpy(ctlr->subsys_id, subsys_id, SUBSYS_ID_LEN); memcpy(ctlr->slot_id, slot_id, SLOT_ID_LEN); + + /* update the controller index */ + if (slot_id[1] == 0x31) + ctlr->index = 0; + else + ctlr->index = 1; + kref_init(&ctlr->kref); ctlr->use_ms10 = -1; list_add(&ctlr->node, &ctlr_list); @@ -381,6 +415,26 @@ static int get_lun(struct scsi_device *s return err; } +static int get_array_name(struct scsi_device *sdev, struct rdac_dh_data *h) +{ + int err, i; + struct c8_inquiry *inqp; + + err = submit_inquiry(sdev, 0xC8, sizeof(struct c8_inquiry), h); + if (err == SCSI_DH_OK) { + inqp = &h->inq.c8; + if (inqp->page_code != 0xc8) + return SCSI_DH_NOSYS; + + for(i=0; i<30; ++i) { + h->ctlr->array_name[i] = inqp->array_user_label[(2*i)+1]; + } + h->ctlr->array_name[30] = '\0'; + } + + return err; +} + static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h) { int err; @@ -450,13 +504,12 @@ static int mode_select_handle_sense(stru { struct scsi_sense_hdr sense_hdr; int err = SCSI_DH_IO, ret; + struct rdac_dh_data *h = get_rdac_data(sdev); ret = scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE, &sense_hdr); if (!ret) goto done; - err = SCSI_DH_OK; - switch (sense_hdr.sense_key) { case NO_SENSE: case ABORTED_COMMAND: @@ -478,12 +531,15 @@ static int mode_select_handle_sense(stru err = SCSI_DH_RETRY; break; default: - sdev_printk(KERN_INFO, sdev, - "MODE_SELECT failed with sense %02x/%02x/%02x.\n", - sense_hdr.sense_key, sense_hdr.asc, sense_hdr.ascq); + break; } done: + RDAC_DEBUG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " + "MODE_SELECT returned with sense %02x/%02x/%02x", + (char *) h->ctlr->array_name, h->ctlr->index, + sense_hdr.sense_key, sense_hdr.asc, sense_hdr.ascq); + return err; } @@ -499,7 +555,9 @@ retry: if (!rq) goto done; - sdev_printk(KERN_INFO, sdev, "%s MODE_SELECT command.\n", + RDAC_DEBUG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " + "%s MODE_SELECT command", + (char *) h->ctlr->array_name, h->ctlr->index, (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying"); err = blk_execute_rq(q, NULL, rq, 1); @@ -509,8 +567,12 @@ retry: if (err == SCSI_DH_RETRY && retry_cnt--) goto retry; } - if (err == SCSI_DH_OK) + if (err == SCSI_DH_OK) { h->state = RDAC_STATE_ACTIVE; + RDAC_DEBUG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " + "MODE_SELECT completed", + (char *) h->ctlr->array_name, h->ctlr->index); + } done: return err; @@ -525,12 +587,6 @@ static int rdac_activate(struct scsi_dev if (err != SCSI_DH_OK) goto done; - if (!h->ctlr) { - err = initialize_controller(sdev, h); - if (err != SCSI_DH_OK) - goto done; - } - if (h->ctlr->use_ms10 == -1) { err = set_mode_select(sdev, h); if (err != SCSI_DH_OK) @@ -559,6 +615,12 @@ static int rdac_check_sense(struct scsi_ struct scsi_sense_hdr *sense_hdr) { struct rdac_dh_data *h = get_rdac_data(sdev); + + RDAC_DEBUG(RDAC_LOG_SENSE, sdev, "array %s, ctlr %d, " + "command returned with sense %02x/%02x/%02x", + (char *) h->ctlr->array_name, h->ctlr->index, + sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq); + switch (sense_hdr->sense_key) { case NOT_READY: if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x01) @@ -678,6 +740,16 @@ static int rdac_bus_attach(struct scsi_d if (err != SCSI_DH_OK) goto failed; + if (!h->ctlr) { + err = initialize_controller(sdev, h); + if (err != SCSI_DH_OK) + goto failed; + + err = get_array_name(sdev, h); + if (err != SCSI_DH_OK) + goto failed; + } + if (!try_module_get(THIS_MODULE)) goto failed;