Skip to content

Commit 203627b

Browse files
author
Miklos Szeredi
committed
fuse: fix blksize calculation
Don't use inode->i_blkbits which might be stale, instead calculate the blksize information from the freshly obtained attributes. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 45c72cd commit 203627b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/fuse/dir.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,8 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
775775
static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr,
776776
struct kstat *stat)
777777
{
778+
unsigned int blkbits;
779+
778780
stat->dev = inode->i_sb->s_dev;
779781
stat->ino = attr->ino;
780782
stat->mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
@@ -790,7 +792,13 @@ static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr,
790792
stat->ctime.tv_nsec = attr->ctimensec;
791793
stat->size = attr->size;
792794
stat->blocks = attr->blocks;
793-
stat->blksize = (1 << inode->i_blkbits);
795+
796+
if (attr->blksize != 0)
797+
blkbits = ilog2(attr->blksize);
798+
else
799+
blkbits = inode->i_sb->s_blocksize_bits;
800+
801+
stat->blksize = 1 << blkbits;
794802
}
795803

796804
static int fuse_do_getattr(struct inode *inode, struct kstat *stat,

0 commit comments

Comments
 (0)