From patchwork Thu Apr 25 14:04:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Fields X-Patchwork-Id: 10917185 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 0F8A71395 for ; Thu, 25 Apr 2019 14:04:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00C0628793 for ; Thu, 25 Apr 2019 14:04:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E931628B6D; Thu, 25 Apr 2019 14:04:26 +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=-7.9 required=2.0 tests=BAYES_00,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 8E2DA28793 for ; Thu, 25 Apr 2019 14:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728621AbfDYOEZ (ORCPT ); Thu, 25 Apr 2019 10:04:25 -0400 Received: from fieldses.org ([173.255.197.46]:50908 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727780AbfDYOEY (ORCPT ); Thu, 25 Apr 2019 10:04:24 -0400 Received: by fieldses.org (Postfix, from userid 2815) id D43967CC; Thu, 25 Apr 2019 10:04:22 -0400 (EDT) From: "J. Bruce Fields" To: linux-nfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, abe@purdue.edu, lsof-l@lists.purdue.edu, util-linux@vger.kernel.org, jlayton@redhat.com, "J. Bruce Fields" Subject: [PATCH 05/10] nfsd: make client/ directory names small ints Date: Thu, 25 Apr 2019 10:04:15 -0400 Message-Id: <1556201060-7947-6-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1556201060-7947-1-git-send-email-bfields@redhat.com> References: <1556201060-7947-1-git-send-email-bfields@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "J. Bruce Fields" We want clientid's on the wire to be randomized for reasons explained in ebd7c72c63ac "nfsd: randomize SETCLIENTID reply to help distinguish servers". But I'd rather have mostly small integers for the clients/ directory. Signed-off-by: J. Bruce Fields --- fs/nfsd/netns.h | 1 + fs/nfsd/nfs4state.c | 2 +- fs/nfsd/nfsctl.c | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 46d956676480..888b2891960e 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -121,6 +121,7 @@ struct nfsd_net { */ unsigned int max_connections; + u32 clientid_base; u32 clientid_counter; u32 clverifier_counter; diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index dfcb90743861..de99bfe3e6e2 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2221,7 +2221,7 @@ static struct nfs4_client *create_client(struct xdr_netobj name, clp->cl_cb_session = NULL; clp->net = net; clp->cl_nfsd_dentry = nfsd_client_mkdir(nn, &clp->cl_nfsdfs, - clp->cl_clientid.cl_id); + clp->cl_clientid.cl_id - nn->clientid_base); if (!clp->cl_nfsd_dentry) { free_client(clp); return NULL; diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 8a2261cdefee..edf4dada42bf 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1212,7 +1212,7 @@ struct dentry *nfsd_client_mkdir(struct nfsd_net *nn, struct nfsdfs_client *ncl, { char name[11]; - sprintf(name, "%d", id++); + sprintf(name, "%u", id); return nfsd_mkdir(nn->nfsd_client_dir, ncl, name); } @@ -1350,7 +1350,8 @@ static __net_init int nfsd_init_net(struct net *net) nn->nfsd4_grace = 90; nn->somebody_reclaimed = false; nn->clverifier_counter = prandom_u32(); - nn->clientid_counter = prandom_u32(); + nn->clientid_base = prandom_u32(); + nn->clientid_counter = nn->clientid_base + 1; nn->s2s_cp_cl_id = nn->clientid_counter++; atomic_set(&nn->ntf_refcnt, 0);