9 #include <linux/netdevice.h>
11 #include <linux/slab.h>
12 #include <linux/bitmap.h>
13 #include <linux/kdev_t.h>
17 static void dummy_timer(
ulong);
18 static void aoedev_freedev(
struct aoedev *);
20 static void skbpoolfree(
struct aoedev *
d);
22 static int aoe_dyndevs = 1;
36 #define N_DEVS ((1U<<MINORBITS)/AOE_PARTITIONS)
54 spin_unlock_irqrestore(&used_minors_lock, flags);
61 minor_get_static(
ulong *sysminor,
ulong aoemaj,
int aoemin)
72 n = aoemaj * NPERSHELF + aoemin;
73 if (aoemin >= NPERSHELF || n >=
N_DEVS) {
74 pr_err(
"aoe: %s with e%ld.%d\n",
75 "cannot use static minor device numbers",
82 "existing device already has static minor number",
87 spin_unlock_irqrestore(&used_minors_lock, flags);
95 minor_get(
ulong *sysminor,
ulong aoemaj,
int aoemin)
98 return minor_get_dyn(sysminor);
100 return minor_get_static(sysminor, aoemaj, aoemin);
104 minor_free(
ulong minor)
114 spin_unlock_irqrestore(&used_minors_lock, flags);
136 spin_unlock_irqrestore(&devlist_lock, flags);
140 dummy_timer(
ulong vp)
152 aoe_failip(
struct aoedev *d)
163 while ((bio = d->
ip.nxbio)) {
165 d->
ip.nxbio = bio->bi_next;
166 n = (
unsigned long) rq->special;
167 rq->special = (
void *) --
n;
169 if ((
unsigned long) rq->special == 0)
191 f->
buf->nframesout--;
200 for (; tt < te && (t = *
tt); tt++) {
201 t->maxout = t->nframes;
218 set_capacity(d->
gd, 0);
222 aoedev_freedev(
struct aoedev *d)
235 for (; t < e && *
t; t++)
254 if (cnt >
sizeof buf)
269 spin_unlock(&d->
lock);
276 spin_unlock(&d->
lock);
280 spin_unlock_irqrestore(&devlist_lock, flags);
297 enum { Sms = 250, Tms = 30 * 1000};
302 while (
atomic_read(&skb_shinfo(skb)->dataref) != 1 && i-- > 0)
306 "aoe: %s holds ref: %s\n",
307 skb->
dev ? skb->
dev->name :
"netif",
308 "cannot free skb -- memory leaked.");
312 skb_shinfo(skb)->nr_frags = skb->
data_len = 0;
318 skbpoolfree(
struct aoedev *d)
322 skb_queue_walk_safe(&d->
skbpool, skb, tmp)
325 __skb_queue_head_init(&d->skbpool);
339 for (d=devlist;
d; d=d->
next)
344 if (d || !do_alloc || minor_get(&sysminor, maj, min) < 0)
351 skb_queue_head_init(&d->
skbpool);
354 d->
timer.function = dummy_timer;
361 INIT_LIST_HEAD(&d->
factive[i]);
369 spin_unlock_irqrestore(&devlist_lock, flags);
403 while ((d = devlist)) {
409 spin_unlock_irqrestore(&d->
lock, flags);