fuse: simplify local variables holding writeback cache state

There are two instances of "bool is_wb = fc->writeback_cache" where the
actual use mostly involves checking "is_wb && S_ISREG(inode->i_mode)".

Clean up these cases by storing the second condition in the local variable.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Miklos Szeredi 2021-10-22 17:03:03 +02:00
parent 20235b435a
commit c15016b7ae
2 changed files with 6 additions and 6 deletions

View File

@ -1561,10 +1561,10 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
struct fuse_setattr_in inarg; struct fuse_setattr_in inarg;
struct fuse_attr_out outarg; struct fuse_attr_out outarg;
bool is_truncate = false; bool is_truncate = false;
bool is_wb = fc->writeback_cache; bool is_wb = fc->writeback_cache && S_ISREG(inode->i_mode);
loff_t oldsize; loff_t oldsize;
int err; int err;
bool trust_local_cmtime = is_wb && S_ISREG(inode->i_mode); bool trust_local_cmtime = is_wb;
bool fault_blocked = false; bool fault_blocked = false;
if (!fc->default_permissions) if (!fc->default_permissions)
@ -1608,7 +1608,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
} }
/* Flush dirty data/metadata before non-truncate SETATTR */ /* Flush dirty data/metadata before non-truncate SETATTR */
if (is_wb && S_ISREG(inode->i_mode) && if (is_wb &&
attr->ia_valid & attr->ia_valid &
(ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME_SET | (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME_SET |
ATTR_TIMES_SET)) { ATTR_TIMES_SET)) {
@ -1679,7 +1679,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
attr_timeout(&outarg)); attr_timeout(&outarg));
oldsize = inode->i_size; oldsize = inode->i_size;
/* see the comment in fuse_change_attributes() */ /* see the comment in fuse_change_attributes() */
if (!is_wb || is_truncate || !S_ISREG(inode->i_mode)) if (!is_wb || is_truncate)
i_size_write(inode, outarg.attr.size); i_size_write(inode, outarg.attr.size);
if (is_truncate) { if (is_truncate) {

View File

@ -223,7 +223,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
{ {
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_inode *fi = get_fuse_inode(inode);
bool is_wb = fc->writeback_cache; bool is_wb = fc->writeback_cache && S_ISREG(inode->i_mode);
loff_t oldsize; loff_t oldsize;
struct timespec64 old_mtime; struct timespec64 old_mtime;
@ -243,7 +243,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
* extend local i_size without keeping userspace server in sync. So, * extend local i_size without keeping userspace server in sync. So,
* attr->size coming from server can be stale. We cannot trust it. * attr->size coming from server can be stale. We cannot trust it.
*/ */
if (!is_wb || !S_ISREG(inode->i_mode)) if (!is_wb)
i_size_write(inode, attr->size); i_size_write(inode, attr->size);
spin_unlock(&fi->lock); spin_unlock(&fi->lock);