Re: [PATCH] device-mapper: multipath hardware handler for EMC

2005-02-12 Thread Mike Christie
Christoph Hellwig wrote:
+/* Code borrowed from dm-lsi-rdac by Mike Christie */

Any reason that module isn't submitted?
I do not have access to their HW specs, and have been busy with
some iscsi things so I did not have time to finish things up.
I was also hoping LSI would soon figure out that they should be
using dm (I have seen some of them pop up now and then only)
and take over the work.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] device-mapper: multipath hardware handler for EMC

2005-02-12 Thread Mike Christie
Christoph Hellwig wrote:
+/* Code borrowed from dm-lsi-rdac by Mike Christie */

Any reason that module isn't submitted?
I do not have access to their HW specs, and have been busy with
some iscsi things so I did not have time to finish things up.
I was also hoping LSI would soon figure out that they should be
using dm (I have seen some of them pop up now and then only)
and take over the work.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] device-mapper: multipath hardware handler for EMC

2005-02-11 Thread Lars Marowsky-Bree
On 2005-02-11T19:58:41, Christoph Hellwig <[EMAIL PROTECTED]> wrote:

> > +/* Code borrowed from dm-lsi-rdac by Mike Christie */
> 
> Any reason that module isn't submitted?

No idea why.

> > +   bio->bi_bdev = path->dev->bdev;
> > +   bio->bi_sector = 0;
> > +   bio->bi_private = path;
> > +   bio->bi_end_io = emc_endio;
> > +
> > +   page = alloc_page(GFP_ATOMIC);
> > +   if (!page) {
> > +   DMERR("dm-emc: get_failover_bio: alloc_page() failed.");
> > +   bio_put(bio);
> > +   return NULL;
> > +   }
> > +
> > +   if (bio_add_page(bio, page, data_size, 0) != data_size) {
> > +   DMERR("dm-emc: get_failover_bio: alloc_page() failed.");
> > +   __free_page(page);
> > +   bio_put(bio);
> > +   return NULL;
> > +   }
> > +
> > +   return bio;
> 
> this would benefit from goto unwinding.

OK.

> > +   if (h->short_trespass) {
> > +   memcpy(page22, short_trespass_pg, data_size);
> > +   } else {
> > +   memcpy(page22, long_trespass_pg, data_size);
> > +   }
>memcpy(page22, h->short_trespass ?
>   short_trespass_pg : long_trespass_pg, data_size);
> 
> ?

Yes, I first did some other things there than just copying the commands
around, it can surely benefit from cleanup.

