Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 376592
b: refs/heads/master
c: e5c5f05
h: refs/heads/master
v: v3
  • Loading branch information
Maxim Patlasov authored and Miklos Szeredi committed Jun 3, 2013
1 parent 86446bb commit 89ef786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c9ecf989cc7626e9edf8abef79f64b909542129b
refs/heads/master: e5c5f05dca0cf90f0f3bb1aea85dcf658baff185
14 changes: 10 additions & 4 deletions trunk/fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2373,13 +2373,19 @@ static void fuse_do_truncate(struct file *file)
fuse_do_setattr(inode, &attr, file);
}

static inline loff_t fuse_round_up(loff_t off)
{
return round_up(off, FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT);
}

static ssize_t
fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t offset, unsigned long nr_segs)
{
ssize_t ret = 0;
struct file *file = iocb->ki_filp;
struct fuse_file *ff = file->private_data;
bool async_dio = ff->fc->async_dio;
loff_t pos = 0;
struct inode *inode;
loff_t i_size;
Expand All @@ -2391,10 +2397,10 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
i_size = i_size_read(inode);

/* optimization for short read */
if (rw != WRITE && offset + count > i_size) {
if (async_dio && rw != WRITE && offset + count > i_size) {
if (offset >= i_size)
return 0;
count = i_size - offset;
count = min_t(loff_t, count, fuse_round_up(i_size - offset));
}

io = kmalloc(sizeof(struct fuse_io_priv), GFP_KERNEL);
Expand All @@ -2412,15 +2418,15 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
* By default, we want to optimize all I/Os with async request
* submission to the client filesystem if supported.
*/
io->async = ff->fc->async_dio;
io->async = async_dio;
io->iocb = iocb;

/*
* We cannot asynchronously extend the size of a file. We have no method
* to wait on real async I/O requests, so we must submit this request
* synchronously.
*/
if (!is_sync_kiocb(iocb) && (offset + count > i_size))
if (!is_sync_kiocb(iocb) && (offset + count > i_size) && rw == WRITE)
io->async = false;

if (rw == WRITE)
Expand Down

0 comments on commit 89ef786

Please sign in to comment.