diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2019-01-24 10:40:17 +0100 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2019-02-13 13:15:15 +0100 |
commit | 2f7b6f5bed01a3fd2abcc20d2c85b7c532eb95cd (patch) | |
tree | d336e825a3562b8c2555bbb113d78cdc93891dcc /fs/fuse | |
parent | fuse: multiplex cached/direct_io file operations (diff) | |
download | linux-2f7b6f5bed01a3fd2abcc20d2c85b7c532eb95cd.tar.xz linux-2f7b6f5bed01a3fd2abcc20d2c85b7c532eb95cd.zip |
fuse: lift bad inode checks into callers
Bad inode checks were done done in various places, and move them into
fuse_file_{read|write}_iter().
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/file.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index e5dfc5e4b999..8ee0446a8322 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1131,9 +1131,6 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, int err = 0; ssize_t res = 0; - if (is_bad_inode(inode)) - return -EIO; - if (inode->i_size < pos + iov_iter_count(ii)) set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); @@ -1422,9 +1419,6 @@ static ssize_t __fuse_direct_read(struct fuse_io_priv *io, ssize_t res; struct inode *inode = file_inode(io->iocb->ki_filp); - if (is_bad_inode(inode)) - return -EIO; - res = fuse_direct_io(io, iter, ppos, 0); fuse_invalidate_atime(inode); @@ -1439,11 +1433,6 @@ static ssize_t fuse_direct_read_iter(struct kiocb *iocb, struct iov_iter *to) ssize_t res; if (!is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) { - struct file *file = iocb->ki_filp; - - if (is_bad_inode(file_inode(file))) - return -EIO; - res = fuse_direct_IO(iocb, to); } else { struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb); @@ -1460,9 +1449,6 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb); ssize_t res; - if (is_bad_inode(inode)) - return -EIO; - /* Don't allow parallel writes to the same file */ inode_lock(inode); res = generic_write_checks(iocb, from); @@ -1484,7 +1470,11 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) static ssize_t fuse_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { - struct fuse_file *ff = iocb->ki_filp->private_data; + struct file *file = iocb->ki_filp; + struct fuse_file *ff = file->private_data; + + if (is_bad_inode(file_inode(file))) + return -EIO; if (!(ff->open_flags & FOPEN_DIRECT_IO)) return fuse_cache_read_iter(iocb, to); @@ -1494,7 +1484,11 @@ static ssize_t fuse_file_read_iter(struct kiocb *iocb, struct iov_iter *to) static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { - struct fuse_file *ff = iocb->ki_filp->private_data; + struct file *file = iocb->ki_filp; + struct fuse_file *ff = file->private_data; + + if (is_bad_inode(file_inode(file))) + return -EIO; if (!(ff->open_flags & FOPEN_DIRECT_IO)) return fuse_cache_write_iter(iocb, from); |