]> err.no Git - linux-2.6/blobdiff - drivers/block/aoe/aoecmd.c
pci: VT3336 can't do MSI either
[linux-2.6] / drivers / block / aoe / aoecmd.c
index b49e06ef121e08a22fbea2f54a3540a54fe08205..41f818be2f7ec8c4c737acaa16ecfeddc94f42b4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006 Coraid, Inc.  See COPYING for GPL terms. */
+/* Copyright (c) 2007 Coraid, Inc.  See COPYING for GPL terms. */
 /*
  * aoecmd.c
  * Filesystem request handling methods
@@ -18,6 +18,11 @@ static int aoe_deadsecs = 60 * 3;
 module_param(aoe_deadsecs, int, 0644);
 MODULE_PARM_DESC(aoe_deadsecs, "After aoe_deadsecs seconds, give up and fail dev.");
 
+static int aoe_maxout = 16;
+module_param(aoe_maxout, int, 0644);
+MODULE_PARM_DESC(aoe_maxout,
+       "Only aoe_maxout outstanding packets for every MAC on eX.Y.");
+
 static struct sk_buff *
 new_skb(ulong len)
 {
@@ -663,16 +668,16 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
        u16 n;
 
        /* word 83: command set supported */
-       n = le16_to_cpu(get_unaligned((__le16 *) &id[83<<1]));
+       n = get_unaligned_le16(&id[83 << 1]);
 
        /* word 86: command set/feature enabled */
-       n |= le16_to_cpu(get_unaligned((__le16 *) &id[86<<1]));
+       n |= get_unaligned_le16(&id[86 << 1]);
 
        if (n & (1<<10)) {      /* bit 10: LBA 48 */
                d->flags |= DEVFL_EXT;
 
                /* word 100: number lba48 sectors */
-               ssize = le64_to_cpu(get_unaligned((__le64 *) &id[100<<1]));
+               ssize = get_unaligned_le64(&id[100 << 1]);
 
                /* set as in ide-disk.c:init_idedisk_capacity */
                d->geo.cylinders = ssize;
@@ -683,21 +688,24 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
                d->flags &= ~DEVFL_EXT;
 
                /* number lba28 sectors */
-               ssize = le32_to_cpu(get_unaligned((__le32 *) &id[60<<1]));
+               ssize = get_unaligned_le32(&id[60 << 1]);
 
                /* NOTE: obsolete in ATA 6 */
-               d->geo.cylinders = le16_to_cpu(get_unaligned((__le16 *) &id[54<<1]));
-               d->geo.heads = le16_to_cpu(get_unaligned((__le16 *) &id[55<<1]));
-               d->geo.sectors = le16_to_cpu(get_unaligned((__le16 *) &id[56<<1]));
+               d->geo.cylinders = get_unaligned_le16(&id[54 << 1]);
+               d->geo.heads = get_unaligned_le16(&id[55 << 1]);
+               d->geo.sectors = get_unaligned_le16(&id[56 << 1]);
        }
 
        if (d->ssize != ssize)
-               printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu sectors\n",
+               printk(KERN_INFO
+                       "aoe: %012llx e%ld.%d v%04x has %llu sectors\n",
                        mac_addr(t->addr),
                        d->aoemajor, d->aoeminor,
                        d->fw_ver, (long long)ssize);
        d->ssize = ssize;
        d->geo.start = 0;
+       if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE))
+               return;
        if (d->gd != NULL) {
                d->gd->capacity = ssize;
                d->flags |= DEVFL_NEWSIZE;
@@ -743,15 +751,17 @@ gettgt(struct aoedev *d, char *addr)
 }
 
 static inline void
-diskstats(struct gendisk *disk, struct bio *bio, ulong duration)
+diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector)
 {
        unsigned long n_sect = bio->bi_size >> 9;
        const int rw = bio_data_dir(bio);
+       struct hd_struct *part;
 
-       disk_stat_inc(disk, ios[rw]);
-       disk_stat_add(disk, ticks[rw], duration);
-       disk_stat_add(disk, sectors[rw], n_sect);
-       disk_stat_add(disk, io_ticks, duration);
+       part = get_part(disk, sector);
+       all_stat_inc(disk, part, ios[rw], sector);
+       all_stat_add(disk, part, ticks[rw], duration, sector);
+       all_stat_add(disk, part, sectors[rw], n_sect, sector);
+       all_stat_add(disk, part, io_ticks, duration, sector);
 }
 
 void
