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>
This commit is contained in:
parent
ba58a37c28
commit
9dc10a54ab
@ -92,7 +92,7 @@ static void fuse_dentry_settime(struct dentry *dentry, u64 time)
|
||||
/*
|
||||
* Calculate the time in jiffies until a dentry/attributes are valid
|
||||
*/
|
||||
static u64 time_to_jiffies(u64 sec, u32 nsec)
|
||||
u64 fuse_time_to_jiffies(u64 sec, u32 nsec)
|
||||
{
|
||||
if (sec || nsec) {
|
||||
struct timespec64 ts = {
|
||||
@ -112,17 +112,7 @@ static u64 time_to_jiffies(u64 sec, u32 nsec)
|
||||
void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o)
|
||||
{
|
||||
fuse_dentry_settime(entry,
|
||||
time_to_jiffies(o->entry_valid, o->entry_valid_nsec));
|
||||
}
|
||||
|
||||
static u64 attr_timeout(struct fuse_attr_out *o)
|
||||
{
|
||||
return time_to_jiffies(o->attr_valid, o->attr_valid_nsec);
|
||||
}
|
||||
|
||||
u64 entry_attr_timeout(struct fuse_entry_out *o)
|
||||
{
|
||||
return time_to_jiffies(o->attr_valid, o->attr_valid_nsec);
|
||||
fuse_time_to_jiffies(o->entry_valid, o->entry_valid_nsec));
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
forget_all_cached_acls(inode);
|
||||
fuse_change_attributes(inode, &outarg.attr,
|
||||
entry_attr_timeout(&outarg),
|
||||
ATTR_TIMEOUT(&outarg),
|
||||
attr_version);
|
||||
fuse_change_entry_timeout(entry, &outarg);
|
||||
} else if (inode) {
|
||||
@ -399,7 +389,7 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name
|
||||
goto out_put_forget;
|
||||
|
||||
*inode = fuse_iget(sb, outarg->nodeid, outarg->generation,
|
||||
&outarg->attr, entry_attr_timeout(outarg),
|
||||
&outarg->attr, ATTR_TIMEOUT(outarg),
|
||||
attr_version);
|
||||
err = -ENOMEM;
|
||||
if (!*inode) {
|
||||
@ -686,7 +676,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
|
||||
ff->nodeid = outentry.nodeid;
|
||||
ff->open_flags = outopen.open_flags;
|
||||
inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation,
|
||||
&outentry.attr, entry_attr_timeout(&outentry), 0);
|
||||
&outentry.attr, ATTR_TIMEOUT(&outentry), 0);
|
||||
if (!inode) {
|
||||
flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
|
||||
fuse_sync_release(NULL, ff, flags);
|
||||
@ -813,7 +803,7 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args,
|
||||
goto out_put_forget_req;
|
||||
|
||||
inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
|
||||
&outarg.attr, entry_attr_timeout(&outarg), 0);
|
||||
&outarg.attr, ATTR_TIMEOUT(&outarg), 0);
|
||||
if (!inode) {
|
||||
fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1);
|
||||
return -ENOMEM;
|
||||
@ -1190,7 +1180,7 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
|
||||
err = -EIO;
|
||||
} else {
|
||||
fuse_change_attributes(inode, &outarg.attr,
|
||||
attr_timeout(&outarg),
|
||||
ATTR_TIMEOUT(&outarg),
|
||||
attr_version);
|
||||
if (stat)
|
||||
fuse_fillattr(inode, &outarg.attr, stat);
|
||||
@ -1867,7 +1857,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
|
||||
}
|
||||
|
||||
fuse_change_attributes_common(inode, &outarg.attr,
|
||||
attr_timeout(&outarg),
|
||||
ATTR_TIMEOUT(&outarg),
|
||||
fuse_get_cache_mask(inode));
|
||||
oldsize = inode->i_size;
|
||||
/* see the comment in fuse_change_attributes() */
|
||||
|
@ -1114,7 +1114,10 @@ void fuse_invalidate_entry_cache(struct dentry *entry);
|
||||
|
||||
void fuse_invalidate_atime(struct inode *inode);
|
||||
|
||||
u64 entry_attr_timeout(struct fuse_entry_out *o);
|
||||
u64 fuse_time_to_jiffies(u64 sec, u32 nsec);
|
||||
#define ATTR_TIMEOUT(o) \
|
||||
fuse_time_to_jiffies((o)->attr_valid, (o)->attr_valid_nsec)
|
||||
|
||||
void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o);
|
||||
|
||||
/**
|
||||
|
@ -224,7 +224,7 @@ retry:
|
||||
|
||||
forget_all_cached_acls(inode);
|
||||
fuse_change_attributes(inode, &o->attr,
|
||||
entry_attr_timeout(o),
|
||||
ATTR_TIMEOUT(o),
|
||||
attr_version);
|
||||
/*
|
||||
* The other branch comes via fuse_iget()
|
||||
@ -232,7 +232,7 @@ retry:
|
||||
*/
|
||||
} else {
|
||||
inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
|
||||
&o->attr, entry_attr_timeout(o),
|
||||
&o->attr, ATTR_TIMEOUT(o),
|
||||
attr_version);
|
||||
if (!inode)
|
||||
inode = ERR_PTR(-ENOMEM);
|
||||
|
Loading…
Reference in New Issue
Block a user