mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-29 23:24:11 +08:00
fuse: move reverting attributes to fuse_change_attributes()
In case of writeback_cache fuse_fillattr() would revert the queried attributes to the cached version. Move this to fuse_change_attributes() in order to manage the writeback logic in a central helper. This will be necessary for patches that follow. Only fuse_do_getattr() -> fuse_fillattr() uses the attributes after calling fuse_change_attributes(), so this should not change behavior. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
c15016b7ae
commit
04d82db0c5
@ -944,15 +944,6 @@ static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr,
|
|||||||
unsigned int blkbits;
|
unsigned int blkbits;
|
||||||
struct fuse_conn *fc = get_fuse_conn(inode);
|
struct fuse_conn *fc = get_fuse_conn(inode);
|
||||||
|
|
||||||
/* see the comment in fuse_change_attributes() */
|
|
||||||
if (fc->writeback_cache && S_ISREG(inode->i_mode)) {
|
|
||||||
attr->size = i_size_read(inode);
|
|
||||||
attr->mtime = inode->i_mtime.tv_sec;
|
|
||||||
attr->mtimensec = inode->i_mtime.tv_nsec;
|
|
||||||
attr->ctime = inode->i_ctime.tv_sec;
|
|
||||||
attr->ctimensec = inode->i_ctime.tv_nsec;
|
|
||||||
}
|
|
||||||
|
|
||||||
stat->dev = inode->i_sb->s_dev;
|
stat->dev = inode->i_sb->s_dev;
|
||||||
stat->ino = attr->ino;
|
stat->ino = attr->ino;
|
||||||
stat->mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
|
stat->mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
|
||||||
|
@ -228,6 +228,19 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
|
|||||||
struct timespec64 old_mtime;
|
struct timespec64 old_mtime;
|
||||||
|
|
||||||
spin_lock(&fi->lock);
|
spin_lock(&fi->lock);
|
||||||
|
/*
|
||||||
|
* In case of writeback_cache enabled, writes update mtime, ctime and
|
||||||
|
* may update i_size. In these cases trust the cached value in the
|
||||||
|
* inode.
|
||||||
|
*/
|
||||||
|
if (is_wb) {
|
||||||
|
attr->size = i_size_read(inode);
|
||||||
|
attr->mtime = inode->i_mtime.tv_sec;
|
||||||
|
attr->mtimensec = inode->i_mtime.tv_nsec;
|
||||||
|
attr->ctime = inode->i_ctime.tv_sec;
|
||||||
|
attr->ctimensec = inode->i_ctime.tv_nsec;
|
||||||
|
}
|
||||||
|
|
||||||
if ((attr_version != 0 && fi->attr_version > attr_version) ||
|
if ((attr_version != 0 && fi->attr_version > attr_version) ||
|
||||||
test_bit(FUSE_I_SIZE_UNSTABLE, &fi->state)) {
|
test_bit(FUSE_I_SIZE_UNSTABLE, &fi->state)) {
|
||||||
spin_unlock(&fi->lock);
|
spin_unlock(&fi->lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user