From patchwork Mon Oct 1 14:41:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10622269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13E541515 for ; Mon, 1 Oct 2018 14:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE54428DDB for ; Mon, 1 Oct 2018 14:42:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E31612921C; Mon, 1 Oct 2018 14:42:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95BA6290FE for ; Mon, 1 Oct 2018 14:42:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729496AbeJAVUf (ORCPT ); Mon, 1 Oct 2018 17:20:35 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:38751 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729489AbeJAVUf (ORCPT ); Mon, 1 Oct 2018 17:20:35 -0400 Received: by mail-it1-f193.google.com with SMTP id i76-v6so6171241ita.3 for ; Mon, 01 Oct 2018 07:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0G2bnJBT9neJeBsYsT5N3sx16XxrZfyMnJJSzdPqCu4=; b=P5RD0HsgqqAZ3k2gklLGGyXIo4C3jwADGAYngZKMuCrnER3bHmDgISydm9HJqWZKzk YKTomxOERnjl7JXssa/gUuGXinV974Yv//sFa3TTs5+7Br3oDdaPG72WCfW+Oo6cOLH0 sm4o4yI16vuWxOKS621+bh1hWSaOVVb1ABNIL/+0YAVOFMaWyq4l7kTF/Wcu+xJlK/Xc Sgbg66Xj6lO4qJtOGui9QQGlXsAm3/2hlyF3bo+Nxl7MCzxWe1lE3VXqMHxGoexEyuli UcBqspr2iuoxS4cr8c1QbCfEdPhi9sOObvCwEjvAcATqgpDvhioF+FXtH8Y5B29hQFkX RpMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0G2bnJBT9neJeBsYsT5N3sx16XxrZfyMnJJSzdPqCu4=; b=KhgQTrODVSzx1KMsjsYV5y8GMDm47ysLWXuIc2FbeeInH4KaOARq9X+dtz74UNbwyk PSH3VsL5aEz+W/K1eiv5BMacKUzz8ViYyjPaeOKhBKFV9aEoA7LHwXLAwjjgYrAX8aHf bxoSkFAvBb+6fzUHSaPBaPlf6tMqihRlNEXTAfXfFrSHXbrP3lBtM7O1RdBYkCO6htyj sLMbmuw0c5oBFMA34IBARSU7jTQX33EEDKAKuZTJeSYN4fHMNbWk8GzrkAgQovcSQj5p Sa2Z4V+OS3xNKil8RMHHx3HdgiRpRYa2xjxikLOtXlgnLUjtTaI53iQANmb2ZYcr0y++ qtGw== X-Gm-Message-State: ABuFfohw6czBgGZVJc9v+3REJfydz9euhVu232xun3yYTMUDtcG7gYkb e6AdoP1sCEPLjQv+vod15w== X-Google-Smtp-Source: ACcGV63/ZG5i2ZCoXZAlR8IH+2eWDaTfhpXsgya83zxyCOeurqLtOZNEQZriedrKJni+JnEqvIXpPw== X-Received: by 2002:a24:d703:: with SMTP id y3-v6mr931763itg.154.1538404946508; Mon, 01 Oct 2018 07:42:26 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-40-195-73.hsd1.mi.comcast.net. [68.40.195.73]) by smtp.gmail.com with ESMTPSA id j75-v6sm2055597itj.33.2018.10.01.07.42.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 07:42:25 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: "J . Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH 08/15] NFS: Lockless DNS lookups Date: Mon, 1 Oct 2018 10:41:50 -0400 Message-Id: <20181001144157.3515-9-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181001144157.3515-8-trond.myklebust@hammerspace.com> References: <20181001144157.3515-1-trond.myklebust@hammerspace.com> <20181001144157.3515-2-trond.myklebust@hammerspace.com> <20181001144157.3515-3-trond.myklebust@hammerspace.com> <20181001144157.3515-4-trond.myklebust@hammerspace.com> <20181001144157.3515-5-trond.myklebust@hammerspace.com> <20181001144157.3515-6-trond.myklebust@hammerspace.com> <20181001144157.3515-7-trond.myklebust@hammerspace.com> <20181001144157.3515-8-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enable RCU protected lookup in the legacy DNS resolver. Signed-off-by: Trond Myklebust --- fs/nfs/dns_resolve.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c index 060c658eab66..e93a5dc07c8c 100644 --- a/fs/nfs/dns_resolve.c +++ b/fs/nfs/dns_resolve.c @@ -65,6 +65,7 @@ struct nfs_dns_ent { struct sockaddr_storage addr; size_t addrlen; + struct rcu_head rcu_head; }; @@ -101,15 +102,23 @@ static void nfs_dns_ent_init(struct cache_head *cnew, } } -static void nfs_dns_ent_put(struct kref *ref) +static void nfs_dns_ent_free_rcu(struct rcu_head *head) { struct nfs_dns_ent *item; - item = container_of(ref, struct nfs_dns_ent, h.ref); + item = container_of(head, struct nfs_dns_ent, rcu_head); kfree(item->hostname); kfree(item); } +static void nfs_dns_ent_put(struct kref *ref) +{ + struct nfs_dns_ent *item; + + item = container_of(ref, struct nfs_dns_ent, h.ref); + call_rcu(item, nfs_dns_ent_free_rcu); +} + static struct cache_head *nfs_dns_ent_alloc(void) { struct nfs_dns_ent *item = kmalloc(sizeof(*item), GFP_KERNEL); @@ -195,7 +204,7 @@ static struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd, { struct cache_head *ch; - ch = sunrpc_cache_lookup(cd, + ch = sunrpc_cache_lookup_rcu(cd, &key->h, nfs_dns_hash(key)); if (!ch)