From patchwork Wed Aug 5 21:13:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 6953021 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A6BA09F402 for ; Wed, 5 Aug 2015 21:13:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CBBD4204AB for ; Wed, 5 Aug 2015 21:13:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7E7820443 for ; Wed, 5 Aug 2015 21:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752454AbbHEVNp (ORCPT ); Wed, 5 Aug 2015 17:13:45 -0400 Received: from mail-yk0-f177.google.com ([209.85.160.177]:33809 "EHLO mail-yk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbbHEVNo (ORCPT ); Wed, 5 Aug 2015 17:13:44 -0400 Received: by ykax123 with SMTP id x123so46809818yka.1 for ; Wed, 05 Aug 2015 14:13:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kT/5PUFN8unCqw26TanJSDWTkA8CYQat7ovcuNLJXSc=; b=h9Uch2yYySa3zFoK7QKRDibiGEaX6jxYJb9j/Xeza0HBPvbybvrYRaieNxYQW3f1hD MCGYJp0ekGTzivjB9yK1kJhpu3IWPGPjoxS6/8LRitxtklUY5WtavO5+QkvQPL8dlKjM qK+MZNbApSyQZsodx5S33Bh5vRVdB9rr2+76zu+L29hJ4pGB4fapddKz8DHhRJOujt4P nn9jkFAjS+3Yy43lOVJUZHlhh14u6lYwu/WqsRFfQipknBMzlI2EiwS22e9bZudwW1KW vPEWj/JHXHNarzQCS+nt1ccNMFFPc4ZnrX9OmMA027Ynp/Da+P2h2MBRTPIL4tGeX7Hl rLWg== X-Gm-Message-State: ALoCoQnLlsabbK+2IPDvtoP3MLAGcLpiY1TIl7gdEkOW4gNArzgv4FDU2q78uFPqZtOiPY/mZGJq X-Received: by 10.170.54.22 with SMTP id 22mr4484021ykw.111.1438809224264; Wed, 05 Aug 2015 14:13:44 -0700 (PDT) Received: from tlielax.poochiereds.net (cpe-45-37-211-243.nc.res.rr.com. [45.37.211.243]) by smtp.googlemail.com with ESMTPSA id p81sm3975306ywe.19.2015.08.05.14.13.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2015 14:13:43 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 02/18] nfsd: move some file caching helpers to a common header Date: Wed, 5 Aug 2015 17:13:20 -0400 Message-Id: <1438809216-4846-3-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1438809216-4846-1-git-send-email-jeff.layton@primarydata.com> References: <1438264341-18048-1-git-send-email-jeff.layton@primarydata.com> <1438809216-4846-1-git-send-email-jeff.layton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We'll want to reuse some of this for common open file caching infrastructure. Signed-off-by: Jeff Layton Reviewed-by: Christoph Hellwig --- fs/nfsd/filecache.h | 25 +++++++++++++++++++++++++ fs/nfsd/nfs4state.c | 17 ++--------------- 2 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 fs/nfsd/filecache.h diff --git a/fs/nfsd/filecache.h b/fs/nfsd/filecache.h new file mode 100644 index 000000000000..9051ee54faa3 --- /dev/null +++ b/fs/nfsd/filecache.h @@ -0,0 +1,25 @@ +#ifndef _FS_NFSD_FILECACHE_H +#define _FS_NFSD_FILECACHE_H + +#include +#include + +#include "export.h" + +/* hash table for nfs4_file */ +#define NFSD_FILE_HASH_BITS 8 +#define NFSD_FILE_HASH_SIZE (1 << NFSD_FILE_HASH_BITS) + +static inline unsigned int +nfsd_fh_hashval(struct knfsd_fh *fh) +{ + return jhash2(fh->fh_base.fh_pad, XDR_QUADLEN(fh->fh_size), 0); +} + +static inline unsigned int +file_hashval(struct knfsd_fh *fh) +{ + return nfsd_fh_hashval(fh) & (NFSD_FILE_HASH_SIZE - 1); +} + +#endif /* _FS_NFSD_FILECACHE_H */ diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 43903abd6189..b3b306bd1830 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -49,6 +49,7 @@ #include "netns.h" #include "pnfs.h" +#include "filecache.h" #define NFSDDBG_FACILITY NFSDDBG_PROC @@ -381,21 +382,7 @@ static unsigned int ownerstr_hashval(struct xdr_netobj *ownername) return ret & OWNER_HASH_MASK; } -/* hash table for nfs4_file */ -#define FILE_HASH_BITS 8 -#define FILE_HASH_SIZE (1 << FILE_HASH_BITS) - -static unsigned int nfsd_fh_hashval(struct knfsd_fh *fh) -{ - return jhash2(fh->fh_base.fh_pad, XDR_QUADLEN(fh->fh_size), 0); -} - -static unsigned int file_hashval(struct knfsd_fh *fh) -{ - return nfsd_fh_hashval(fh) & (FILE_HASH_SIZE - 1); -} - -static struct hlist_head file_hashtbl[FILE_HASH_SIZE]; +static struct hlist_head file_hashtbl[NFSD_FILE_HASH_SIZE]; static void __nfs4_file_get_access(struct nfs4_file *fp, u32 access)