> > +static struct emc_handler *alloc_emc_handler(void)
> > +{
> > +   struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
> > +
> > +   if (h) {
> > +   h->lock = SPIN_LOCK_UNLOCKED;
> > +   }
> 
>   if (h)
>   spin_lock_init(>lock);

Came in via the copy, good catch.

> > +static unsigned emc_err(struct hw_handler *hwh, struct bio *bio)
> > +{
> > +   /* FIXME: Patch from axboe still missing */
> 
> it's in -mm now afaik??

No, it's not. That's the request sense keys, but here we're dealing with
the bio.

> > +#if 0
> > +   int sense;
> > +
> > +   if (bio->bi_error & BIO_SENSE) {
> > +   sense = bio->bi_error & 0xff; /* sense key / asc / ascq */
> > +
> > +   if (sense == 0x020403) {
> 
> please use the sense handling helpers from Doug Gilbert so you can handle
> the descriptor sense format aswell.  (And make the code a lot clear).

I'll go look them up.

> Also please try to use constants instead of magic numbers.

Noted. I'll clean this part up when I actually have sense keys to try,
so far this was mostly about getting that tiny bit of logic in.


Sincerely,
Lars Marowsky-Brée <[EMAIL PROTECTED]>

-- 
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX Products GmbH - A Novell Business

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] device-mapper: multipath hardware handler for EMC

2005-02-11 Thread Christoph Hellwig
> +/* Code borrowed from dm-lsi-rdac by Mike Christie */

Any reason that module isn't submitted?

> + bio->bi_bdev = path->dev->bdev;
> + bio->bi_sector = 0;
> + bio->bi_private = path;
> + bio->bi_end_io = emc_endio;
> +
> + page = alloc_page(GFP_ATOMIC);
> + if (!page) {
> + DMERR("dm-emc: get_failover_bio: alloc_page() failed.");
> + bio_put(bio);
> + return NULL;
> + }
> +
> + if (bio_add_page(bio, page, data_size, 0) != data_size) {
> + DMERR("dm-emc: get_failover_bio: alloc_page() failed.");
> + __free_page(page);
> + bio_put(bio);
> + return NULL;
> + }
> +
> + return bio;

this would benefit from goto unwinding.

> + if (h->short_trespass) {
> + memcpy(page22, short_trespass_pg, data_size);
> + } else {
> + memcpy(page22, long_trespass_pg, data_size);
> + }

 memcpy(page22, h->short_trespass ?
short_trespass_pg : long_trespass_pg, data_size);

?

> +static struct emc_handler *alloc_emc_handler(void)
> +{
> + struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
> +
> + if (h) {
> + h->lock = SPIN_LOCK_UNLOCKED;
> + }

if (h)
spin_lock_init(>lock);

> +static unsigned emc_err(struct hw_handler *hwh, struct bio *bio)
> +{
> + /* FIXME: Patch from axboe still missing */

it's in -mm now afaik??

> +#if 0
> + int sense;
> +
> + if (bio->bi_error & BIO_SENSE) {
> + sense = bio->bi_error & 0xff; /* sense key / asc / ascq */
> +
> + if (sense == 0x020403) {

please use the sense handling helpers from Doug Gilbert so you can handle
the descriptor sense format aswell.  (And make the code a lot clear).

Also please try to use constants instead of magic numbers.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] device-mapper: multipath hardware handler for EMC

2005-02-11 Thread Alasdair G Kergon
Outline Hardware Handler for EMC CLARiiON AX/CX-series.

Signed-Off-By: Alasdair G Kergon <[EMAIL PROTECTED]>
From: Lars Marowsky-Bree <[EMAIL PROTECTED]>
--- diff/drivers/md/Kconfig 2005-02-09 14:41:52.0 +
+++ source/drivers/md/Kconfig   2005-02-09 14:42:24.0 +
@@ -233,5 +233,11 @@
---help---
  Allow volume managers to support multipath hardware.
 
+config DM_MULTIPATH_EMC
+   tristate "EMC CX/AX multipath support (EXPERIMENTAL)"
+   depends on DM_MULTIPATH && BLK_DEV_DM && EXPERIMENTAL
+   ---help---
+ Multipath support for EMC CX/AX series hardware.
+
 endmenu
 
--- diff/drivers/md/Makefile2005-02-09 14:42:12.0 +
+++ source/drivers/md/Makefile  2005-02-09 14:42:24.0 +
@@ -32,6 +32,7 @@
 obj-$(CONFIG_BLK_DEV_DM)   += dm-mod.o
 obj-$(CONFIG_DM_CRYPT) += dm-crypt.o
 obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o
+obj-$(CONFIG_DM_MULTIPATH_EMC) += dm-emc.o
 obj-$(CONFIG_DM_SNAPSHOT)  += dm-snapshot.o
 obj-$(CONFIG_DM_MIRROR)+= dm-mirror.o
 obj-$(CONFIG_DM_ZERO)  += dm-zero.o
--- diff/drivers/md/dm-emc.c1970-01-01 01:00:00.0 +0100
+++ source/drivers/md/dm-emc.c  2005-02-09 14:42:24.0 +
@@ -0,0 +1,363 @@
+/*
+ * Copyright (C) 2004 SUSE LINUX Products GmbH. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is released under the GPL.
+ *
+ * Multipath support for EMC CLARiiON AX/CX-series hardware.
+ */
+
+#include "dm.h"
+#include "dm-hw-handler.h"
+#include 
+#include 
+
+struct emc_handler {
+   spinlock_t lock;
+
+   /* Whether we should send the short trespass command (FC-series)
+* or the long version (default for AX/CX CLARiiON arrays). */
+   unsigned short_trespass;
+   /* Whether or not to honor SCSI reservations when initiating a
+* switch-over. Default: Don't. */
+   unsigned hr;
+   
+   unsigned char sense[SCSI_SENSE_BUFFERSIZE];
+};
+
+#define TRESPASS_PAGE 0x22
+#define EMC_FAILOVER_TIMEOUT (60 * HZ)
+
+/* Code borrowed from dm-lsi-rdac by Mike Christie */
+
+static inline void free_bio(struct bio *bio)
+{
+   __free_page(bio->bi_io_vec[0].bv_page);
+   bio_put(bio);
+}
+
+static int emc_endio(struct bio *bio, unsigned int bytes_done, int error)
+{
+   struct path *path = bio->bi_private;
+
+   if (bio->bi_size)
+   return 1;
+
+   /* We also need to look at the sense keys here whether or not to
+* switch to the next PG etc.
+* 
+* For now simple logic: either it works or it doesn't.
+*/
+   if (error)
+   dm_pg_init_complete(path, MP_FAIL_PATH);
+   else
+   dm_pg_init_complete(path, 0);
+
+   /* request is freed in block layer */
+   free_bio(bio);
+
+   return 0;
+}
+
+static struct bio *get_failover_bio(struct path *path, unsigned data_size)
+{
+   struct bio *bio;
+   struct page *page;
+
+   bio = bio_alloc(GFP_ATOMIC, 1);
+   if (!bio) {
+   DMERR("dm-emc: get_failover_bio: bio_alloc() failed.");
+   return NULL;
+   }
+   
+   bio->bi_rw |= (1 << BIO_RW);
+   bio->bi_bdev = path->dev->bdev;
+   bio->bi_sector = 0;
+   bio->bi_private = path;
+   bio->bi_end_io = emc_endio;
+
+   page = alloc_page(GFP_ATOMIC);
+   if (!page) {
+   DMERR("dm-emc: get_failover_bio: alloc_page() failed.");
+   bio_put(bio);
+   return NULL;
+   }
+
+   if (bio_add_page(bio, page, data_size, 0) != data_size) {
+   DMERR("dm-emc: get_failover_bio: alloc_page() failed.");
+   __free_page(page);
+   bio_put(bio);
+   return NULL;
+   }
+
+   return bio;
+}
+
+static struct request *get_failover_req(struct emc_handler *h,
+   struct bio *bio, struct path *path)
+{
+   struct request *rq;
+   struct block_device *bdev = bio->bi_bdev;
+   struct request_queue *q = bdev_get_queue(bdev);
+
+   /* FIXME: Figure out why it fails with GFP_ATOMIC. */
+   rq = blk_get_request(q, WRITE, __GFP_WAIT);
+   if (!rq) {
+   DMERR("dm-emc: get_failover_req: blk_get_request failed");
+   return NULL;
+   }
+   
+   rq->bio = rq->biotail = bio;
+   blk_rq_bio_prep(q, rq, bio);
+
+   rq->rq_disk = bdev->bd_contains->bd_disk;
+
+   /* bio backed don't set data */
+   rq->buffer = rq->data = NULL;
+   /* rq data_len used for pc cmd's request_bufflen */
+   rq->data_len = bio->bi_size;
+
+   rq->sense = h->sense;
+   memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
+   rq->sense_len = 0;
+
+   memset(>cmd, 0, BLK_MAX_CDB);
+
+   rq->timeout = EMC_FAILOVER_TIMEOUT;
+   rq->flags |= (REQ_BLOCK_PC | REQ_FAILFAST | REQ_NOMERGE);
+
+   return rq;
+}
+
+static 

[PATCH] device-mapper: multipath hardware handler for EMC

2005-02-11 Thread Alasdair G Kergon
Outline Hardware Handler for EMC CLARiiON AX/CX-series.

Signed-Off-By: Alasdair G Kergon [EMAIL PROTECTED]
From: Lars Marowsky-Bree [EMAIL PROTECTED]
--- diff/drivers/md/Kconfig 2005-02-09 14:41:52.0 +
+++ source/drivers/md/Kconfig   2005-02-09 14:42:24.0 +
@@ -233,5 +233,11 @@
---help---
  Allow volume managers to support multipath hardware.
 
+config DM_MULTIPATH_EMC
+   tristate EMC CX/AX multipath support (EXPERIMENTAL)
+   depends on DM_MULTIPATH  BLK_DEV_DM  EXPERIMENTAL
+   ---help---
+ Multipath support for EMC CX/AX series hardware.
+
 endmenu
 
--- diff/drivers/md/Makefile2005-02-09 14:42:12.0 +
+++ source/drivers/md/Makefile  2005-02-09 14:42:24.0 +
@@ -32,6 +32,7 @@
 obj-$(CONFIG_BLK_DEV_DM)   += dm-mod.o
 obj-$(CONFIG_DM_CRYPT) += dm-crypt.o
 obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o
+obj-$(CONFIG_DM_MULTIPATH_EMC) += dm-emc.o
 obj-$(CONFIG_DM_SNAPSHOT)  += dm-snapshot.o
 obj-$(CONFIG_DM_MIRROR)+= dm-mirror.o
 obj-$(CONFIG_DM_ZERO)  += dm-zero.o
--- diff/drivers/md/dm-emc.c1970-01-01 01:00:00.0 +0100
+++ source/drivers/md/dm-emc.c  2005-02-09 14:42:24.0 +
@@ -0,0 +1,363 @@
+/*
+ * Copyright (C) 2004 SUSE LINUX Products GmbH. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is released under the GPL.
+ *
+ * Multipath support for EMC CLARiiON AX/CX-series hardware.
+ */
+
+#include dm.h
+#include dm-hw-handler.h
+#include scsi/scsi.h
+#include scsi/scsi_cmnd.h
+
+struct emc_handler {
+   spinlock_t lock;
+
+   /* Whether we should send the short trespass command (FC-series)
+* or the long version (default for AX/CX CLARiiON arrays). */
+   unsigned short_trespass;
+   /* Whether or not to honor SCSI reservations when initiating a
+* switch-over. Default: Don't. */
+   unsigned hr;
+   
+   unsigned char sense[SCSI_SENSE_BUFFERSIZE];
+};
+
+#define TRESPASS_PAGE 0x22
+#define EMC_FAILOVER_TIMEOUT (60 * HZ)
+
+/* Code borrowed from dm-lsi-rdac by Mike Christie */
+
+static inline void free_bio(struct bio *bio)
+{
+   __free_page(bio-bi_io_vec[0].bv_page);
+   bio_put(bio);
+}
+
+static int emc_endio(struct bio *bio, unsigned int bytes_done, int error)
+{
+   struct path *path = bio-bi_private;
+
+   if (bio-bi_size)
+   return 1;
+
+   /* We also need to look at the sense keys here whether or not to
+* switch to the next PG etc.
+* 
+* For now simple logic: either it works or it doesn't.
+*/
+   if (error)
+   dm_pg_init_complete(path, MP_FAIL_PATH);
+   else
+   dm_pg_init_complete(path, 0);
+
+   /* request is freed in block layer */
+   free_bio(bio);
+
+   return 0;
+}
+
+static struct bio *get_failover_bio(struct path *path, unsigned data_size)
+{
+   struct bio *bio;
+   struct page *page;
+
+   bio = bio_alloc(GFP_ATOMIC, 1);
+   if (!bio) {
+   DMERR(dm-emc: get_failover_bio: bio_alloc() failed.);
+   return NULL;
+   }
+   
+   bio-bi_rw |= (1  BIO_RW);
+   bio-bi_bdev = path-dev-bdev;
+   bio-bi_sector = 0;
+   bio-bi_private = path;
+   bio-bi_end_io = emc_endio;
+
+   page = alloc_page(GFP_ATOMIC);
+   if (!page) {
+   DMERR(dm-emc: get_failover_bio: alloc_page() failed.);
+   bio_put(bio);
+   return NULL;
+   }
+
+   if (bio_add_page(bio, page, data_size, 0) != data_size) {
+   DMERR(dm-emc: get_failover_bio: alloc_page() failed.);
+   __free_page(page);
+   bio_put(bio);
+   return NULL;
+   }
+
+   return bio;
+}
+
+static struct request *get_failover_req(struct emc_handler *h,
+   struct bio *bio, struct path *path)
+{
+   struct request *rq;
+   struct block_device *bdev = bio-bi_bdev;
+   struct request_queue *q = bdev_get_queue(bdev);
+
+   /* FIXME: Figure out why it fails with GFP_ATOMIC. */
+   rq = blk_get_request(q, WRITE, __GFP_WAIT);
+   if (!rq) {
+   DMERR(dm-emc: get_failover_req: blk_get_request failed);
+   return NULL;
+   }
+   
+   rq-bio = rq-biotail = bio;
+   blk_rq_bio_prep(q, rq, bio);
+
+   rq-rq_disk = bdev-bd_contains-bd_disk;
+
+   /* bio backed don't set data */
+   rq-buffer = rq-data = NULL;
+   /* rq data_len used for pc cmd's request_bufflen */
+   rq-data_len = bio-bi_size;
+
+   rq-sense = h-sense;
+   memset(rq-sense, 0, SCSI_SENSE_BUFFERSIZE);
+   rq-sense_len = 0;
+
+   memset(rq-cmd, 0, BLK_MAX_CDB);
+
+   rq-timeout = EMC_FAILOVER_TIMEOUT;
+   rq-flags |= (REQ_BLOCK_PC | REQ_FAILFAST | REQ_NOMERGE);
+
+   return rq;
+}
+
+static struct request 

Re: [PATCH] device-mapper: multipath hardware handler for EMC

2005-02-11 Thread Christoph Hellwig
 +/* Code borrowed from dm-lsi-rdac by Mike Christie */

Any reason that module isn't submitted?

 + bio-bi_bdev = path-dev-bdev;
 + bio-bi_sector = 0;
 + bio-bi_private = path;
 + bio-bi_end_io = emc_endio;
 +
 + page = alloc_page(GFP_ATOMIC);
 + if (!page) {
 + DMERR(dm-emc: get_failover_bio: alloc_page() failed.);
 + bio_put(bio);
 + return NULL;
 + }
 +
 + if (bio_add_page(bio, page, data_size, 0) != data_size) {
 + DMERR(dm-emc: get_failover_bio: alloc_page() failed.);
 + __free_page(page);
 + bio_put(bio);
 + return NULL;
 + }
 +
 + return bio;

this would benefit from goto unwinding.

 + if (h-short_trespass) {
 + memcpy(page22, short_trespass_pg, data_size);
 + } else {
 + memcpy(page22, long_trespass_pg, data_size);
 + }

 memcpy(page22, h-short_trespass ?
short_trespass_pg : long_trespass_pg, data_size);

?

 +static struct emc_handler *alloc_emc_handler(void)
 +{
 + struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
 +
 + if (h) {
 + h-lock = SPIN_LOCK_UNLOCKED;
 + }

if (h)
spin_lock_init(h-lock);

 +static unsigned emc_err(struct hw_handler *hwh, struct bio *bio)
 +{
 + /* FIXME: Patch from axboe still missing */

it's in -mm now afaik??

 +#if 0
 + int sense;
 +
 + if (bio-bi_error  BIO_SENSE) {
 + sense = bio-bi_error  0xff; /* sense key / asc / ascq */
 +
 + if (sense == 0x020403) {

please use the sense handling helpers from Doug Gilbert so you can handle
the descriptor sense format aswell.  (And make the code a lot clear).

Also please try to use constants instead of magic numbers.

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] device-mapper: multipath hardware handler for EMC

2005-02-11 Thread Lars Marowsky-Bree
On 2005-02-11T19:58:41, Christoph Hellwig [EMAIL PROTECTED] wrote:

  +/* Code borrowed from dm-lsi-rdac by Mike Christie */
 
 Any reason that module isn't submitted?

No idea why.

  +   bio-bi_bdev = path-dev-bdev;
  +   bio-bi_sector = 0;
  +   bio-bi_private = path;
  +   bio-bi_end_io = emc_endio;
  +
  +   page = alloc_page(GFP_ATOMIC);
  +   if (!page) {
  +   DMERR(dm-emc: get_failover_bio: alloc_page() failed.);
  +   bio_put(bio);
  +   return NULL;
  +   }
  +
  +   if (bio_add_page(bio, page, data_size, 0) != data_size) {
  +   DMERR(dm-emc: get_failover_bio: alloc_page() failed.);
  +   __free_page(page);
  +   bio_put(bio);
  +   return NULL;
  +   }
  +
  +   return bio;
 
 this would benefit from goto unwinding.

OK.

  +   if (h-short_trespass) {
  +   memcpy(page22, short_trespass_pg, data_size);
  +   } else {
  +   memcpy(page22, long_trespass_pg, data_size);
  +   }
memcpy(page22, h-short_trespass ?
   short_trespass_pg : long_trespass_pg, data_size);
 
 ?

Yes, I first did some other things there than just copying the commands
around, it can surely benefit from cleanup.

  +static struct emc_handler *alloc_emc_handler(void)
  +{
  +   struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
  +
  +   if (h) {
  +   h-lock = SPIN_LOCK_UNLOCKED;
  +   }
 
   if (h)
   spin_lock_init(h-lock);

Came in via the copy, good catch.

  +static unsigned emc_err(struct hw_handler *hwh, struct bio *bio)
  +{
  +   /* FIXME: Patch from axboe still missing */
 
 it's in -mm now afaik??

No, it's not. That's the request sense keys, but here we're dealing with
the bio.

  +#if 0
  +   int sense;
  +
  +   if (bio-bi_error  BIO_SENSE) {
  +   sense = bio-bi_error  0xff; /* sense key / asc / ascq */
  +
  +   if (sense == 0x020403) {
 
 please use the sense handling helpers from Doug Gilbert so you can handle
 the descriptor sense format aswell.  (And make the code a lot clear).

I'll go look them up.

 Also please try to use constants instead of magic numbers.

Noted. I'll clean this part up when I actually have sense keys to try,
so far this was mostly about getting that tiny bit of logic in.


Sincerely,
Lars Marowsky-Brée [EMAIL PROTECTED]

-- 
High Availability  Clustering
SUSE Labs, Research and Development
SUSE LINUX Products GmbH - A Novell Business

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/