Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1004/?format=api
{ "id": 1004, "url": "http://patchwork.ozlabs.org/api/patches/1004/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20080922.191237.75584132.davem@davemloft.net/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20080922.191237.75584132.davem@davemloft.net>", "list_archive_url": null, "date": "2008-09-23T02:12:37", "name": "[4/7] : aoe: Use SKB interfaces for list management instead of home-grown stuff.", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "bd0d37c3c35a9a2ffac194e08137e234e6ea082f", "submitter": { "id": 15, "url": "http://patchwork.ozlabs.org/api/people/15/?format=api", "name": "David Miller", "email": "davem@davemloft.net" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20080922.191237.75584132.davem@davemloft.net/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/1004/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1004/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.176.167])\n\tby ozlabs.org (Postfix) with ESMTP id ACDD9DDEEF\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 23 Sep 2008 12:13:03 +1000 (EST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754133AbYIWCMy (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 22 Sep 2008 22:12:54 -0400", "(majordomo@vger.kernel.org) by vger.kernel.org id S1754128AbYIWCMx\n\t(ORCPT <rfc822; netdev-outgoing>); Mon, 22 Sep 2008 22:12:53 -0400", "from 74-93-104-97-Washington.hfc.comcastbusiness.net\n\t([74.93.104.97]:37177\n\t\"EHLO sunset.davemloft.net\" rhost-flags-OK-FAIL-OK-OK)\n\tby vger.kernel.org with ESMTP id S1754108AbYIWCMu (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 22 Sep 2008 22:12:50 -0400", "from localhost (localhost [127.0.0.1])\n\tby sunset.davemloft.net (Postfix) with ESMTP id 290CEC8C181\n\tfor <netdev@vger.kernel.org>; Mon, 22 Sep 2008 19:12:38 -0700 (PDT)" ], "Date": "Mon, 22 Sep 2008 19:12:37 -0700 (PDT)", "Message-Id": "<20080922.191237.75584132.davem@davemloft.net>", "To": "netdev@vger.kernel.org", "Subject": "[PATCH 4/7]: aoe: Use SKB interfaces for list management instead\n\tof home-grown stuff.", "From": "David Miller <davem@davemloft.net>", "X-Mailer": "Mew version 6.1 on Emacs 22.1 / Mule 5.0 (SAKAKI)", "Mime-Version": "1.0", "Content-Type": "Text/Plain; charset=us-ascii", "Content-Transfer-Encoding": "7bit", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "aoe: Use SKB interfaces for list management instead of home-grown stuff.\n\nSigned-off-by: David S. Miller <davem@davemloft.net>\n---\n drivers/block/aoe/aoe.h | 9 ++---\n drivers/block/aoe/aoeblk.c | 8 ++--\n drivers/block/aoe/aoechr.c | 8 ++++-\n drivers/block/aoe/aoecmd.c | 85 ++++++++++++++++---------------------------\n drivers/block/aoe/aoedev.c | 12 +++---\n drivers/block/aoe/aoemain.c | 1 +\n drivers/block/aoe/aoenet.c | 9 ++---\n 7 files changed, 56 insertions(+), 76 deletions(-)", "diff": "diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h\nindex 5b4c6e6..93f3690 100644\n--- a/drivers/block/aoe/aoe.h\n+++ b/drivers/block/aoe/aoe.h\n@@ -159,11 +159,8 @@ struct aoedev {\n \tsector_t ssize;\n \tstruct timer_list timer;\n \tspinlock_t lock;\n-\tstruct sk_buff *sendq_hd; /* packets needing to be sent, list head */\n-\tstruct sk_buff *sendq_tl;\n-\tstruct sk_buff *skbpool_hd;\n-\tstruct sk_buff *skbpool_tl;\n-\tint nskbpool;\n+\tstruct sk_buff_head sendq;\n+\tstruct sk_buff_head skbpool;\n \tmempool_t *bufpool;\t/* for deadlock-free Buf allocation */\n \tstruct list_head bufq;\t/* queue of bios to work on */\n \tstruct buf *inprocess;\t/* the one we're currently working on */\n@@ -199,7 +196,7 @@ int aoedev_flush(const char __user *str, size_t size);\n \n int aoenet_init(void);\n void aoenet_exit(void);\n-void aoenet_xmit(struct sk_buff *);\n+void aoenet_xmit(struct sk_buff_head *);\n int is_aoe_netif(struct net_device *ifp);\n int set_aoe_iflist(const char __user *str, size_t size);\n \ndiff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c\nindex 0c39782..fd2cf54 100644\n--- a/drivers/block/aoe/aoeblk.c\n+++ b/drivers/block/aoe/aoeblk.c\n@@ -158,9 +158,9 @@ aoeblk_release(struct inode *inode, struct file *filp)\n static int\n aoeblk_make_request(struct request_queue *q, struct bio *bio)\n {\n+\tstruct sk_buff_head queue;\n \tstruct aoedev *d;\n \tstruct buf *buf;\n-\tstruct sk_buff *sl;\n \tulong flags;\n \n \tblk_queue_bounce(q, &bio);\n@@ -213,11 +213,11 @@ aoeblk_make_request(struct request_queue *q, struct bio *bio)\n \tlist_add_tail(&buf->bufs, &d->bufq);\n \n \taoecmd_work(d);\n-\tsl = d->sendq_hd;\n-\td->sendq_hd = d->sendq_tl = NULL;\n+\t__skb_queue_head_init(&queue);\n+\tskb_queue_splice_init(&d->sendq, &queue);\n \n \tspin_unlock_irqrestore(&d->lock, flags);\n-\taoenet_xmit(sl);\n+\taoenet_xmit(&queue);\n \n \treturn 0;\n }\ndiff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c\nindex 181ebb8..1f56d2c 100644\n--- a/drivers/block/aoe/aoechr.c\n+++ b/drivers/block/aoe/aoechr.c\n@@ -9,6 +9,7 @@\n #include <linux/completion.h>\n #include <linux/delay.h>\n #include <linux/smp_lock.h>\n+#include <linux/skbuff.h>\n #include \"aoe.h\"\n \n enum {\n@@ -103,7 +104,12 @@ loop:\n \t\tspin_lock_irqsave(&d->lock, flags);\n \t\tgoto loop;\n \t}\n-\taoenet_xmit(skb);\n+\tif (skb) {\n+\t\tstruct sk_buff_head queue;\n+\t\t__skb_queue_head_init(&queue);\n+\t\t__skb_queue_tail(&queue, skb);\n+\t\taoenet_xmit(&queue);\n+\t}\n \taoecmd_cfg(major, minor);\n \treturn 0;\n }\ndiff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c\nindex 2f17462..e33da30 100644\n--- a/drivers/block/aoe/aoecmd.c\n+++ b/drivers/block/aoe/aoecmd.c\n@@ -114,29 +114,22 @@ ifrotate(struct aoetgt *t)\n static void\n skb_pool_put(struct aoedev *d, struct sk_buff *skb)\n {\n-\tif (!d->skbpool_hd)\n-\t\td->skbpool_hd = skb;\n-\telse\n-\t\td->skbpool_tl->next = skb;\n-\td->skbpool_tl = skb;\n+\t__skb_queue_tail(&d->skbpool, skb);\n }\n \n static struct sk_buff *\n skb_pool_get(struct aoedev *d)\n {\n-\tstruct sk_buff *skb;\n+\tstruct sk_buff *skb = skb_peek(&d->skbpool);\n \n-\tskb = d->skbpool_hd;\n \tif (skb && atomic_read(&skb_shinfo(skb)->dataref) == 1) {\n-\t\td->skbpool_hd = skb->next;\n-\t\tskb->next = NULL;\n+\t\t__skb_unlink(skb, &d->skbpool);\n \t\treturn skb;\n \t}\n-\tif (d->nskbpool < NSKBPOOLMAX\n-\t&& (skb = new_skb(ETH_ZLEN))) {\n-\t\td->nskbpool++;\n+\tif (skb_queue_len(&d->skbpool) < NSKBPOOLMAX &&\n+\t (skb = new_skb(ETH_ZLEN)))\n \t\treturn skb;\n-\t}\n+\n \treturn NULL;\n }\n \n@@ -293,29 +286,22 @@ aoecmd_ata_rw(struct aoedev *d)\n \n \tskb->dev = t->ifp->nd;\n \tskb = skb_clone(skb, GFP_ATOMIC);\n-\tif (skb) {\n-\t\tif (d->sendq_hd)\n-\t\t\td->sendq_tl->next = skb;\n-\t\telse\n-\t\t\td->sendq_hd = skb;\n-\t\td->sendq_tl = skb;\n-\t}\n+\tif (skb)\n+\t\t__skb_queue_tail(&d->sendq, skb);\n \treturn 1;\n }\n \n /* some callers cannot sleep, and they can call this function,\n * transmitting the packets later, when interrupts are on\n */\n-static struct sk_buff *\n-aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)\n+static void\n+aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *queue)\n {\n \tstruct aoe_hdr *h;\n \tstruct aoe_cfghdr *ch;\n-\tstruct sk_buff *skb, *sl, *sl_tail;\n+\tstruct sk_buff *skb;\n \tstruct net_device *ifp;\n \n-\tsl = sl_tail = NULL;\n-\n \tread_lock(&dev_base_lock);\n \tfor_each_netdev(&init_net, ifp) {\n \t\tdev_hold(ifp);\n@@ -329,8 +315,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)\n \t\t}\n \t\tskb_put(skb, sizeof *h + sizeof *ch);\n \t\tskb->dev = ifp;\n-\t\tif (sl_tail == NULL)\n-\t\t\tsl_tail = skb;\n+\t\t__skb_queue_tail(queue, skb);\n \t\th = (struct aoe_hdr *) skb_mac_header(skb);\n \t\tmemset(h, 0, sizeof *h + sizeof *ch);\n \n@@ -342,16 +327,10 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)\n \t\th->minor = aoeminor;\n \t\th->cmd = AOECMD_CFG;\n \n-\t\tskb->next = sl;\n-\t\tsl = skb;\n cont:\n \t\tdev_put(ifp);\n \t}\n \tread_unlock(&dev_base_lock);\n-\n-\tif (tail != NULL)\n-\t\t*tail = sl_tail;\n-\treturn sl;\n }\n \n static void\n@@ -406,11 +385,7 @@ resend(struct aoedev *d, struct aoetgt *t, struct frame *f)\n \tskb = skb_clone(skb, GFP_ATOMIC);\n \tif (skb == NULL)\n \t\treturn;\n-\tif (d->sendq_hd)\n-\t\td->sendq_tl->next = skb;\n-\telse\n-\t\td->sendq_hd = skb;\n-\td->sendq_tl = skb;\n+\t__skb_queue_tail(&d->sendq, skb);\n }\n \n static int\n@@ -508,16 +483,15 @@ ata_scnt(unsigned char *packet) {\n static void\n rexmit_timer(ulong vp)\n {\n+\tstruct sk_buff_head queue;\n \tstruct aoedev *d;\n \tstruct aoetgt *t, **tt, **te;\n \tstruct aoeif *ifp;\n \tstruct frame *f, *e;\n-\tstruct sk_buff *sl;\n \tregister long timeout;\n \tulong flags, n;\n \n \td = (struct aoedev *) vp;\n-\tsl = NULL;\n \n \t/* timeout is always ~150% of the moving average */\n \ttimeout = d->rttavg;\n@@ -589,7 +563,7 @@ rexmit_timer(ulong vp)\n \t\t}\n \t}\n \n-\tif (d->sendq_hd) {\n+\tif (!skb_queue_empty(&d->sendq)) {\n \t\tn = d->rttavg <<= 1;\n \t\tif (n > MAXTIMER)\n \t\t\td->rttavg = MAXTIMER;\n@@ -600,15 +574,15 @@ rexmit_timer(ulong vp)\n \t\taoecmd_work(d);\n \t}\n \n-\tsl = d->sendq_hd;\n-\td->sendq_hd = d->sendq_tl = NULL;\n+\t__skb_queue_head_init(&queue);\n+\tskb_queue_splice_init(&d->sendq, &queue);\n \n \td->timer.expires = jiffies + TIMERTICK;\n \tadd_timer(&d->timer);\n \n \tspin_unlock_irqrestore(&d->lock, flags);\n \n-\taoenet_xmit(sl);\n+\taoenet_xmit(&queue);\n }\n \n /* enters with d->lock held */\n@@ -767,12 +741,12 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector\n void\n aoecmd_ata_rsp(struct sk_buff *skb)\n {\n+\tstruct sk_buff_head queue;\n \tstruct aoedev *d;\n \tstruct aoe_hdr *hin, *hout;\n \tstruct aoe_atahdr *ahin, *ahout;\n \tstruct frame *f;\n \tstruct buf *buf;\n-\tstruct sk_buff *sl;\n \tstruct aoetgt *t;\n \tstruct aoeif *ifp;\n \tregister long n;\n@@ -893,21 +867,21 @@ aoecmd_ata_rsp(struct sk_buff *skb)\n \n \taoecmd_work(d);\n xmit:\n-\tsl = d->sendq_hd;\n-\td->sendq_hd = d->sendq_tl = NULL;\n+\t__skb_queue_head_init(&queue);\n+\tskb_queue_splice_init(&d->sendq, &queue);\n \n \tspin_unlock_irqrestore(&d->lock, flags);\n-\taoenet_xmit(sl);\n+\taoenet_xmit(&queue);\n }\n \n void\n aoecmd_cfg(ushort aoemajor, unsigned char aoeminor)\n {\n-\tstruct sk_buff *sl;\n-\n-\tsl = aoecmd_cfg_pkts(aoemajor, aoeminor, NULL);\n+\tstruct sk_buff_head queue;\n \n-\taoenet_xmit(sl);\n+\t__skb_queue_head_init(&queue);\n+\taoecmd_cfg_pkts(aoemajor, aoeminor, &queue);\n+\taoenet_xmit(&queue);\n }\n \n struct sk_buff *\n@@ -1076,7 +1050,12 @@ aoecmd_cfg_rsp(struct sk_buff *skb)\n \n \tspin_unlock_irqrestore(&d->lock, flags);\n \n-\taoenet_xmit(sl);\n+\tif (sl) {\n+\t\tstruct sk_buff_head queue;\n+\t\t__skb_queue_head_init(&queue);\n+\t\t__skb_queue_tail(&queue, sl);\n+\t\taoenet_xmit(&queue);\n+\t}\n }\n \n void\ndiff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c\nindex a1d813a..75a610a 100644\n--- a/drivers/block/aoe/aoedev.c\n+++ b/drivers/block/aoe/aoedev.c\n@@ -188,14 +188,12 @@ skbfree(struct sk_buff *skb)\n static void\n skbpoolfree(struct aoedev *d)\n {\n-\tstruct sk_buff *skb;\n+\tstruct sk_buff *skb, *tmp;\n \n-\twhile ((skb = d->skbpool_hd)) {\n-\t\td->skbpool_hd = skb->next;\n-\t\tskb->next = NULL;\n+\tskb_queue_walk_safe(&d->skbpool, skb, tmp)\n \t\tskbfree(skb);\n-\t}\n-\td->skbpool_tl = NULL;\n+\n+\t__skb_queue_head_init(&d->skbpool);\n }\n \n /* find it or malloc it */\n@@ -217,6 +215,8 @@ aoedev_by_sysminor_m(ulong sysminor)\n \t\tgoto out;\n \tINIT_WORK(&d->work, aoecmd_sleepwork);\n \tspin_lock_init(&d->lock);\n+\tskb_queue_head_init(&d->sendq);\n+\tskb_queue_head_init(&d->skbpool);\n \tinit_timer(&d->timer);\n \td->timer.data = (ulong) d;\n \td->timer.function = dummy_timer;\ndiff --git a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c\nindex 7b15a5e..7f83ad9 100644\n--- a/drivers/block/aoe/aoemain.c\n+++ b/drivers/block/aoe/aoemain.c\n@@ -7,6 +7,7 @@\n #include <linux/hdreg.h>\n #include <linux/blkdev.h>\n #include <linux/module.h>\n+#include <linux/skbuff.h>\n #include \"aoe.h\"\n \n MODULE_LICENSE(\"GPL\");\ndiff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c\nindex 0c81ca7..8fb2603 100644\n--- a/drivers/block/aoe/aoenet.c\n+++ b/drivers/block/aoe/aoenet.c\n@@ -95,15 +95,12 @@ mac_addr(char addr[6])\n }\n \n void\n-aoenet_xmit(struct sk_buff *sl)\n+aoenet_xmit(struct sk_buff_head *queue)\n {\n-\tstruct sk_buff *skb;\n+\tstruct sk_buff *skb, *tmp;\n \n-\twhile ((skb = sl)) {\n-\t\tsl = sl->next;\n-\t\tskb->next = skb->prev = NULL;\n+\tskb_queue_walk_safe(queue, skb, tmp)\n \t\tdev_queue_xmit(skb);\n-\t}\n }\n \n /* \n", "prefixes": [ "4/7" ] }