diff options
author | Ed Cashin <ecashin@coraid.com> | 2012-12-17 19:04:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 20:15:25 -0500 |
commit | 71114ec45f09eb6ef6f9d41c98d4ab6455086e58 (patch) | |
tree | 3f25f6e70364656b06387955764cd61e08148d3f /drivers | |
parent | e52a29326462badd9ceec90a9eb2ac2a8550e02e (diff) |
aoe: use dynamic number of remote ports for AoE storage target
Many AoE targets have four or fewer network ports, but some existing
storage devices have many, and the AoE protocol sets no limit.
This patch allows the use of more than eight remote MAC addresses per AoE
target, while reducing the amount of memory used by the aoe driver in
cases where there are many AoE targets with fewer than eight MAC addresses
each.
Signed-off-by: Ed Cashin <ecashin@coraid.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/aoe/aoe.h | 6 | ||||
-rw-r--r-- | drivers/block/aoe/aoeblk.c | 2 | ||||
-rw-r--r-- | drivers/block/aoe/aoecmd.c | 50 | ||||
-rw-r--r-- | drivers/block/aoe/aoedev.c | 12 |
4 files changed, 49 insertions, 21 deletions
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h index d50e9455b937..0f478dcfc199 100644 --- a/drivers/block/aoe/aoe.h +++ b/drivers/block/aoe/aoe.h | |||
@@ -84,7 +84,7 @@ enum { | |||
84 | enum { | 84 | enum { |
85 | DEFAULTBCNT = 2 * 512, /* 2 sectors */ | 85 | DEFAULTBCNT = 2 * 512, /* 2 sectors */ |
86 | MIN_BUFS = 16, | 86 | MIN_BUFS = 16, |
87 | NTARGETS = 8, | 87 | NTARGETS = 4, |
88 | NAOEIFS = 8, | 88 | NAOEIFS = 8, |
89 | NSKBPOOLMAX = 256, | 89 | NSKBPOOLMAX = 256, |
90 | NFACTIVE = 61, | 90 | NFACTIVE = 61, |
@@ -185,9 +185,9 @@ struct aoedev { | |||
185 | ulong maxbcnt; | 185 | ulong maxbcnt; |
186 | struct list_head factive[NFACTIVE]; /* hash of active frames */ | 186 | struct list_head factive[NFACTIVE]; /* hash of active frames */ |
187 | struct list_head rexmitq; /* deferred retransmissions */ | 187 | struct list_head rexmitq; /* deferred retransmissions */ |
188 | struct aoetgt *targets[NTARGETS]; | 188 | struct aoetgt **targets; |
189 | ulong ntargets; /* number of allocated aoetgt pointers */ | ||
189 | struct aoetgt **tgt; /* target in use when working */ | 190 | struct aoetgt **tgt; /* target in use when working */ |
190 | ulong ntargets; | ||
191 | ulong kicked; | 191 | ulong kicked; |
192 | char ident[512]; | 192 | char ident[512]; |
193 | }; | 193 | }; |
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 6b5b7876ecf3..a129f8c8073d 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c | |||
@@ -67,7 +67,7 @@ static ssize_t aoedisk_show_netif(struct device *dev, | |||
67 | nd = nds; | 67 | nd = nds; |
68 | ne = nd + ARRAY_SIZE(nds); | 68 | ne = nd + ARRAY_SIZE(nds); |
69 | t = d->targets; | 69 | t = d->targets; |
70 | te = t + NTARGETS; | 70 | te = t + d->ntargets; |
71 | for (; t < te && *t; t++) { | 71 | for (; t < te && *t; t++) { |
72 | ifp = (*t)->ifs; | 72 | ifp = (*t)->ifs; |
73 | e = ifp + NAOEIFS; | 73 | e = ifp + NAOEIFS; |
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index 000f7fb48841..da360f95c8ea 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -242,14 +242,14 @@ newframe(struct aoedev *d) | |||
242 | int use_tainted; | 242 | int use_tainted; |
243 | int has_untainted; | 243 | int has_untainted; |
244 | 244 | ||
245 | if (d->targets[0] == NULL) { /* shouldn't happen, but I'm paranoid */ | 245 | if (!d->targets || !d->targets[0]) { |
246 | printk(KERN_ERR "aoe: NULL TARGETS!\n"); | 246 | printk(KERN_ERR "aoe: NULL TARGETS!\n"); |
247 | return NULL; | 247 | return NULL; |
248 | } | 248 | } |
249 | tt = d->tgt; /* last used target */ | 249 | tt = d->tgt; /* last used target */ |
250 | for (use_tainted = 0, has_untainted = 0;;) { | 250 | for (use_tainted = 0, has_untainted = 0;;) { |
251 | tt++; | 251 | tt++; |
252 | if (tt >= &d->targets[NTARGETS] || !*tt) | 252 | if (tt >= &d->targets[d->ntargets] || !*tt) |
253 | tt = d->targets; | 253 | tt = d->targets; |
254 | t = *tt; | 254 | t = *tt; |
255 | if (!t->taint) { | 255 | if (!t->taint) { |
@@ -1104,7 +1104,7 @@ gettgt(struct aoedev *d, char *addr) | |||
1104 | struct aoetgt **t, **e; | 1104 | struct aoetgt **t, **e; |
1105 | 1105 | ||
1106 | t = d->targets; | 1106 | t = d->targets; |
1107 | e = t + NTARGETS; | 1107 | e = t + d->ntargets; |
1108 | for (; t < e && *t; t++) | 1108 | for (; t < e && *t; t++) |
1109 | if (memcmp((*t)->addr, addr, sizeof((*t)->addr)) == 0) | 1109 | if (memcmp((*t)->addr, addr, sizeof((*t)->addr)) == 0) |
1110 | return *t; | 1110 | return *t; |
@@ -1479,28 +1479,44 @@ aoecmd_ata_id(struct aoedev *d) | |||
1479 | return skb; | 1479 | return skb; |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | static struct aoetgt ** | ||
1483 | grow_targets(struct aoedev *d) | ||
1484 | { | ||
1485 | ulong oldn, newn; | ||
1486 | struct aoetgt **tt; | ||
1487 | |||
1488 | oldn = d->ntargets; | ||
1489 | newn = oldn * 2; | ||
1490 | tt = kcalloc(newn, sizeof(*d->targets), GFP_ATOMIC); | ||
1491 | if (!tt) | ||
1492 | return NULL; | ||
1493 | memmove(tt, d->targets, sizeof(*d->targets) * oldn); | ||
1494 | d->tgt = tt + (d->tgt - d->targets); | ||
1495 | kfree(d->targets); | ||
1496 | d->targets = tt; | ||
1497 | d->ntargets = newn; | ||
1498 | |||
1499 | return &d->targets[oldn]; | ||
1500 | } | ||
1501 | |||
1482 | static struct aoetgt * | 1502 | static struct aoetgt * |
1483 | addtgt(struct aoedev *d, char *addr, ulong nframes) | 1503 | addtgt(struct aoedev *d, char *addr, ulong nframes) |
1484 | { | 1504 | { |
1485 | struct aoetgt *t, **tt, **te; | 1505 | struct aoetgt *t, **tt, **te; |
1486 | 1506 | ||
1487 | tt = d->targets; | 1507 | tt = d->targets; |
1488 | te = tt + NTARGETS; | 1508 | te = tt + d->ntargets; |
1489 | for (; tt < te && *tt; tt++) | 1509 | for (; tt < te && *tt; tt++) |
1490 | ; | 1510 | ; |
1491 | 1511 | ||
1492 | if (tt == te) { | 1512 | if (tt == te) { |
1493 | printk(KERN_INFO | 1513 | tt = grow_targets(d); |
1494 | "aoe: device addtgt failure; too many targets\n"); | 1514 | if (!tt) |
1495 | return NULL; | 1515 | goto nomem; |
1496 | } | 1516 | } |
1497 | t = kzalloc(sizeof(*t), GFP_ATOMIC); | 1517 | t = kzalloc(sizeof(*t), GFP_ATOMIC); |
1498 | if (!t) { | 1518 | if (!t) |
1499 | printk(KERN_INFO "aoe: cannot allocate memory to add target\n"); | 1519 | goto nomem; |
1500 | return NULL; | ||
1501 | } | ||
1502 | |||
1503 | d->ntargets++; | ||
1504 | t->nframes = nframes; | 1520 | t->nframes = nframes; |
1505 | t->d = d; | 1521 | t->d = d; |
1506 | memcpy(t->addr, addr, sizeof t->addr); | 1522 | memcpy(t->addr, addr, sizeof t->addr); |
@@ -1509,6 +1525,10 @@ addtgt(struct aoedev *d, char *addr, ulong nframes) | |||
1509 | t->maxout = t->nframes / 2; | 1525 | t->maxout = t->nframes / 2; |
1510 | INIT_LIST_HEAD(&t->ffree); | 1526 | INIT_LIST_HEAD(&t->ffree); |
1511 | return *tt = t; | 1527 | return *tt = t; |
1528 | |||
1529 | nomem: | ||
1530 | pr_info("aoe: cannot allocate memory to add target\n"); | ||
1531 | return NULL; | ||
1512 | } | 1532 | } |
1513 | 1533 | ||
1514 | static void | 1534 | static void |
@@ -1518,7 +1538,7 @@ setdbcnt(struct aoedev *d) | |||
1518 | int bcnt = 0; | 1538 | int bcnt = 0; |
1519 | 1539 | ||
1520 | t = d->targets; | 1540 | t = d->targets; |
1521 | e = t + NTARGETS; | 1541 | e = t + d->ntargets; |
1522 | for (; t < e && *t; t++) | 1542 | for (; t < e && *t; t++) |
1523 | if (bcnt == 0 || bcnt > (*t)->minbcnt) | 1543 | if (bcnt == 0 || bcnt > (*t)->minbcnt) |
1524 | bcnt = (*t)->minbcnt; | 1544 | bcnt = (*t)->minbcnt; |
@@ -1662,7 +1682,7 @@ aoecmd_cleanslate(struct aoedev *d) | |||
1662 | d->maxbcnt = 0; | 1682 | d->maxbcnt = 0; |
1663 | 1683 | ||
1664 | t = d->targets; | 1684 | t = d->targets; |
1665 | te = t + NTARGETS; | 1685 | te = t + d->ntargets; |
1666 | for (; t < te && *t; t++) | 1686 | for (; t < te && *t; t++) |
1667 | aoecmd_wreset(*t); | 1687 | aoecmd_wreset(*t); |
1668 | } | 1688 | } |
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index 3776715eb255..e66ccbf41a50 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c | |||
@@ -214,7 +214,7 @@ aoedev_downdev(struct aoedev *d) | |||
214 | 214 | ||
215 | /* reset window dressings */ | 215 | /* reset window dressings */ |
216 | tt = d->targets; | 216 | tt = d->targets; |
217 | te = tt + NTARGETS; | 217 | te = tt + d->ntargets; |
218 | for (; tt < te && (t = *tt); tt++) { | 218 | for (; tt < te && (t = *tt); tt++) { |
219 | aoecmd_wreset(t); | 219 | aoecmd_wreset(t); |
220 | t->nout = 0; | 220 | t->nout = 0; |
@@ -284,7 +284,7 @@ freedev(struct aoedev *d) | |||
284 | blk_cleanup_queue(d->blkq); | 284 | blk_cleanup_queue(d->blkq); |
285 | } | 285 | } |
286 | t = d->targets; | 286 | t = d->targets; |
287 | e = t + NTARGETS; | 287 | e = t + d->ntargets; |
288 | for (; t < e && *t; t++) | 288 | for (; t < e && *t; t++) |
289 | freetgt(d, *t); | 289 | freetgt(d, *t); |
290 | if (d->bufpool) | 290 | if (d->bufpool) |
@@ -376,6 +376,8 @@ restart: | |||
376 | dd = &d->next; | 376 | dd = &d->next; |
377 | } | 377 | } |
378 | spin_unlock(&d->lock); | 378 | spin_unlock(&d->lock); |
379 | if (doomed) | ||
380 | kfree(doomed->targets); | ||
379 | kfree(doomed); | 381 | kfree(doomed); |
380 | } | 382 | } |
381 | spin_unlock_irqrestore(&devlist_lock, flags); | 383 | spin_unlock_irqrestore(&devlist_lock, flags); |
@@ -456,6 +458,12 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc) | |||
456 | d = kcalloc(1, sizeof *d, GFP_ATOMIC); | 458 | d = kcalloc(1, sizeof *d, GFP_ATOMIC); |
457 | if (!d) | 459 | if (!d) |
458 | goto out; | 460 | goto out; |
461 | d->targets = kcalloc(NTARGETS, sizeof(*d->targets), GFP_ATOMIC); | ||
462 | if (!d->targets) { | ||
463 | kfree(d); | ||
464 | goto out; | ||
465 | } | ||
466 | d->ntargets = NTARGETS; | ||
459 | INIT_WORK(&d->work, aoecmd_sleepwork); | 467 | INIT_WORK(&d->work, aoecmd_sleepwork); |
460 | spin_lock_init(&d->lock); | 468 | spin_lock_init(&d->lock); |
461 | skb_queue_head_init(&d->skbpool); | 469 | skb_queue_head_init(&d->skbpool); |