Skip to content

Commit 7956994

Browse files
joannekoongMiklos Szeredi
authored andcommitted
fuse: reflect cached blocksize if blocksize was changed
As pointed out by Miklos[1], in the fuse_update_get_attr() path, the attributes returned to stat may be cached values instead of fresh ones fetched from the server. In the case where the server returned a modified blocksize value, we need to cache it and reflect it back to stat if values are not re-fetched since we now no longer directly change inode->i_blkbits. Link: https://lore.kernel.org/linux-fsdevel/CAJfpeguCOxeVX88_zPd1hqziB_C+tmfuDhZP5qO2nKmnb-dTUA@mail.gmail.com/ [1] Fixes: 542ede0 ("fuse: keep inode->i_blkbits constant") Signed-off-by: Joanne Koong <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 1e08938 commit 7956994

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

fs/fuse/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ static int fuse_update_get_attr(struct mnt_idmap *idmap, struct inode *inode,
13771377
generic_fillattr(idmap, request_mask, inode, stat);
13781378
stat->mode = fi->orig_i_mode;
13791379
stat->ino = fi->orig_ino;
1380+
stat->blksize = 1 << fi->cached_i_blkbits;
13801381
if (test_bit(FUSE_I_BTIME, &fi->state)) {
13811382
stat->btime = fi->i_btime;
13821383
stat->result_mask |= STATX_BTIME;

fs/fuse/fuse_i.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ struct fuse_inode {
210210
/** Reference to backing file in passthrough mode */
211211
struct fuse_backing *fb;
212212
#endif
213+
214+
/*
215+
* The underlying inode->i_blkbits value will not be modified,
216+
* so preserve the blocksize specified by the server.
217+
*/
218+
u8 cached_i_blkbits;
213219
};
214220

215221
/** FUSE inode state bits */

fs/fuse/inode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
289289
}
290290
}
291291

292+
if (attr->blksize)
293+
fi->cached_i_blkbits = ilog2(attr->blksize);
294+
else
295+
fi->cached_i_blkbits = inode->i_sb->s_blocksize_bits;
296+
292297
/*
293298
* Don't set the sticky bit in i_mode, unless we want the VFS
294299
* to check permissions. This prevents failures due to the

0 commit comments

Comments
 (0)