Skip to content

Commit 9dc10a5

Browse files
author
Miklos Szeredi
committed
fuse: add ATTR_TIMEOUT macro
Next patch will introduce yet another type attribute reply. Add a macro that can handle attribute timeouts for all of the structs. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent ba58a37 commit 9dc10a5

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

fs/fuse/dir.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void fuse_dentry_settime(struct dentry *dentry, u64 time)
9292
/*
9393
* Calculate the time in jiffies until a dentry/attributes are valid
9494
*/
95-
static u64 time_to_jiffies(u64 sec, u32 nsec)
95+
u64 fuse_time_to_jiffies(u64 sec, u32 nsec)
9696
{
9797
if (sec || nsec) {
9898
struct timespec64 ts = {
@@ -112,17 +112,7 @@ static u64 time_to_jiffies(u64 sec, u32 nsec)
112112
void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o)
113113
{
114114
fuse_dentry_settime(entry,
115-
time_to_jiffies(o->entry_valid, o->entry_valid_nsec));
116-
}
117-
118-
static u64 attr_timeout(struct fuse_attr_out *o)
119-
{
120-
return time_to_jiffies(o->attr_valid, o->attr_valid_nsec);
121-
}
122-
123-
u64 entry_attr_timeout(struct fuse_entry_out *o)
124-
{
125-
return time_to_jiffies(o->attr_valid, o->attr_valid_nsec);
115+
fuse_time_to_jiffies(o->entry_valid, o->entry_valid_nsec));
126116
}
127117

128118
void fuse_invalidate_attr_mask(struct inode *inode, u32 mask)
@@ -266,7 +256,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
266256

267257
forget_all_cached_acls(inode);
268258
fuse_change_attributes(inode, &outarg.attr,
269-
entry_attr_timeout(&outarg),
259+
ATTR_TIMEOUT(&outarg),
270260
attr_version);
271261
fuse_change_entry_timeout(entry, &outarg);
272262
} else if (inode) {
@@ -399,7 +389,7 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name
399389
goto out_put_forget;
400390

401391
*inode = fuse_iget(sb, outarg->nodeid, outarg->generation,
402-
&outarg->attr, entry_attr_timeout(outarg),
392+
&outarg->attr, ATTR_TIMEOUT(outarg),
403393
attr_version);
404394
err = -ENOMEM;
405395
if (!*inode) {
@@ -686,7 +676,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
686676
ff->nodeid = outentry.nodeid;
687677
ff->open_flags = outopen.open_flags;
688678
inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation,
689-
&outentry.attr, entry_attr_timeout(&outentry), 0);
679+
&outentry.attr, ATTR_TIMEOUT(&outentry), 0);
690680
if (!inode) {
691681
flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
692682
fuse_sync_release(NULL, ff, flags);
@@ -813,7 +803,7 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args,
813803
goto out_put_forget_req;
814804

815805
inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
816-
&outarg.attr, entry_attr_timeout(&outarg), 0);
806+
&outarg.attr, ATTR_TIMEOUT(&outarg), 0);
817807
if (!inode) {
818808
fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1);
819809
return -ENOMEM;
@@ -1190,7 +1180,7 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
11901180
err = -EIO;
11911181
} else {
11921182
fuse_change_attributes(inode, &outarg.attr,
1193-
attr_timeout(&outarg),
1183+
ATTR_TIMEOUT(&outarg),
11941184
attr_version);
11951185
if (stat)
11961186
fuse_fillattr(inode, &outarg.attr, stat);
@@ -1867,7 +1857,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
18671857
}
18681858

18691859
fuse_change_attributes_common(inode, &outarg.attr,
1870-
attr_timeout(&outarg),
1860+
ATTR_TIMEOUT(&outarg),
18711861
fuse_get_cache_mask(inode));
18721862
oldsize = inode->i_size;
18731863
/* see the comment in fuse_change_attributes() */

fs/fuse/fuse_i.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,10 @@ void fuse_invalidate_entry_cache(struct dentry *entry);
11141114

11151115
void fuse_invalidate_atime(struct inode *inode);
11161116

1117-
u64 entry_attr_timeout(struct fuse_entry_out *o);
1117+
u64 fuse_time_to_jiffies(u64 sec, u32 nsec);
1118+
#define ATTR_TIMEOUT(o) \
1119+
fuse_time_to_jiffies((o)->attr_valid, (o)->attr_valid_nsec)
1120+
11181121
void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o);
11191122

11201123
/**

fs/fuse/readdir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ static int fuse_direntplus_link(struct file *file,
224224

225225
forget_all_cached_acls(inode);
226226
fuse_change_attributes(inode, &o->attr,
227-
entry_attr_timeout(o),
227+
ATTR_TIMEOUT(o),
228228
attr_version);
229229
/*
230230
* The other branch comes via fuse_iget()
231231
* which bumps nlookup inside
232232
*/
233233
} else {
234234
inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
235-
&o->attr, entry_attr_timeout(o),
235+
&o->attr, ATTR_TIMEOUT(o),
236236
attr_version);
237237
if (!inode)
238238
inode = ERR_PTR(-ENOMEM);

0 commit comments

Comments
 (0)