Skip to content

Commit c15016b

Browse files
author
Miklos Szeredi
committed
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 <[email protected]>
1 parent 20235b4 commit c15016b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

fs/fuse/dir.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,10 +1561,10 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
15611561
struct fuse_setattr_in inarg;
15621562
struct fuse_attr_out outarg;
15631563
bool is_truncate = false;
1564-
bool is_wb = fc->writeback_cache;
1564+
bool is_wb = fc->writeback_cache && S_ISREG(inode->i_mode);
15651565
loff_t oldsize;
15661566
int err;
1567-
bool trust_local_cmtime = is_wb && S_ISREG(inode->i_mode);
1567+
bool trust_local_cmtime = is_wb;
15681568
bool fault_blocked = false;
15691569

15701570
if (!fc->default_permissions)
@@ -1608,7 +1608,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
16081608
}
16091609

16101610
/* Flush dirty data/metadata before non-truncate SETATTR */
1611-
if (is_wb && S_ISREG(inode->i_mode) &&
1611+
if (is_wb &&
16121612
attr->ia_valid &
16131613
(ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME_SET |
16141614
ATTR_TIMES_SET)) {
@@ -1679,7 +1679,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
16791679
attr_timeout(&outarg));
16801680
oldsize = inode->i_size;
16811681
/* see the comment in fuse_change_attributes() */
1682-
if (!is_wb || is_truncate || !S_ISREG(inode->i_mode))
1682+
if (!is_wb || is_truncate)
16831683
i_size_write(inode, outarg.attr.size);
16841684

16851685
if (is_truncate) {

fs/fuse/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
223223
{
224224
struct fuse_conn *fc = get_fuse_conn(inode);
225225
struct fuse_inode *fi = get_fuse_inode(inode);
226-
bool is_wb = fc->writeback_cache;
226+
bool is_wb = fc->writeback_cache && S_ISREG(inode->i_mode);
227227
loff_t oldsize;
228228
struct timespec64 old_mtime;
229229

@@ -243,7 +243,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
243243
* extend local i_size without keeping userspace server in sync. So,
244244
* attr->size coming from server can be stale. We cannot trust it.
245245
*/
246-
if (!is_wb || !S_ISREG(inode->i_mode))
246+
if (!is_wb)
247247
i_size_write(inode, attr->size);
248248
spin_unlock(&fi->lock);
249249

0 commit comments

Comments
 (0)