Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373788
b: refs/heads/master
c: 439ee5f
h: refs/heads/master
v: v3
  • Loading branch information
Maxim Patlasov authored and Miklos Szeredi committed Apr 17, 2013
1 parent 1a8f783 commit e09702d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 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: bcba24ccdc82f7415154cf87226c2577cea13a5c
refs/heads/master: 439ee5f0c5080d4fd15fda0c5bbee1fb3a57894e
19 changes: 13 additions & 6 deletions trunk/fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,8 @@ EXPORT_SYMBOL_GPL(fuse_direct_io);

static ssize_t __fuse_direct_read(struct fuse_io_priv *io,
const struct iovec *iov,
unsigned long nr_segs, loff_t *ppos)
unsigned long nr_segs, loff_t *ppos,
size_t count)
{
ssize_t res;
struct file *file = io->file;
Expand All @@ -1340,8 +1341,7 @@ static ssize_t __fuse_direct_read(struct fuse_io_priv *io,
if (is_bad_inode(inode))
return -EIO;

res = fuse_direct_io(io, iov, nr_segs, iov_length(iov, nr_segs),
ppos, 0);
res = fuse_direct_io(io, iov, nr_segs, count, ppos, 0);

fuse_invalidate_attr(inode);

Expand All @@ -1353,7 +1353,7 @@ static ssize_t fuse_direct_read(struct file *file, char __user *buf,
{
struct fuse_io_priv io = { .async = 0, .file = file };
struct iovec iov = { .iov_base = buf, .iov_len = count };
return __fuse_direct_read(&io, &iov, 1, ppos);
return __fuse_direct_read(&io, &iov, 1, ppos, count);
}

static ssize_t __fuse_direct_write(struct fuse_io_priv *io,
Expand Down Expand Up @@ -2369,6 +2369,13 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
inode = file->f_mapping->host;
i_size = i_size_read(inode);

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

io = kmalloc(sizeof(struct fuse_io_priv), GFP_KERNEL);
if (!io)
return -ENOMEM;
Expand All @@ -2392,13 +2399,13 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
* to wait on real async I/O requests, so we must submit this request
* synchronously.
*/
if (!is_sync_kiocb(iocb) && (offset + count > i_size) && rw == WRITE)
if (!is_sync_kiocb(iocb) && (offset + count > i_size))
io->async = false;

if (rw == WRITE)
ret = __fuse_direct_write(io, iov, nr_segs, &pos);
else
ret = __fuse_direct_read(io, iov, nr_segs, &pos);
ret = __fuse_direct_read(io, iov, nr_segs, &pos, count);

if (io->async) {
fuse_aio_complete(io, ret < 0 ? ret : 0, -1);
Expand Down

0 comments on commit e09702d

Please sign in to comment.