@@ -771,7 +781,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
        u16 aoemajor;
 
        hin = (struct aoe_hdr *) skb_mac_header(skb);
-       aoemajor = be16_to_cpu(get_unaligned(&hin->major));
+       aoemajor = get_unaligned_be16(&hin->major);
        d = aoedev_by_aoeaddr(aoemajor, hin->minor);
        if (d == NULL) {
                snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response "
@@ -783,7 +793,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
 
        spin_lock_irqsave(&d->lock, flags);
 
-       n = be32_to_cpu(get_unaligned(&hin->tag));
+       n = get_unaligned_be32(&hin->tag);
        t = gettgt(d, hin->src);
        if (t == NULL) {
                printk(KERN_INFO "aoe: can't find target e%ld.%d:%012llx\n",
@@ -798,9 +808,9 @@ aoecmd_ata_rsp(struct sk_buff *skb)
                snprintf(ebuf, sizeof ebuf,
                        "%15s e%d.%d    tag=%08x@%08lx\n",
                        "unexpected rsp",
-                       be16_to_cpu(get_unaligned(&hin->major)),
+                       get_unaligned_be16(&hin->major),
                        hin->minor,
-                       be32_to_cpu(get_unaligned(&hin->tag)),
+                       get_unaligned_be32(&hin->tag),
                        jiffies);
                aoechr_error(ebuf);
                return;
@@ -815,7 +825,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
 
        if (ahin->cmdstat & 0xa9) {     /* these bits cleared on success */
                printk(KERN_ERR
-                       "aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%ld\n",
+                       "aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%d\n",
                        ahout->cmdstat, ahin->cmdstat,
                        d->aoemajor, d->aoeminor);
                if (buf)
@@ -865,13 +875,13 @@ aoecmd_ata_rsp(struct sk_buff *skb)
                        printk(KERN_INFO
                                "aoe: unrecognized ata command %2.2Xh for %d.%d\n",
                                ahout->cmdstat,
-                               be16_to_cpu(get_unaligned(&hin->major)),
+                               get_unaligned_be16(&hin->major),
                                hin->minor);
                }
        }
 
        if (buf && --buf->nframesout == 0 && buf->resid == 0) {
-               diskstats(d->gd, buf->bio, jiffies - buf->stime);
+               diskstats(d->gd, buf->bio, jiffies - buf->stime, buf->sector);
                n = (buf->flags & BUFFL_FAIL) ? -EIO : 0;
                bio_endio(buf->bio, n);
                mempool_free(buf, d->bufpool);
@@ -949,15 +959,17 @@ addtgt(struct aoedev *d, char *addr, ulong nframes)
        for (; tt < te && *tt; tt++)
                ;
 
-       if (tt == te)
+       if (tt == te) {
+               printk(KERN_INFO
+                       "aoe: device addtgt failure; too many targets\n");
                return NULL;
-
+       }
        t = kcalloc(1, sizeof *t, GFP_ATOMIC);
-       if (!t)
-               return NULL;
        f = kcalloc(nframes, sizeof *f, GFP_ATOMIC);
-       if (!f) {
+       if (!t || !f) {
+               kfree(f);
                kfree(t);
+               printk(KERN_INFO "aoe: cannot allocate memory to add target\n");
                return NULL;
        }
 
@@ -982,7 +994,6 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
        struct aoeif *ifp;
        ulong flags, sysminor, aoemajor;
        struct sk_buff *sl;
-       enum { MAXFRAMES = 16 };
        u16 n;
 
        h = (struct aoe_hdr *) skb_mac_header(skb);
@@ -1007,8 +1018,8 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
        }
 
        n = be16_to_cpu(ch->bufcnt);
-       if (n > MAXFRAMES)      /* keep it reasonable */
-               n = MAXFRAMES;
+       if (n > aoe_maxout)     /* keep it reasonable */
+               n = aoe_maxout;
 
        d = aoedev_by_sysminor_m(sysminor);
        if (d == NULL) {
@@ -1022,9 +1033,6 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
        if (!t) {
                t = addtgt(d, h->src, n);
                if (!t) {
-                       printk(KERN_INFO
-                               "aoe: device addtgt failure; "
-                               "too many targets?\n");
                        spin_unlock_irqrestore(&d->lock, flags);
                        return;
                }