Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
[sfrench/cifs-2.6.git] / drivers / block / aoe / aoecmd.c
index bcea36c87d04dcd86734df58af5bcf4c9e5196b2..d00293ba3b456187a21b1b2aa6fa5ccff49c0dfc 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
@@ -751,15 +751,15 @@ 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);
 
-       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);
+       all_stat_inc(disk, ios[rw], sector);
+       all_stat_add(disk, ticks[rw], duration, sector);
+       all_stat_add(disk, sectors[rw], n_sect, sector);
+       all_stat_add(disk, io_ticks, duration, sector);
 }
 
 void
@@ -879,7 +879,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
        }
 
        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);
@@ -957,15 +957,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;
        }
 
@@ -1029,9 +1031,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;
                }