Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4847736pxu; Wed, 21 Oct 2020 06:54:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpCLFefThZtXI2Wp/YwHcOSe1Kn8LKLaY6RB/1OkEjRPHt0DiEaugziMukrP9VkQvSDXQ3 X-Received: by 2002:a50:cbc9:: with SMTP id l9mr3077468edi.310.1603288447908; Wed, 21 Oct 2020 06:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603288447; cv=none; d=google.com; s=arc-20160816; b=fMLrLiEKTZhjElp2tc1+XyPAh2IMLzGNJmRxdhM657HdHdTP0UUSC1cCd7Wb7/3ISS 9usxys0qecuHz+GY5TW1OZQEhdJaw4jQmh6yLqfCOUdHkcMy1N8jehSveQEct7+eMLW1 pWWP26sICDhGeIQe3Wr+t4c/9HDcCO460NPTyewU8DtI6Z4u6yflGX4nNgbE+Kih76TF eB7Rl3/5j15oCdegU++6CYYDjvxqVQ+JNbOEmj4qtl7nFfs+D6sFdA15pLEaTPY4ZwQ+ /m1GclnOrQoiD8eMRYZe1q2W7dnU7Bi9C5SJnf7GD4QUwD+pyruQ8xsCMXd9VONkErrP lcrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vJHUiIV/mXgyDV0BplJrCZ+f4uBKxL2uz453PEXSerk=; b=MjfS9hXwS0Q4sWn4+hL+PhPJmiO2GwtYcrmQs/FZX2zniY085T6BLh2b3g0NblNBsE dSDmGy5qTdOuijQRPLwlsPm+1oc6Bq46kK0iGNlXA7F/Zv4xVC0ZP0ioorQz1myGMVjR pUvHZQfVxnOxDRGERrsp7wxDWMe5tvjYbmAlBIYeC64CtQsAbSSUxUGykmq2CINMuLuW YK9L2bV/oWzs4XH2gnUDLfXCpNAu7cnKC/MB7pd/HoAJBwqv3gkRSrh5ciUYs5RDatkf +biRd57K8LnGcXy9SfOnqSgV+tWWgewExWhi4qM7jh0Aweb+RfdEox21lkRyoVGp3jpF zb6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b=P5zrFhEb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si1405935ejg.50.2020.10.21.06.53.45; Wed, 21 Oct 2020 06:54:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b=P5zrFhEb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2411168AbgJUMFp (ORCPT + 99 others); Wed, 21 Oct 2020 08:05:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439910AbgJUMFo (ORCPT ); Wed, 21 Oct 2020 08:05:44 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EC03C0613CE for ; Wed, 21 Oct 2020 05:05:43 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id kk5so1045597pjb.1 for ; Wed, 21 Oct 2020 05:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vJHUiIV/mXgyDV0BplJrCZ+f4uBKxL2uz453PEXSerk=; b=P5zrFhEbkRW8IMbTRa8/5yw4n/AYJtpsEebsoYbAF4LdoGYLXxm1bUWxoAHdfvm3o1 Jx6pTPuhnirmBFkEi+usNt2pMpb+6y3ROBP7la/rEpRRhSwEJqykDtMf9O3wIs7SBbD/ NkSoPzDB6eWKj/QbRCz+9kHBoMeFOFzh16oNw= 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=vJHUiIV/mXgyDV0BplJrCZ+f4uBKxL2uz453PEXSerk=; b=fI2nEFA8nbqv0jwfsTkZYqdGSaxrIng0O4vxvw7G/8SGuJU11ReEOXJ3Lqg2SZHmW2 KrTeKORQjIlYE/MCF4hiSiXhv4wcnfkai2icW0KqqYQiXZc6rAEi5/ppbXQR40jxeigh 095Ek7K/yNf6Iid3duyC0257aOnISSjOdUSTne7LNy9E5MFUZe1yIy697lB+334UYeJC /IjGx6CYb7tvuGhn5FOSOwjZxHlESfb/mwK+zGlYBq6wGU6FLzwaHkIslANo+I2XXg7c AOJ7se0coL+cPu8s7yPpu/iOgw3r+6QxcRvLg+NLFfVdNJaYqHgtHHKEI+527MzymqrR yVWQ== X-Gm-Message-State: AOAM531CgGW8rUFaAp9Y+0YxZzkaWaiKctl/Xe8kXO6wB22AzexgfKvU y92WFWcQPgXXTHheFXr8XQRAgg== X-Received: by 2002:a17:902:8e89:b029:d5:fefd:9637 with SMTP id bg9-20020a1709028e89b02900d5fefd9637mr3217602plb.39.1603281942696; Wed, 21 Oct 2020 05:05:42 -0700 (PDT) Received: from ubuntu.netflix.com (203.20.25.136.in-addr.arpa. [136.25.20.203]) by smtp.gmail.com with ESMTPSA id b5sm2276392pfo.64.2020.10.21.05.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 05:05:42 -0700 (PDT) From: Sargun Dhillon To: "J . Bruce Fields" , Chuck Lever , Trond Myklebust , Anna Schumaker , David Howells , Scott Mayhew Cc: Sargun Dhillon , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, kylea@netflix.com Subject: [PATCH v3 2/3] NFSv4: Refactor: reference user namespace from nfs4idmap Date: Wed, 21 Oct 2020 05:05:28 -0700 Message-Id: <20201021120529.7062-3-sargun@sargun.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201021120529.7062-1-sargun@sargun.me> References: <20201021120529.7062-1-sargun@sargun.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The nfs4idmapper only needs access to the user namespace, and not the entire cred struct. This replaces the struct cred* member with struct user_namespace*. This is so we don't have to hold onto the cred object, which has extraneous references to things like user_struct. This also makes switching away from init_user_ns more straightforward in the future. Signed-off-by: Sargun Dhillon --- fs/nfs/nfs4idmap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c index 62e6eea5c516..8d8aba305ecc 100644 --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "internal.h" #include "netns.h" @@ -69,13 +70,13 @@ struct idmap { struct rpc_pipe *idmap_pipe; struct idmap_legacy_upcalldata *idmap_upcall_data; struct mutex idmap_mutex; - const struct cred *cred; + struct user_namespace *user_ns; }; static struct user_namespace *idmap_userns(const struct idmap *idmap) { - if (idmap && idmap->cred) - return idmap->cred->user_ns; + if (idmap && idmap->user_ns) + return idmap->user_ns; return &init_user_ns; } @@ -286,7 +287,7 @@ static struct key *nfs_idmap_request_key(const char *name, size_t namelen, if (ret < 0) return ERR_PTR(ret); - if (!idmap->cred || idmap->cred->user_ns == &init_user_ns) + if (!idmap->user_ns || idmap->user_ns == &init_user_ns) rkey = request_key(&key_type_id_resolver, desc, ""); if (IS_ERR(rkey)) { mutex_lock(&idmap->idmap_mutex); @@ -462,7 +463,7 @@ nfs_idmap_new(struct nfs_client *clp) return -ENOMEM; mutex_init(&idmap->idmap_mutex); - idmap->cred = get_cred(clp->cl_rpcclient->cl_cred); + idmap->user_ns = get_user_ns(clp->cl_rpcclient->cl_cred->user_ns); rpc_init_pipe_dir_object(&idmap->idmap_pdo, &nfs_idmap_pipe_dir_object_ops, @@ -486,7 +487,7 @@ nfs_idmap_new(struct nfs_client *clp) err_destroy_pipe: rpc_destroy_pipe_data(idmap->idmap_pipe); err: - put_cred(idmap->cred); + get_user_ns(idmap->user_ns); kfree(idmap); return error; } @@ -503,7 +504,7 @@ nfs_idmap_delete(struct nfs_client *clp) &clp->cl_rpcclient->cl_pipedir_objects, &idmap->idmap_pdo); rpc_destroy_pipe_data(idmap->idmap_pipe); - put_cred(idmap->cred); + put_user_ns(idmap->user_ns); kfree(idmap); } -- 2.25.1