diff options
author | Maxim Patlasov <mpatlasov@parallels.com> | 2012-12-18 14:05:08 +0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2013-04-18 10:55:24 +0200 |
commit | efb9fa9e911b23c7ea5330215bda778a7c69dba8 (patch) | |
tree | 7af69df4b3f3c5b89dc0e245a974fec358f23028 /fs/fuse/file.c | |
parent | 439ee5f0c5080d4fd15fda0c5bbee1fb3a57894e (diff) |
fuse: truncate file if async dio failed
The patch improves error handling in fuse_direct_IO(): if we successfully
submitted several fuse requests on behalf of synchronous direct write
extending file and some of them failed, let's try to do our best to clean-up.
Changed in v2: reuse fuse_do_setattr(). Thanks to Brian for suggestion.
Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/fuse/file.c')
-rw-r--r-- | fs/fuse/file.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 8f39f7b8cef..1f8e3d60dc0 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2352,6 +2352,20 @@ int fuse_notify_poll_wakeup(struct fuse_conn *fc, return 0; } +static void fuse_do_truncate(struct file *file) +{ + struct inode *inode = file->f_mapping->host; + struct iattr attr; + + attr.ia_valid = ATTR_SIZE; + attr.ia_size = i_size_read(inode); + + attr.ia_file = file; + attr.ia_valid |= ATTR_FILE; + + fuse_do_setattr(inode, &attr, file); +} + static ssize_t fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t offset, unsigned long nr_segs) @@ -2419,8 +2433,12 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, kfree(io); } - if (rw == WRITE && ret > 0) - fuse_write_update_size(inode, pos); + if (rw == WRITE) { + if (ret > 0) + fuse_write_update_size(inode, pos); + else if (ret < 0 && offset + count > i_size) + fuse_do_truncate(file); + } return ret; } |