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