From patchwork Mon Jun 30 15:48:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4451341 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 03E8BBEEAA for ; Mon, 30 Jun 2014 15:51:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 220702021F for ; Mon, 30 Jun 2014 15:51:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FC1420379 for ; Mon, 30 Jun 2014 15:51:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754626AbaF3PvM (ORCPT ); Mon, 30 Jun 2014 11:51:12 -0400 Received: from mail-qc0-f175.google.com ([209.85.216.175]:51239 "EHLO mail-qc0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754624AbaF3PvL (ORCPT ); Mon, 30 Jun 2014 11:51:11 -0400 Received: by mail-qc0-f175.google.com with SMTP id i8so7247095qcq.34 for ; Mon, 30 Jun 2014 08:51:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ml8JRr9e556AXS8m7TelR+LjFce3uwl/4y2Cz0WhRxo=; b=kesERv20XmZjS0ireuYGe0vWoamI6LTWjLzeHrf5vgTG3/vuOB9EPpeikJ1+TPjs29 UsAmwQmwTSRblnD2b6q2/svb+gqV6KzC1QpEAg5tBkKuVEM3BhH7McbQ52vVem7udrIA qru58NJCSGmPjsP0ATt7y8ygAgxmcBOjRj+kOWDCGWFss8iMSP1bmawZQeGxVnwqYa2/ 3vOf0lyjagIDAqDMLJNENUWXtDir2zkSjeFbQ34Qjuo2YUr4JqeHzEdufS03UeocG5ec HehLCAwtUQgMGhLeUHis0bReo9wClMtXs2sAWM5tsM/W3Fvlo2pxEMWUec2qTYHmH4rU Z96Q== X-Gm-Message-State: ALoCoQmPXxv+pFOipYNCxZPnXO34/BtMDMjtpSQCz7iv/uWNKPDs4C9BUHozujb2QXuFJ/pOOBnQ X-Received: by 10.140.49.194 with SMTP id q60mr49911170qga.7.1404143471042; Mon, 30 Jun 2014 08:51:11 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id m1sm32584105qaz.27.2014.06.30.08.51.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jun 2014 08:51:10 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 027/114] nfsd: shrink st_access_bmap and st_deny_bmap Date: Mon, 30 Jun 2014 11:48:56 -0400 Message-Id: <1404143423-24381-28-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1404143423-24381-1-git-send-email-jlayton@primarydata.com> References: <1404143423-24381-1-git-send-email-jlayton@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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 never use anything above bit #3, so an unsigned long for each is wasteful. Shrink them to a char each, and add some WARN_ON_ONCE calls if we try to set or clear bits that would go outside those sizes. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 26 +++++++++++++++----------- fs/nfsd/state.h | 4 ++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 485a0dc039d5..9dba8b7baf3b 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -722,42 +722,46 @@ test_share(struct nfs4_ol_stateid *stp, struct nfsd4_open *open) { static inline void set_access(u32 access, struct nfs4_ol_stateid *stp) { - __set_bit(access, &stp->st_access_bmap); + WARN_ON_ONCE(access > NFS4_SHARE_ACCESS_BOTH); + __set_bit(access, (unsigned long *)&stp->st_access_bmap); } /* clear share access for a given stateid */ static inline void clear_access(u32 access, struct nfs4_ol_stateid *stp) { - __clear_bit(access, &stp->st_access_bmap); + WARN_ON_ONCE(access > NFS4_SHARE_ACCESS_BOTH); + __clear_bit(access, (unsigned long *)&stp->st_access_bmap); } /* test whether a given stateid has access */ static inline bool test_access(u32 access, struct nfs4_ol_stateid *stp) { - return test_bit(access, &stp->st_access_bmap); + return test_bit(access, (unsigned long *)&stp->st_access_bmap); } /* set share deny for a given stateid */ static inline void -set_deny(u32 access, struct nfs4_ol_stateid *stp) +set_deny(u32 deny, struct nfs4_ol_stateid *stp) { - __set_bit(access, &stp->st_deny_bmap); + WARN_ON_ONCE(deny > NFS4_SHARE_DENY_BOTH); + __set_bit(deny, (unsigned long *)&stp->st_deny_bmap); } /* clear share deny for a given stateid */ static inline void -clear_deny(u32 access, struct nfs4_ol_stateid *stp) +clear_deny(u32 deny, struct nfs4_ol_stateid *stp) { - __clear_bit(access, &stp->st_deny_bmap); + WARN_ON_ONCE(deny > NFS4_SHARE_DENY_BOTH); + __clear_bit(deny, (unsigned long *)&stp->st_deny_bmap); } /* test whether a given stateid is denying specific access */ static inline bool -test_deny(u32 access, struct nfs4_ol_stateid *stp) +test_deny(u32 deny, struct nfs4_ol_stateid *stp) { - return test_bit(access, &stp->st_deny_bmap); + return test_bit(deny, (unsigned long *)&stp->st_deny_bmap); } /* release all access and file references for a given stateid */ @@ -4270,12 +4274,12 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, goto out; status = nfserr_inval; if (!test_access(od->od_share_access, stp)) { - dprintk("NFSD: access not a subset current bitmap: 0x%lx, input access=%08x\n", + dprintk("NFSD: access not a subset of current bitmap: 0x%hhx, input access=%08x\n", stp->st_access_bmap, od->od_share_access); goto out; } if (!test_deny(od->od_share_deny, stp)) { - dprintk("NFSD:deny not a subset current bitmap: 0x%lx, input deny=%08x\n", + dprintk("NFSD: deny not a subset of current bitmap: 0x%hhx, input deny=%08x\n", stp->st_deny_bmap, od->od_share_deny); goto out; } diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index dc56ec234df7..949b331d9e13 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -407,8 +407,8 @@ struct nfs4_ol_stateid { struct list_head st_locks; struct nfs4_stateowner * st_stateowner; struct nfs4_file * st_file; - unsigned long st_access_bmap; - unsigned long st_deny_bmap; + unsigned char st_access_bmap; + unsigned char st_deny_bmap; struct nfs4_ol_stateid * st_openstp; };