From: Miklos Szeredi <mszeredi@redhat.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] ncpfs: don't use ->d_time
Date: Mon, 7 Nov 2016 11:51:59 +0100 [thread overview]
Message-ID: <1478515920-20458-3-git-send-email-mszeredi@redhat.com> (raw)
In-Reply-To: <1478515920-20458-1-git-send-email-mszeredi@redhat.com>
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 <mszeredi@redhat.com>
---
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 6df2a3827574..ce42dbdde777 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_init(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 *,
@@ -81,6 +83,8 @@ static void ncp_d_prune(struct dentry *dentry);
const struct dentry_operations ncp_dentry_operations =
{
+ .d_init = ncp_d_init,
+ .d_release = ncp_d_release,
.d_revalidate = ncp_lookup_validate,
.d_hash = ncp_hash_dentry,
.d_compare = ncp_compare_dentry,
@@ -305,6 +309,17 @@ leave_me:;
}
#endif /* CONFIG_NCPFS_STRONG */
+static int ncp_d_init(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)
@@ -408,7 +423,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);
@@ -568,7 +583,7 @@ static int ncp_readdir(struct file *file, struct dir_context *ctx)
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;
}
@@ -659,7 +674,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 {
--
2.5.5
next prev parent reply other threads:[~2016-11-07 11:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 10:51 [RFC/RFT PATCH 0/3] d_time removal Miklos Szeredi
2016-11-07 10:51 ` [PATCH 1/3] nfs: don't use ->d_time Miklos Szeredi
2016-11-07 10:51 ` Miklos Szeredi [this message]
2016-11-07 10:52 ` [PATCH 3/3] vfs: remove ->d_time Miklos Szeredi
2016-12-07 19:46 ` [RFC/RFT PATCH 0/3] d_time removal Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1478515920-20458-3-git-send-email-mszeredi@redhat.com \
--to=mszeredi@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=trond.myklebust@primarydata.com \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®