From patchwork Wed Jun 22 14:35:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 9193103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40D6A60756 for ; Wed, 22 Jun 2016 14:36:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31C1128400 for ; Wed, 22 Jun 2016 14:36:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 264192840B; Wed, 22 Jun 2016 14:36:46 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 C997A28400 for ; Wed, 22 Jun 2016 14:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752800AbcFVOf1 (ORCPT ); Wed, 22 Jun 2016 10:35:27 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:37176 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752798AbcFVOfY (ORCPT ); Wed, 22 Jun 2016 10:35:24 -0400 Received: by mail-wm0-f45.google.com with SMTP id a66so9039997wme.0 for ; Wed, 22 Jun 2016 07:35:24 -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=RdaRHF+TiAYa9lL+rOgQJaNi329nLNnijszoD8tkV5g=; b=h8v/peaAlhkMyEG0J6m0Rx9dCv7e71MRclhwzTs/wCJHtpk7OoPieMmcT03VwnBkRL dSx7FMbb2NCD9auyGiUAESs1kALO0cu83QhPXIP1eBNEMFxdG1BS0GNpPxRtXrkRJija UUQVCzptT5NDtJqKo4aFAhDtvcQLMYLLj24idvfldw0E7eN/15qm6Z+pb/hLFKk3nnZu oPx9nFgVW8KCaoGwWzUNrIdBfDkLxWjesBoIVxzGN9uukmkG8lkMJaZPx0Npi7DM/4An u1uTAZQ14E+Z+jWBA3f7bN0aILD9x1DaJ+cLXrmlJVslh1EVAz22zXiJQRXopuo0gE5i 0I/A== X-Gm-Message-State: ALyK8tLf0iRJxFUgg7xmK4tF1kcysdOFkYUS7R7jwIe1yCbY/oXS+ZFLlPNdmlqRi2Lcu6yg X-Received: by 10.194.88.106 with SMTP id bf10mr20280218wjb.37.1466606122945; Wed, 22 Jun 2016 07:35:22 -0700 (PDT) Received: from veci.piliscsaba.szeredi.hu (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id u71sm930666wmu.13.2016.06.22.07.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 07:35:22 -0700 (PDT) From: Miklos Szeredi To: Al Viro Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 7/8] ncpfs: don't use ->d_time Date: Wed, 22 Jun 2016 16:35:09 +0200 Message-Id: <1466606110-24297-8-git-send-email-mszeredi@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466606110-24297-1-git-send-email-mszeredi@redhat.com> References: <1466606110-24297-1-git-send-email-mszeredi@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 Ncpfs stores a boolean value in ->d_fsdata as well as using d_time. Introcude ncp_dentry to store both of these and make d_fsdata point to it. Signed-off-by: Miklos Szeredi --- fs/ncpfs/dir.c | 21 ++++++++++++++++++--- fs/ncpfs/ncplib_kernel.h | 16 +++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index bfdad003ee56..805d76dba426 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -72,6 +72,8 @@ const struct inode_operations ncp_dir_inode_operations = /* * Dentry operations routines */ +static int ncp_d_allocate(struct dentry *); +static void ncp_d_release(struct dentry *); static int ncp_lookup_validate(struct dentry *, unsigned int); static int ncp_hash_dentry(const struct dentry *, struct qstr *); static int ncp_compare_dentry(const struct dentry *, const struct dentry *, @@ -81,6 +83,8 @@ static void ncp_d_prune(struct dentry *dentry); const struct dentry_operations ncp_dentry_operations = { + .d_allocate = ncp_d_allocate, + .d_release = ncp_d_release, .d_revalidate = ncp_lookup_validate, .d_hash = ncp_hash_dentry, .d_compare = ncp_compare_dentry, @@ -306,6 +310,17 @@ leave_me:; } #endif /* CONFIG_NCPFS_STRONG */ +static int ncp_d_allocate(struct dentry *dentry) +{ + dentry->d_fsdata = kzalloc(sizeof(struct ncp_dentry), GFP_KERNEL); + + return dentry->d_fsdata ? 0 : -ENOMEM; +} + +static void ncp_d_release(struct dentry *dentry) +{ + kfree(dentry->d_fsdata); +} static int ncp_lookup_validate(struct dentry *dentry, unsigned int flags) @@ -409,7 +424,7 @@ ncp_invalidate_dircache_entries(struct dentry *parent) spin_lock(&parent->d_lock); list_for_each_entry(dentry, &parent->d_subdirs, d_child) { - dentry->d_fsdata = NULL; + NCP_DENTRY(dentry)->cached = false; ncp_age_dentry(server, dentry); } spin_unlock(&parent->d_lock); @@ -569,7 +584,7 @@ out: static void ncp_d_prune(struct dentry *dentry) { - if (!dentry->d_fsdata) /* not referenced from page cache */ + if (!NCP_DENTRY(dentry)->cached) /* not referenced from page cache */ return; NCP_FINFO(d_inode(dentry->d_parent))->flags &= ~NCPI_DIR_CACHE; } @@ -660,7 +675,7 @@ ncp_fill_cache(struct file *file, struct dir_context *ctx, } if (ctl.cache) { if (d_really_is_positive(newdent)) { - newdent->d_fsdata = newdent; + NCP_DENTRY(newdent)->cached = true; ctl.cache->dentry[ctl.idx] = newdent; ino = d_inode(newdent)->i_ino; ncp_new_dentry(newdent); diff --git a/fs/ncpfs/ncplib_kernel.h b/fs/ncpfs/ncplib_kernel.h index 17cfb743b5bf..76459e4f6b64 100644 --- a/fs/ncpfs/ncplib_kernel.h +++ b/fs/ncpfs/ncplib_kernel.h @@ -168,20 +168,30 @@ static inline int ncp_strnicmp(const struct nls_table *t, #endif /* CONFIG_NCPFS_NLS */ -#define NCP_GET_AGE(dentry) (jiffies - (dentry)->d_time) +struct ncp_dentry { + unsigned long time; + bool cached; +}; + +static inline struct ncp_dentry *NCP_DENTRY(struct dentry *dentry) +{ + return (struct ncp_dentry *) dentry->d_fsdata; +} + +#define NCP_GET_AGE(dentry) (jiffies - NCP_DENTRY(dentry)->time) #define NCP_MAX_AGE(server) atomic_read(&(server)->dentry_ttl) #define NCP_TEST_AGE(server,dentry) (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server)) static inline void ncp_age_dentry(struct ncp_server* server, struct dentry* dentry) { - dentry->d_time = jiffies - NCP_MAX_AGE(server); + NCP_DENTRY(dentry)->time = jiffies - NCP_MAX_AGE(server); } static inline void ncp_new_dentry(struct dentry* dentry) { - dentry->d_time = jiffies; + NCP_DENTRY(dentry)->time = jiffies; } struct ncp_cache_head {