From: Chun-Yi Lee <joeyli.kernel@gmail.com>
To: Justin Sanders <justin@coraid.com>
Cc: Jens Axboe <axboe@kernel.dk>, Pavel Emelianov <xemul@openvz.org>,
Kirill Korotaev <dev@openvz.org>,
"David S . Miller" <davem@davemloft.net>,
Nicolai Stange <nstange@suse.com>,
Greg KH <gregkh@linuxfoundation.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Chun-Yi Lee <jlee@suse.com>
Subject: [RFC PATCH 2/2] aoe: using wrappers instead of dev_hold/dev_put for tracking the references of net_device in aoeif
Date: Wed, 2 Oct 2024 12:06:16 +0800 [thread overview]
Message-ID: <20241002040616.25193-3-jlee@suse.com> (raw)
In-Reply-To: <20241002040616.25193-1-jlee@suse.com>
Signed-off-by: Chun-Yi Lee <jlee@suse.com>
---
drivers/block/aoe/aoecmd.c | 24 ++++++++++++------------
drivers/block/aoe/aoedev.c | 3 ++-
drivers/block/aoe/aoenet.c | 2 +-
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index d1f4ddc57645..2bae364fc5ef 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -361,7 +361,7 @@ ata_rw_frameinit(struct frame *f)
}
ah->cmdstat = ATA_CMD_PIO_READ | writebit | extbit;
- dev_hold(t->ifp->nd);
+ nd_dev_hold(t->ifp->nd, t->ifp);
skb->dev = t->ifp->nd;
}
@@ -403,7 +403,7 @@ aoecmd_ata_rw(struct aoedev *d)
__skb_queue_tail(&queue, skb);
aoenet_xmit(&queue);
} else {
- dev_put(f->t->ifp->nd);
+ nd_dev_put(f->t->ifp->nd, f->t->ifp);
}
return 1;
}
@@ -421,16 +421,16 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu
rcu_read_lock();
for_each_netdev_rcu(&init_net, ifp) {
- dev_hold(ifp);
+ nd_dev_hold(ifp, NULL);
if (!is_aoe_netif(ifp)) {
- dev_put(ifp);
+ nd_dev_put(ifp, NULL);
continue;
}
skb = new_skb(sizeof *h + sizeof *ch);
if (skb == NULL) {
printk(KERN_INFO "aoe: skb alloc failure\n");
- dev_put(ifp);
+ nd_dev_put(ifp, NULL);
continue;
}
skb_put(skb, sizeof *h + sizeof *ch);
@@ -486,11 +486,11 @@ resend(struct aoedev *d, struct frame *f)
memcpy(h->dst, t->addr, sizeof h->dst);
memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src);
- dev_hold(t->ifp->nd);
+ nd_dev_hold(t->ifp->nd, t->ifp);
skb->dev = t->ifp->nd;
skb = skb_clone(skb, GFP_ATOMIC);
if (skb == NULL) {
- dev_put(t->ifp->nd);
+ nd_dev_put(t->ifp->nd, t->ifp);
return;
}
f->sent = ktime_get();
@@ -552,7 +552,7 @@ ejectif(struct aoetgt *t, struct aoeif *ifp)
n = (e - ifp) * sizeof *ifp;
memmove(ifp, ifp+1, n);
e->nd = NULL;
- dev_put(nd);
+ nd_dev_put(nd, NULL);
}
static struct frame *
@@ -624,7 +624,7 @@ probe(struct aoetgt *t)
__skb_queue_tail(&queue, skb);
aoenet_xmit(&queue);
} else {
- dev_put(f->t->ifp->nd);
+ nd_dev_put(f->t->ifp->nd, f->t->ifp);
}
}
@@ -1403,7 +1403,7 @@ aoecmd_ata_id(struct aoedev *d)
ah->cmdstat = ATA_CMD_ID_ATA;
ah->lba3 = 0xa0;
- dev_hold(t->ifp->nd);
+ nd_dev_hold(t->ifp->nd, t->ifp);
skb->dev = t->ifp->nd;
d->rttavg = RTTAVG_INIT;
@@ -1414,7 +1414,7 @@ aoecmd_ata_id(struct aoedev *d)
if (skb)
f->sent = ktime_get();
else
- dev_put(t->ifp->nd);
+ nd_dev_put(t->ifp->nd, t->ifp);
return skb;
}
@@ -1514,7 +1514,7 @@ setifbcnt(struct aoetgt *t, struct net_device *nd, int bcnt)
pr_err("aoe: device setifbcnt failure; too many interfaces.\n");
return;
}
- dev_hold(nd);
+ nd_dev_hold(nd, p);
p->nd = nd;
p->bcnt = bcnt;
}
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 9781488b286b..48c936dbb9e5 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -504,7 +504,8 @@ freetgt(struct aoedev *d, struct aoetgt *t)
for (ifp = t->ifs; ifp < &t->ifs[NAOEIFS]; ++ifp) {
if (!ifp->nd)
break;
- dev_put(ifp->nd);
+ nd_dev_put(ifp->nd, ifp);
+ aoeif_nd_refcnt_free(ifp);
}
head = &t->ffree;
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index 923a134fd766..3565042b567f 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -63,7 +63,7 @@ tx(int id) __must_hold(&txlock)
pr_warn("aoe: packet could not be sent on %s. %s\n",
ifp ? ifp->name : "netif",
"consider increasing tx_queue_len");
- dev_put(ifp);
+ nd_dev_put(ifp, NULL);
spin_lock_irq(&txlock);
}
return 0;
--
2.35.3
next prev parent reply other threads:[~2024-10-02 4:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 4:06 [RFC PATCH 0/2] tracking the references of net_device in aoe Chun-Yi Lee
2024-10-02 4:06 ` [RFC PATCH 1/2] aoe: add reference count in aoeif for tracking the using of net_device Chun-Yi Lee
2024-10-02 5:35 ` Damien Le Moal
2024-10-04 7:17 ` joeyli
2024-10-02 18:38 ` Jens Axboe
2024-10-04 10:40 ` joeyli
2024-10-02 4:06 ` Chun-Yi Lee [this message]
2024-10-02 5:37 ` [RFC PATCH 2/2] aoe: using wrappers instead of dev_hold/dev_put for tracking the references of net_device in aoeif Damien Le Moal
2024-10-04 7:52 ` joeyli
2024-10-02 6:30 ` Greg KH
2024-10-04 7:53 ` joeyli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241002040616.25193-3-jlee@suse.com \
--to=joeyli.kernel@gmail.com \
--cc=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=dev@openvz.org \
--cc=gregkh@linuxfoundation.org \
--cc=jlee@suse.com \
--cc=justin@coraid.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nstange@suse.com \
--cc=xemul@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.