mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-25 18:30:06 +00:00
fuse: direct-io: don't dirty ITER_BVEC pages
When reading from a loop device backed by a fuse file it deadlocks on
lock_page().
This is because the page is already locked by the read() operation done on
the loop device. In this case we don't want to either lock the page or
dirty it.
So do what fs/direct-io.c does: only dirty the page for ITER_IOVEC vectors.
Reported-by: Sheng Yang <sheng@yasker.org>
Fixes: aa4d86163e
("block: loop: switch to VFS ITER_BVEC")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Cc: <stable@vger.kernel.org> # v4.1+
Reviewed-by: Sheng Yang <sheng@yasker.org>
Reviewed-by: Ashish Samant <ashish.samant@oracle.com>
Tested-by: Sheng Yang <sheng@yasker.org>
Tested-by: Ashish Samant <ashish.samant@oracle.com>
This commit is contained in:
parent
fa8410b355
commit
8fba54aebb
1 changed files with 4 additions and 3 deletions
|
@ -530,13 +530,13 @@ void fuse_read_fill(struct fuse_req *req, struct file *file, loff_t pos,
|
|||
req->out.args[0].size = count;
|
||||
}
|
||||
|
||||
static void fuse_release_user_pages(struct fuse_req *req, int write)
|
||||
static void fuse_release_user_pages(struct fuse_req *req, bool should_dirty)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < req->num_pages; i++) {
|
||||
struct page *page = req->pages[i];
|
||||
if (write)
|
||||
if (should_dirty)
|
||||
set_page_dirty_lock(page);
|
||||
put_page(page);
|
||||
}
|
||||
|
@ -1320,6 +1320,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
|
|||
loff_t *ppos, int flags)
|
||||
{
|
||||
int write = flags & FUSE_DIO_WRITE;
|
||||
bool should_dirty = !write && iter_is_iovec(iter);
|
||||
int cuse = flags & FUSE_DIO_CUSE;
|
||||
struct file *file = io->file;
|
||||
struct inode *inode = file->f_mapping->host;
|
||||
|
@ -1363,7 +1364,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
|
|||
nres = fuse_send_read(req, io, pos, nbytes, owner);
|
||||
|
||||
if (!io->async)
|
||||
fuse_release_user_pages(req, !write);
|
||||
fuse_release_user_pages(req, should_dirty);
|
||||
if (req->out.h.error) {
|
||||
err = req->out.h.error;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue