aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/aoe/aoeblk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/aoe/aoeblk.c')
-rw-r--r--drivers/block/aoe/aoeblk.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 393b86a3dbf8..d433f27e0ce2 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoeblk.c 3 * aoeblk.c
4 * block device routines 4 * block device routines
@@ -14,7 +14,6 @@
14 14
15static kmem_cache_t *buf_pool_cache; 15static kmem_cache_t *buf_pool_cache;
16 16
17/* add attributes for our block devices in sysfs */
18static ssize_t aoedisk_show_state(struct gendisk * disk, char *page) 17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
19{ 18{
20 struct aoedev *d = disk->private_data; 19 struct aoedev *d = disk->private_data;
@@ -64,21 +63,26 @@ static struct disk_attribute disk_attr_fwver = {
64 .show = aoedisk_show_fwver 63 .show = aoedisk_show_fwver
65}; 64};
66 65
67static void 66static struct attribute *aoe_attrs[] = {
67 &disk_attr_state.attr,
68 &disk_attr_mac.attr,
69 &disk_attr_netif.attr,
70 &disk_attr_fwver.attr,
71};
72
73static const struct attribute_group attr_group = {
74 .attrs = aoe_attrs,
75};
76
77static int
68aoedisk_add_sysfs(struct aoedev *d) 78aoedisk_add_sysfs(struct aoedev *d)
69{ 79{
70 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr); 80 return sysfs_create_group(&d->gd->kobj, &attr_group);
71 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
72 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
73 sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
74} 81}
75void 82void
76aoedisk_rm_sysfs(struct aoedev *d) 83aoedisk_rm_sysfs(struct aoedev *d)
77{ 84{
78 sysfs_remove_link(&d->gd->kobj, "state"); 85 sysfs_remove_group(&d->gd->kobj, &attr_group);
79 sysfs_remove_link(&d->gd->kobj, "mac");
80 sysfs_remove_link(&d->gd->kobj, "netif");
81 sysfs_remove_link(&d->gd->kobj, "firmware-version");
82} 86}
83 87
84static int 88static int
@@ -132,8 +136,7 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
132 d = bio->bi_bdev->bd_disk->private_data; 136 d = bio->bi_bdev->bd_disk->private_data;
133 buf = mempool_alloc(d->bufpool, GFP_NOIO); 137 buf = mempool_alloc(d->bufpool, GFP_NOIO);
134 if (buf == NULL) { 138 if (buf == NULL) {
135 printk(KERN_INFO "aoe: aoeblk_make_request: buf allocation " 139 printk(KERN_INFO "aoe: buf allocation failure\n");
136 "failure\n");
137 bio_endio(bio, bio->bi_size, -ENOMEM); 140 bio_endio(bio, bio->bi_size, -ENOMEM);
138 return 0; 141 return 0;
139 } 142 }
@@ -143,14 +146,15 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
143 buf->bio = bio; 146 buf->bio = bio;
144 buf->resid = bio->bi_size; 147 buf->resid = bio->bi_size;
145 buf->sector = bio->bi_sector; 148 buf->sector = bio->bi_sector;
146 buf->bv = buf->bio->bi_io_vec; 149 buf->bv = &bio->bi_io_vec[bio->bi_idx];
150 WARN_ON(buf->bv->bv_len == 0);
147 buf->bv_resid = buf->bv->bv_len; 151 buf->bv_resid = buf->bv->bv_len;
148 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset; 152 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset;
149 153
150 spin_lock_irqsave(&d->lock, flags); 154 spin_lock_irqsave(&d->lock, flags);
151 155
152 if ((d->flags & DEVFL_UP) == 0) { 156 if ((d->flags & DEVFL_UP) == 0) {
153 printk(KERN_INFO "aoe: aoeblk_make_request: device %ld.%ld is not up\n", 157 printk(KERN_INFO "aoe: device %ld.%ld is not up\n",
154 d->aoemajor, d->aoeminor); 158 d->aoemajor, d->aoeminor);
155 spin_unlock_irqrestore(&d->lock, flags); 159 spin_unlock_irqrestore(&d->lock, flags);
156 mempool_free(buf, d->bufpool); 160 mempool_free(buf, d->bufpool);
@@ -176,7 +180,7 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
176 struct aoedev *d = bdev->bd_disk->private_data; 180 struct aoedev *d = bdev->bd_disk->private_data;
177 181
178 if ((d->flags & DEVFL_UP) == 0) { 182 if ((d->flags & DEVFL_UP) == 0) {
179 printk(KERN_ERR "aoe: aoeblk_ioctl: disk not up\n"); 183 printk(KERN_ERR "aoe: disk not up\n");
180 return -ENODEV; 184 return -ENODEV;
181 } 185 }
182 186
@@ -203,8 +207,8 @@ aoeblk_gdalloc(void *vp)
203 207
204 gd = alloc_disk(AOE_PARTITIONS); 208 gd = alloc_disk(AOE_PARTITIONS);
205 if (gd == NULL) { 209 if (gd == NULL) {
206 printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate disk " 210 printk(KERN_ERR "aoe: cannot allocate disk structure for %ld.%ld\n",
207 "structure for %ld.%ld\n", d->aoemajor, d->aoeminor); 211 d->aoemajor, d->aoeminor);
208 spin_lock_irqsave(&d->lock, flags); 212 spin_lock_irqsave(&d->lock, flags);
209 d->flags &= ~DEVFL_GDALLOC; 213 d->flags &= ~DEVFL_GDALLOC;
210 spin_unlock_irqrestore(&d->lock, flags); 214 spin_unlock_irqrestore(&d->lock, flags);
@@ -213,8 +217,8 @@ aoeblk_gdalloc(void *vp)
213 217
214 d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache); 218 d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache);
215 if (d->bufpool == NULL) { 219 if (d->bufpool == NULL) {
216 printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate bufpool " 220 printk(KERN_ERR "aoe: cannot allocate bufpool for %ld.%ld\n",
217 "for %ld.%ld\n", d->aoemajor, d->aoeminor); 221 d->aoemajor, d->aoeminor);
218 put_disk(gd); 222 put_disk(gd);
219 spin_lock_irqsave(&d->lock, flags); 223 spin_lock_irqsave(&d->lock, flags);
220 d->flags &= ~DEVFL_GDALLOC; 224 d->flags &= ~DEVFL_GDALLOC;