Commit 27ae0c41 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse

Pull fuse updates from Miklos Szeredi:
 "This fixes error propagation from writeback to fsync/close for
  writeback cache mode as well as adding a missing capability flag to
  the INIT message.  The rest are cleanups.

  (The commits are recent but all the code actually sat in -next for a
  while now.  The recommits are due to conflict avoidance and the
  addition of Cc: stable@...)"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse:
  fuse: use filemap_check_errors()
  mm: export filemap_check_errors() to modules
  fuse: fix wrong assignment of ->flags in fuse_send_init()
  fuse: fuse_flush must check mapping->flags for errors
  fuse: fsync() did not return IO errors
  fuse: don't mess with blocking signals
  new helper: wait_event_killable_exclusive()
  fuse: improve aio directIO write performance for size extending writes
parents 20d00ee8 4a7f4e88
...@@ -99,19 +99,6 @@ void fuse_request_free(struct fuse_req *req) ...@@ -99,19 +99,6 @@ void fuse_request_free(struct fuse_req *req)
kmem_cache_free(fuse_req_cachep, req); kmem_cache_free(fuse_req_cachep, req);
} }
static void block_sigs(sigset_t *oldset)
{
sigset_t mask;
siginitsetinv(&mask, sigmask(SIGKILL));
sigprocmask(SIG_BLOCK, &mask, oldset);
}
static void restore_sigs(sigset_t *oldset)
{
sigprocmask(SIG_SETMASK, oldset, NULL);
}
void __fuse_get_request(struct fuse_req *req) void __fuse_get_request(struct fuse_req *req)
{ {
atomic_inc(&req->count); atomic_inc(&req->count);
...@@ -151,15 +138,9 @@ static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages, ...@@ -151,15 +138,9 @@ static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages,
atomic_inc(&fc->num_waiting); atomic_inc(&fc->num_waiting);
if (fuse_block_alloc(fc, for_background)) { if (fuse_block_alloc(fc, for_background)) {
sigset_t oldset;
int intr;
block_sigs(&oldset);
intr = wait_event_interruptible_exclusive(fc->blocked_waitq,
!fuse_block_alloc(fc, for_background));
restore_sigs(&oldset);
err = -EINTR; err = -EINTR;
if (intr) if (wait_event_killable_exclusive(fc->blocked_waitq,
!fuse_block_alloc(fc, for_background)))
goto out; goto out;
} }
/* Matches smp_wmb() in fuse_set_initialized() */ /* Matches smp_wmb() in fuse_set_initialized() */
...@@ -446,14 +427,9 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req) ...@@ -446,14 +427,9 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
} }
if (!test_bit(FR_FORCE, &req->flags)) { if (!test_bit(FR_FORCE, &req->flags)) {
sigset_t oldset;
/* Only fatal signals may interrupt this */ /* Only fatal signals may interrupt this */
block_sigs(&oldset); err = wait_event_killable(req->waitq,
err = wait_event_interruptible(req->waitq,
test_bit(FR_FINISHED, &req->flags)); test_bit(FR_FINISHED, &req->flags));
restore_sigs(&oldset);
if (!err) if (!err)
return; return;
......
...@@ -417,6 +417,10 @@ static int fuse_flush(struct file *file, fl_owner_t id) ...@@ -417,6 +417,10 @@ static int fuse_flush(struct file *file, fl_owner_t id)
fuse_sync_writes(inode); fuse_sync_writes(inode);
inode_unlock(inode); inode_unlock(inode);
err = filemap_check_errors(file->f_mapping);
if (err)
return err;
req = fuse_get_req_nofail_nopages(fc, file); req = fuse_get_req_nofail_nopages(fc, file);
memset(&inarg, 0, sizeof(inarg)); memset(&inarg, 0, sizeof(inarg));
inarg.fh = ff->fh; inarg.fh = ff->fh;
...@@ -462,6 +466,16 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end, ...@@ -462,6 +466,16 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
goto out; goto out;
fuse_sync_writes(inode); fuse_sync_writes(inode);
/*
* Due to implementation of fuse writeback
* filemap_write_and_wait_range() does not catch errors.
* We have to do this directly after fuse_sync_writes()
*/
err = filemap_check_errors(file->f_mapping);
if (err)
goto out;
err = sync_inode_metadata(inode, 1); err = sync_inode_metadata(inode, 1);
if (err) if (err)
goto out; goto out;
...@@ -562,7 +576,6 @@ static ssize_t fuse_get_res_by_io(struct fuse_io_priv *io) ...@@ -562,7 +576,6 @@ static ssize_t fuse_get_res_by_io(struct fuse_io_priv *io)
*/ */
static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos) static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos)
{ {
bool is_sync = is_sync_kiocb(io->iocb);
int left; int left;
spin_lock(&io->lock); spin_lock(&io->lock);
...@@ -572,11 +585,11 @@ static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos) ...@@ -572,11 +585,11 @@ static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos)
io->bytes = pos; io->bytes = pos;
left = --io->reqs; left = --io->reqs;
if (!left && is_sync) if (!left && io->blocking)
complete(io->done); complete(io->done);
spin_unlock(&io->lock); spin_unlock(&io->lock);
if (!left && !is_sync) { if (!left && !io->blocking) {
ssize_t res = fuse_get_res_by_io(io); ssize_t res = fuse_get_res_by_io(io);
if (res >= 0) { if (res >= 0) {
...@@ -2850,7 +2863,6 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ...@@ -2850,7 +2863,6 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
size_t count = iov_iter_count(iter); size_t count = iov_iter_count(iter);
loff_t offset = iocb->ki_pos; loff_t offset = iocb->ki_pos;
struct fuse_io_priv *io; struct fuse_io_priv *io;
bool is_sync = is_sync_kiocb(iocb);
pos = offset; pos = offset;
inode = file->f_mapping->host; inode = file->f_mapping->host;
...@@ -2885,17 +2897,16 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ...@@ -2885,17 +2897,16 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
*/ */
io->async = async_dio; io->async = async_dio;
io->iocb = iocb; io->iocb = iocb;
io->blocking = is_sync_kiocb(iocb);
/* /*
* We cannot asynchronously extend the size of a file. We have no method * We cannot asynchronously extend the size of a file.
* to wait on real async I/O requests, so we must submit this request * In such case the aio will behave exactly like sync io.
* synchronously.
*/ */
if (!is_sync && (offset + count > i_size) && if ((offset + count > i_size) && iov_iter_rw(iter) == WRITE)
iov_iter_rw(iter) == WRITE) io->blocking = true;
io->async = false;
if (io->async && is_sync) { if (io->async && io->blocking) {
/* /*
* Additional reference to keep io around after * Additional reference to keep io around after
* calling fuse_aio_complete() * calling fuse_aio_complete()
...@@ -2915,7 +2926,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ...@@ -2915,7 +2926,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
fuse_aio_complete(io, ret < 0 ? ret : 0, -1); fuse_aio_complete(io, ret < 0 ? ret : 0, -1);
/* we have a non-extending, async request, so return */ /* we have a non-extending, async request, so return */
if (!is_sync) if (!io->blocking)
return -EIOCBQUEUED; return -EIOCBQUEUED;
wait_for_completion(&wait); wait_for_completion(&wait);
......
...@@ -259,6 +259,7 @@ struct fuse_io_priv { ...@@ -259,6 +259,7 @@ struct fuse_io_priv {
struct kiocb *iocb; struct kiocb *iocb;
struct file *file; struct file *file;
struct completion *done; struct completion *done;
bool blocking;
}; };
#define FUSE_IO_PRIV_SYNC(f) \ #define FUSE_IO_PRIV_SYNC(f) \
......
...@@ -942,7 +942,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req) ...@@ -942,7 +942,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK | FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK |
FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ | FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ |
FUSE_FLOCK_LOCKS | FUSE_IOCTL_DIR | FUSE_AUTO_INVAL_DATA | FUSE_FLOCK_LOCKS | FUSE_HAS_IOCTL_DIR | FUSE_AUTO_INVAL_DATA |
FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO | FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO |
FUSE_WRITEBACK_CACHE | FUSE_NO_OPEN_SUPPORT | FUSE_WRITEBACK_CACHE | FUSE_NO_OPEN_SUPPORT |
FUSE_PARALLEL_DIROPS; FUSE_PARALLEL_DIROPS;
......
...@@ -2506,6 +2506,7 @@ extern int __filemap_fdatawrite_range(struct address_space *mapping, ...@@ -2506,6 +2506,7 @@ extern int __filemap_fdatawrite_range(struct address_space *mapping,
loff_t start, loff_t end, int sync_mode); loff_t start, loff_t end, int sync_mode);
extern int filemap_fdatawrite_range(struct address_space *mapping, extern int filemap_fdatawrite_range(struct address_space *mapping,
loff_t start, loff_t end); loff_t start, loff_t end);
extern int filemap_check_errors(struct address_space *mapping);
extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end,
int datasync); int datasync);
......
...@@ -600,6 +600,19 @@ do { \ ...@@ -600,6 +600,19 @@ do { \
__ret; \ __ret; \
}) })
#define __wait_event_killable_exclusive(wq, condition) \
___wait_event(wq, condition, TASK_KILLABLE, 1, 0, \
schedule())
#define wait_event_killable_exclusive(wq, condition) \
({ \
int __ret = 0; \
might_sleep(); \
if (!(condition)) \
__ret = __wait_event_killable_exclusive(wq, condition); \
__ret; \
})
#define __wait_event_freezable_exclusive(wq, condition) \ #define __wait_event_freezable_exclusive(wq, condition) \
___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \ ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \
......
...@@ -273,7 +273,7 @@ void delete_from_page_cache(struct page *page) ...@@ -273,7 +273,7 @@ void delete_from_page_cache(struct page *page)
} }
EXPORT_SYMBOL(delete_from_page_cache); EXPORT_SYMBOL(delete_from_page_cache);
static int filemap_check_errors(struct address_space *mapping) int filemap_check_errors(struct address_space *mapping)
{ {
int ret = 0; int ret = 0;
/* Check for outstanding write errors */ /* Check for outstanding write errors */
...@@ -285,6 +285,7 @@ static int filemap_check_errors(struct address_space *mapping) ...@@ -285,6 +285,7 @@ static int filemap_check_errors(struct address_space *mapping)
ret = -EIO; ret = -EIO;
return ret; return ret;
} }
EXPORT_SYMBOL(filemap_check_errors);
/** /**
* __filemap_fdatawrite_range - start writeback on mapping dirty pages in range * __filemap_fdatawrite_range - start writeback on mapping dirty pages in range
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment