Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1428845 > unrolled thread
| Started by | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| First post | 2016-06-22 16:40 +0200 |
| Last post | 2016-06-22 18:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 5/8] fuse: don't use ->d_time Miklos Szeredi <mszeredi@redhat.com> - 2016-06-22 16:40 +0200
Re: [PATCH 5/8] fuse: don't use ->d_time Al Viro <viro@ZenIV.linux.org.uk> - 2016-06-22 18:50 +0200
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-06-22 16:40 +0200 |
| Subject | [PATCH 5/8] fuse: don't use ->d_time |
| Message-ID | <rMRtT-4E1-7@gated-at.bofh.it> |
Store in memory pointed to by ->d_fsdata. Use ->d_allocate() to allocate
the storage.
We could cast ->d_fsdata directly on 64bit archs, but I don't think this is
worth the extra complexity.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/fuse/dir.c | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index ccd4971cc6c1..1a1dabb72036 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -37,37 +37,20 @@ static void fuse_advise_use_readdirplus(struct inode *dir)
set_bit(FUSE_I_ADVISE_RDPLUS, &fi->state);
}
-#if BITS_PER_LONG >= 64
static inline void fuse_dentry_settime(struct dentry *entry, u64 time)
{
- entry->d_time = time;
+ *(u64 *) entry->d_fsdata = time;
}
static inline u64 fuse_dentry_time(struct dentry *entry)
{
- return entry->d_time;
+ return *(u64 *) entry->d_fsdata;
}
-#else
-/*
- * On 32 bit archs store the high 32 bits of time in d_fsdata
- */
-static void fuse_dentry_settime(struct dentry *entry, u64 time)
-{
- entry->d_time = time;
- entry->d_fsdata = (void *) (unsigned long) (time >> 32);
-}
-
-static u64 fuse_dentry_time(struct dentry *entry)
-{
- return (u64) entry->d_time +
- ((u64) (unsigned long) entry->d_fsdata << 32);
-}
-#endif
/*
* FUSE caches dentries and attributes with separate timeout. The
* time in jiffies until the dentry/attributes are valid is stored in
- * dentry->d_time and fuse_inode->i_time respectively.
+ * dentry->d_fsdata and fuse_inode->i_time respectively.
*/
/*
@@ -272,8 +255,21 @@ static int invalid_nodeid(u64 nodeid)
return !nodeid || nodeid == FUSE_ROOT_ID;
}
+static int fuse_dentry_allocate(struct dentry *dentry)
+{
+ dentry->d_fsdata = kzalloc(sizeof(u64), GFP_KERNEL);
+
+ return dentry->d_fsdata ? 0 : -ENOMEM;
+}
+static void fuse_dentry_release(struct dentry *dentry)
+{
+ kfree(dentry->d_fsdata);
+}
+
const struct dentry_operations fuse_dentry_operations = {
.d_revalidate = fuse_dentry_revalidate,
+ .d_allocate = fuse_dentry_allocate,
+ .d_release = fuse_dentry_release,
};
int fuse_valid_type(int m)
--
2.5.5
[toc] | [next] | [standalone]
| From | Al Viro <viro@ZenIV.linux.org.uk> |
|---|---|
| Date | 2016-06-22 18:50 +0200 |
| Message-ID | <rMTvJ-5UI-61@gated-at.bofh.it> |
| In reply to | #1428845 |
On Wed, Jun 22, 2016 at 04:35:07PM +0200, Miklos Szeredi wrote:
> Store in memory pointed to by ->d_fsdata. Use ->d_allocate() to allocate
> the storage.
>
> We could cast ->d_fsdata directly on 64bit archs, but I don't think this is
> worth the extra complexity.
Now, _that_ is interesting:
> +static void fuse_dentry_release(struct dentry *dentry)
> +{
> + kfree(dentry->d_fsdata);
> +}
What happens to fuse_dentry_revalidate() called on dentry in process of
getting dropped? Unlike freeing struct dentry itself, ->d_release() is
not RCU-delayed. So you are risking dereference of ->d_fsdata after
kfree(); at the very least, it needs RCU-delayed freeing...
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web