From patchwork Wed Oct 2 04:06:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 13819325 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51FAF18027; Wed, 2 Oct 2024 04:06:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727841992; cv=none; b=DfMIwB5j29MgJwDkYjdwafK7S/XCm4QRBICzBkMmUKT/eYtPV+88woyn2TD+QDf3MGZ1Xvk27NwiHmBoUlvlsL7QY4ng9eQcQpv2iQaZ3mNaABHmv/pe8+Zr7Ld4ng/+TxfToZbDyUjeGdtYxEK88aUSv9X3/1eC4j33/f3F5wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727841992; c=relaxed/simple; bh=zo5VwSEKCU/Lvb5+t+mW5K5kPk3hOVnEu83LPoCmyx4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=rF2bKG0ioGyHswlGOsMetbs9Ql6RxNM05tbEdAPEtyDT6k7pyYp8tafNrxncDkTOuVl44mKw3jSPL0qiKFgmCf7HPD4yWQJBaCckm2DzGQXgAyoC95OLHYKiUzHhJprSuYYi6BSDs7pGda7YQpdfRq2Ik8rb0zt2qsZR5capxO4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NsFKhDlE; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NsFKhDlE" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2e109539aedso2807452a91.0; Tue, 01 Oct 2024 21:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727841991; x=1728446791; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=jvO3ydRgY4tt/z1UVsF5Faqu4tn053ewwaTrZBvxX0Y=; b=NsFKhDlEd4Mq4zwXsMh4Xx+odOWVLqh7FemQXlHgMHncRPstKC23p8Sm32R9uxuunT 0HN34msA18hf4FzLvAuog1zxze8PCQIi681ntL8a+SWN42O9Ot5VWGESzWZxjEKzo8nT mLNvgIj4hnm0IYqauAXbpK03IIehtcrqMrSekVOaxo2DQOauWXPVJgiN2CnEpq2arMx/ XeJ7KLoqx2dIu6I6DCFUNPVf3+F/xF0jP2IvvxHG55ynrthhvpjalVQRxPYF7PQNbvSe kNnhvLk/rdFCyl8oDlvu3RHgTsn+vt9SsSuPx7mJdRzz7Evw86xNL1N5jkZ2ZdLnibxm 89CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727841991; x=1728446791; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jvO3ydRgY4tt/z1UVsF5Faqu4tn053ewwaTrZBvxX0Y=; b=UF59412Agn4bcfINQ8dGCrosCX6p/yXJbAwUQB3dur3fOfucQSL0dCv0gGhD5NWwZG FZKL6x3X+B+99ME+nUQg+DZZsMcEHHx3H40kjLI0EWNCNo8RDTfwbVuFDjm4Fwh4kD4t WLrXwbtdYVZkCuIE/Zd/f8kXxllsHWPUNXv3N1KA4PfY67dbQI5EjizUjhENvYMjFxdX am6dJ8ZEo502DqmMlrKMnyDX7URp7KanPLaoDMvPMM4WB/4XXUNkoTAxE3qgUsb5R3Fp 8Q+KKDKI51neX5gY9E+iBPape5HhlUrWb17BunuUFlRy3m2kj4UdQeRC4Dz/vW8l0ewY 7Uow== X-Forwarded-Encrypted: i=1; AJvYcCWgx5gf1N6EHoU2uYAT0rjB1wh4dXqzprD5v0eOwR1HZ6IIZGLj8HucaxEXPo4DmuneX4fIUH4JbBLmesyN@vger.kernel.org, AJvYcCXyUoM3+34MQSL0EvvQ3heBpeipD8Y0oU8H9EV3vO3Vspi6rsi7qzjPzfI0tUiKoacUT6BC+9Jl5nWZZQ==@vger.kernel.org X-Gm-Message-State: AOJu0Yz/Kolu9/wnWsW5o4+vxIQUCDjwEyIQpoqZpe1262p7SWlmA+yq 2lQQ5JpfPsNF9/zaW6OaCmNwz502gOwjUVLpTdVPL+LoeBb0SmTB X-Google-Smtp-Source: AGHT+IGsQIinJWLAlplnKYLC00klkkFs9EfuwGdQekBYkAMHfaf5zkwFBrxSPy7bCKwvYClbeLm8Mg== X-Received: by 2002:a17:90b:4c47:b0:2d8:8ab3:2889 with SMTP id 98e67ed59e1d1-2e184684888mr2747611a91.11.1727841990566; Tue, 01 Oct 2024 21:06:30 -0700 (PDT) Received: from linux-l9pv.suse ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f8a1429sm511331a91.32.2024.10.01.21.06.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Oct 2024 21:06:30 -0700 (PDT) From: Chun-Yi Lee X-Google-Original-From: Chun-Yi Lee To: Justin Sanders Cc: Jens Axboe , Pavel Emelianov , Kirill Korotaev , "David S . Miller" , Nicolai Stange , Greg KH , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chun-Yi Lee Subject: [RFC PATCH 1/2] aoe: add reference count in aoeif for tracking the using of net_device Date: Wed, 2 Oct 2024 12:06:15 +0800 Message-Id: <20241002040616.25193-2-jlee@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20241002040616.25193-1-jlee@suse.com> References: <20241002040616.25193-1-jlee@suse.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: This is a patch for debugging. For tracking the reference count of using net_device in aoeif, this patch adds a nd_pcpu_refcnt field in aoeif structure. Two wrappers, nd_dev_hold() and nd_dev_put() are used to call dev_hold(nd)/dev_put(nd) and maintain ifp->nd_pcpu_refcnt at the same time. Defined DEBUG to the top of the aoe.h can enable the tracking function. The nd_pcpu_refcnt will be printed to debugfs: rttavg: 249029 rttdev: 1781043 nskbpool: 0 kicked: 0 maxbcnt: 1024 ref: 0 falloc: 36 ffree: 0000000013c0033f 52540054c48e:0:16:16 ssthresh:8 taint:0 r:1270 w:8 enp1s0:1 <-- the aoeif->nd_pcpu_refcnt is behind nd->name The value of aoeif->nd_pcpu_refcnt will also be printed when 'rmmod aoe': [23412.255237][ T2857] aoe: enp1s0->refcnt: 32, aoeif->nd_refcnt: 0 Using kernel dynamic debug can print more detail log but it causes extra overhead: echo -n 'file drivers/block/aoe/* +p' > /sys/kernel/debug/dynamic_debug/control [ 6961.938642] aoe: tx dev_put enp1s0->refcnt: 31, aoeif->nd_refcnt: 1 [ 7023.368814] aoe: aoecmd_cfg_pkts dev_hold lo->refcnt: 30 [ 7023.370530] aoe: aoecmd_cfg_pkts dev_hold enp1s0->refcnt: 32, aoeif->nd_refcnt: 2 [ 7023.372977] aoe: tx dev_put lo->refcnt: 29 [ 7023.375147] aoe: tx dev_put enp1s0->refcnt: 31, aoeif->nd_refcnt: 1 Normally, after one operation of aoe, the aoeif->nd_refcnt should be shown as '1' which means that calls of dev_hold(nd)/dev_put(nd) are balanced. The final '1' reference of net_device will be removed when rmmod aoe. Signed-off-by: Chun-Yi Lee --- drivers/block/aoe/aoe.h | 84 ++++++++++++++++++++++++++++++++++++++ drivers/block/aoe/aoeblk.c | 5 +++ drivers/block/aoe/aoedev.c | 20 +++++++++ 3 files changed, 109 insertions(+) diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h index 749ae1246f4c..a6d954562794 100644 --- a/drivers/block/aoe/aoe.h +++ b/drivers/block/aoe/aoe.h @@ -1,5 +1,6 @@ /* Copyright (c) 2013 Coraid, Inc. See COPYING for GPL terms. */ #include +#include #define VERSION "85" #define AOE_MAJOR 152 @@ -133,6 +134,9 @@ struct aoeif { struct net_device *nd; ulong lost; int bcnt; +#ifdef DEBUG + int __percpu *nd_pcpu_refcnt; +#endif }; struct aoetgt { @@ -238,6 +242,7 @@ void aoedev_downdev(struct aoedev *d); int aoedev_flush(const char __user *str, size_t size); void aoe_failbuf(struct aoedev *, struct buf *); void aoedev_put(struct aoedev *); +struct aoeif *get_aoeif(struct net_device *nd); int aoenet_init(void); void aoenet_exit(void); @@ -246,3 +251,82 @@ int is_aoe_netif(struct net_device *ifp); int set_aoe_iflist(const char __user *str, size_t size); extern struct workqueue_struct *aoe_wq; + +#ifdef DEBUG +static inline int aoeif_nd_refcnt_read(const struct aoeif *ifp) +{ + int i, refcnt = 0; + + for_each_possible_cpu(i) + refcnt += *per_cpu_ptr(ifp->nd_pcpu_refcnt, i); + return refcnt; +} + +static inline void aoeif_nd_refcnt_free(struct aoeif *ifp) +{ + int i; + + if(!ifp) + return; + if (ifp->nd) + pr_info("aoe: %s->refcnt: %d, aoeif->nd_refcnt: %d\n", + ifp->nd->name, netdev_refcnt_read(ifp->nd), + aoeif_nd_refcnt_read(ifp)); + else + pr_info("aoe: aoeif->nd_refcnt: %d\n", aoeif_nd_refcnt_read(ifp)); + + for_each_possible_cpu(i) + *per_cpu_ptr(ifp->nd_pcpu_refcnt, i) = 0; + free_percpu(ifp->nd_pcpu_refcnt); + ifp->nd_pcpu_refcnt = NULL; +} + +/* ifi aoeif input, nb be set to aoeif or in the future will be set */ +static inline void __nd_dev_hold(const char *str, struct net_device *nd, struct aoeif *ifi) +{ + struct aoeif *ifp; + + if (!nd) + return; + dev_hold(nd); + ifp = ifi? ifi:get_aoeif(nd); + if (ifp) { + this_cpu_inc(*ifp->nd_pcpu_refcnt); + pr_debug("aoe: %s dev_hold %s->refcnt: %d, aoeif->nd_refcnt: %d\n", + str, nd->name, netdev_refcnt_read(nd), + aoeif_nd_refcnt_read(ifp)); + } else + pr_debug("aoe: %s dev_hold %s->refcnt: %d\n", + str, nd->name, netdev_refcnt_read(nd)); +} +#define nd_dev_hold(msg, ifi) __nd_dev_hold(__FUNCTION__, (msg), (ifi)) + +static inline void __nd_dev_put(const char *str, struct net_device *nd, struct aoeif *ifi) +{ + struct aoeif *ifp; + + if (!nd) + return; + dev_put(nd); + ifp = ifi? ifi:get_aoeif(nd); + if (ifp) { + this_cpu_dec(*ifp->nd_pcpu_refcnt); + pr_debug("aoe: %s dev_put %s->refcnt: %d, aoeif->nd_refcnt: %d\n", + str, nd->name, netdev_refcnt_read(nd), + aoeif_nd_refcnt_read(ifp)); + } else + pr_debug("aoe: %s dev_put %s->refcnt: %d\n", + str, nd->name, netdev_refcnt_read(nd)); +} +#define nd_dev_put(msg, ifi) __nd_dev_put(__FUNCTION__, (msg), (ifi)) +#else +static inline void nd_dev_put(struct net_device *nd, struct aoeif *ifi) +{ + dev_hold(nd); +} +static inline void nd_dev_hold(struct net_device *nd, struct aoeif *ifi) +{ + dev_put(nd); +} +static inline void aoeif_nd_refcnt_free(const struct aoeif *ifp) {} +#endif // DEBUG diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 2028795ec61c..19d62ccca1e9 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -142,7 +142,12 @@ static int aoe_debugfs_show(struct seq_file *s, void *ignored) ifp = (*t)->ifs; ife = ifp + ARRAY_SIZE((*t)->ifs); for (; ifp->nd && ifp < ife; ifp++) { +#ifdef DEBUG + seq_printf(s, "%c%s:%d", c, ifp->nd->name, + aoeif_nd_refcnt_read(ifp)); +#else seq_printf(s, "%c%s", c, ifp->nd->name); +#endif c = ','; } seq_puts(s, "\n"); diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index 3523dd82d7a0..9781488b286b 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c @@ -529,3 +529,23 @@ aoedev_init(void) { return 0; } + +struct aoeif * +get_aoeif(struct net_device *nd) +{ + struct aoedev *d; + struct aoetgt *t, **tt, **te; + struct aoeif *ifp; + + for (d=devlist; d; d=d->next) { + tt = d->targets; + te = tt + d->ntargets; + for (; tt < te && (t = *tt); tt++) { + for (ifp = t->ifs; ifp < &t->ifs[NAOEIFS]; ++ifp) { + if (ifp->nd && (ifp->nd == nd)) + return ifp; + } + } + } + return NULL; +} From patchwork Wed Oct 2 04:06:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 13819326 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9DF338397; Wed, 2 Oct 2024 04:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727841997; cv=none; b=GonEX27lhHt0Bgcoug8UTMqih1Ow142gkL31BkgFwuXBTpT/t7fo0QAz/nRwX2GrfctFKuNkGGVjrnGmzebH/xBURAl3CE4QDKK3PP8TfuvI+9Z3Y7LYYXaFSzc6WxoPjb4fP6p5NlQLrmuDfCMnCoDQ/Q+R4SIQJ6pmO8qRjmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727841997; c=relaxed/simple; bh=lWuFZNp8SGcuyk7Gf4k+aq+Idi1/bmDlYGOXJ0H77wA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=cQ7zCjgV5U5jU3MoMQvuRMRHxfYGYo9LnFM8a+qxO8TfwUrjyJ/BRR3sHa7Ou/dVAbL5qAj0IjJb5FMm5Kg/YBHatKwiF+k9Of+SPJrVF31pcp05+78uIHNqq6KMedUeN7YWIvRb8NNhrz+WTjGMfMzfs2/9zMrimHf4UaDNJFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IVwMGjbi; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IVwMGjbi" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7d4fa972cbeso4702931a12.2; Tue, 01 Oct 2024 21:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727841995; x=1728446795; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=zYaHB61WqWgkxXuSD6BdpH4wlWMX7ZgatPU8DqKwYTU=; b=IVwMGjbicr6QuJqTGmx+sq7Z9Pw9wYBhWPMf5Bn3YYz+cuCf6RsBhxNcA8lGuDd2h5 xlvCwibRTO1uP/QWOQyItNHzhL4Enu7ZOS+eEW/DnwMfMgGO/4dot/RISz8GJSRNG/7W rIQHZa6yyF9TJaKiVxQOplCUWAfbJpZtRsOk4Tq/MGBfh3HiFfTZj4dwhg8UALAn4PP0 p382RPvxmuHjWjdWSRbD3g7gCkyiJ3erZhSU3tbwirGHCsmBNrbBv1oBw2yXx0LSC9rC 7UPZJ52XIykkc8FI8JTQgPVA7bQTtcg+DgBO8cqI5d1uj691SiNLLO+i6s5FV2i8y1pV 671A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727841995; x=1728446795; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zYaHB61WqWgkxXuSD6BdpH4wlWMX7ZgatPU8DqKwYTU=; b=QsTNp7MoGCwlCkK7ZZC6/5aeUtx/pFDyC6OQYnfVuGV6DqvoXHpOT6z4qTQCfzRcDU /qTOH8ImIi/rHZ7s7ZUkbNZdgYSgyqwEF0T8cuXsDGQ00EeiqMZ0vYurOX5pfB7ASrtw /NBohAk2p5aBM0FwKwgC/7tRxwsO784rVNTZcmVXfc1B6VD9FbJnatP3FDE5CDK1RFq0 Esfw8/yH0+18x3IxyYzQ52nHrLWyFSrrmFx8sddPGhery8XjJ/OWkEHLJvSPSXPNmV1F b5kHMT3AKYqBYzMD670X0tL1mqHSPDDQiLTpunuexMO+GE5H0tniAFKfQATWqebRJOdO ulnw== X-Forwarded-Encrypted: i=1; AJvYcCXlXfy905i1fTucjSvz2fbfMfkoe6DPmYas+a8zrqUi4Q2OJ6tSs99wrGRx/YtgeUMeXG0qv56vaGaiE481@vger.kernel.org, AJvYcCXqunEtXXLxBTZ3oeyE2ggF/fJuHVl420OYux9DIkTLcvIxodZwvZDZ8Ne+pI3aGupVaUZTBVzOVqT7Gw==@vger.kernel.org X-Gm-Message-State: AOJu0YyInhHcF1ZcfD9LfgZdGkgDsM+ZWvTiMHKXdh/qZXID3IzlU//0 ZZKCnnD4nJs+h/Zy+M5hAMiFA8HsxsmK1JQxTI2nBShuBbUqu77G X-Google-Smtp-Source: AGHT+IE/+Jk4TQMRVhQ6ytQzbXd0DS3r9HoGUWNL1fkubxZ8o5AN6Q3LrG2zofg4RpD5c2YH/ULQtA== X-Received: by 2002:a17:90b:4a4f:b0:2d8:898c:3e9b with SMTP id 98e67ed59e1d1-2e1848e2c70mr2483022a91.25.1727841995129; Tue, 01 Oct 2024 21:06:35 -0700 (PDT) Received: from linux-l9pv.suse ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f8a1429sm511331a91.32.2024.10.01.21.06.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Oct 2024 21:06:34 -0700 (PDT) From: Chun-Yi Lee X-Google-Original-From: Chun-Yi Lee To: Justin Sanders Cc: Jens Axboe , Pavel Emelianov , Kirill Korotaev , "David S . Miller" , Nicolai Stange , Greg KH , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chun-Yi Lee 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 Message-Id: <20241002040616.25193-3-jlee@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20241002040616.25193-1-jlee@suse.com> References: <20241002040616.25193-1-jlee@suse.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Signed-off-by: Chun-Yi Lee --- 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;