diff options
Diffstat (limited to 'drivers/block/aoe/aoedev.c')
-rw-r--r-- | drivers/block/aoe/aoedev.c | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index ed4258a62df5..6125921bbec4 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.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 | * aoedev.c | 3 | * aoedev.c |
4 | * AoE device utility functions; maintains device list. | 4 | * AoE device utility functions; maintains device list. |
@@ -20,11 +20,8 @@ aoedev_isbusy(struct aoedev *d) | |||
20 | f = d->frames; | 20 | f = d->frames; |
21 | e = f + d->nframes; | 21 | e = f + d->nframes; |
22 | do { | 22 | do { |
23 | if (f->tag != FREETAG) { | 23 | if (f->tag != FREETAG) |
24 | printk(KERN_DEBUG "aoe: %ld.%ld isbusy\n", | ||
25 | d->aoemajor, d->aoeminor); | ||
26 | return 1; | 24 | return 1; |
27 | } | ||
28 | } while (++f < e); | 25 | } while (++f < e); |
29 | 26 | ||
30 | return 0; | 27 | return 0; |
@@ -66,22 +63,32 @@ aoedev_newdev(ulong nframes) | |||
66 | struct frame *f, *e; | 63 | struct frame *f, *e; |
67 | 64 | ||
68 | d = kzalloc(sizeof *d, GFP_ATOMIC); | 65 | d = kzalloc(sizeof *d, GFP_ATOMIC); |
69 | if (d == NULL) | ||
70 | return NULL; | ||
71 | f = kcalloc(nframes, sizeof *f, GFP_ATOMIC); | 66 | f = kcalloc(nframes, sizeof *f, GFP_ATOMIC); |
72 | if (f == NULL) { | 67 | switch (!d || !f) { |
73 | kfree(d); | 68 | case 0: |
69 | d->nframes = nframes; | ||
70 | d->frames = f; | ||
71 | e = f + nframes; | ||
72 | for (; f<e; f++) { | ||
73 | f->tag = FREETAG; | ||
74 | f->skb = new_skb(ETH_ZLEN); | ||
75 | if (!f->skb) | ||
76 | break; | ||
77 | } | ||
78 | if (f == e) | ||
79 | break; | ||
80 | while (f > d->frames) { | ||
81 | f--; | ||
82 | dev_kfree_skb(f->skb); | ||
83 | } | ||
84 | default: | ||
85 | if (f) | ||
86 | kfree(f); | ||
87 | if (d) | ||
88 | kfree(d); | ||
74 | return NULL; | 89 | return NULL; |
75 | } | 90 | } |
76 | |||
77 | INIT_WORK(&d->work, aoecmd_sleepwork, d); | 91 | INIT_WORK(&d->work, aoecmd_sleepwork, d); |
78 | |||
79 | d->nframes = nframes; | ||
80 | d->frames = f; | ||
81 | e = f + nframes; | ||
82 | for (; f<e; f++) | ||
83 | f->tag = FREETAG; | ||
84 | |||
85 | spin_lock_init(&d->lock); | 92 | spin_lock_init(&d->lock); |
86 | init_timer(&d->timer); | 93 | init_timer(&d->timer); |
87 | d->timer.data = (ulong) d; | 94 | d->timer.data = (ulong) d; |
@@ -114,6 +121,7 @@ aoedev_downdev(struct aoedev *d) | |||
114 | mempool_free(buf, d->bufpool); | 121 | mempool_free(buf, d->bufpool); |
115 | bio_endio(bio, bio->bi_size, -EIO); | 122 | bio_endio(bio, bio->bi_size, -EIO); |
116 | } | 123 | } |
124 | skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0; | ||
117 | } | 125 | } |
118 | d->inprocess = NULL; | 126 | d->inprocess = NULL; |
119 | 127 | ||
@@ -148,7 +156,7 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt) | |||
148 | d = aoedev_newdev(bufcnt); | 156 | d = aoedev_newdev(bufcnt); |
149 | if (d == NULL) { | 157 | if (d == NULL) { |
150 | spin_unlock_irqrestore(&devlist_lock, flags); | 158 | spin_unlock_irqrestore(&devlist_lock, flags); |
151 | printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n"); | 159 | printk(KERN_INFO "aoe: aoedev_newdev failure.\n"); |
152 | return NULL; | 160 | return NULL; |
153 | } | 161 | } |
154 | d->sysminor = sysminor; | 162 | d->sysminor = sysminor; |
@@ -163,11 +171,19 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt) | |||
163 | static void | 171 | static void |
164 | aoedev_freedev(struct aoedev *d) | 172 | aoedev_freedev(struct aoedev *d) |
165 | { | 173 | { |
174 | struct frame *f, *e; | ||
175 | |||
166 | if (d->gd) { | 176 | if (d->gd) { |
167 | aoedisk_rm_sysfs(d); | 177 | aoedisk_rm_sysfs(d); |
168 | del_gendisk(d->gd); | 178 | del_gendisk(d->gd); |
169 | put_disk(d->gd); | 179 | put_disk(d->gd); |
170 | } | 180 | } |
181 | f = d->frames; | ||
182 | e = f + d->nframes; | ||
183 | for (; f<e; f++) { | ||
184 | skb_shinfo(f->skb)->nr_frags = 0; | ||
185 | dev_kfree_skb(f->skb); | ||
186 | } | ||
171 | kfree(d->frames); | 187 | kfree(d->frames); |
172 | if (d->bufpool) | 188 | if (d->bufpool) |
173 | mempool_destroy(d->bufpool); | 189 | mempool_destroy(d->bufpool); |