Skip to content

Commit

Permalink
fs/affs/file.c: add support to O_DIRECT
Browse files Browse the repository at this point in the history
Based on ext2_direct_IO

Tested with O_DIRECT file open and sysbench/mariadb with 1% written
queries improvement (update_non_index test) on a volume created with
mkaffs.

Signed-off-by: Fabian Frederick <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Fabian Frederick authored and torvalds committed Dec 13, 2014
1 parent 1ee54b0 commit 9abb408
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions fs/affs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* affs regular file handling primitives
*/

#include <linux/aio.h>
#include "affs.h"

#if PAGE_SIZE < 4096
Expand Down Expand Up @@ -392,6 +393,22 @@ static void affs_write_failed(struct address_space *mapping, loff_t to)
}
}

static ssize_t
affs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
loff_t offset)
{
struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret;

ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, affs_get_block);
if (ret < 0 && (rw & WRITE))
affs_write_failed(mapping, offset + count);
return ret;
}

static int affs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
Expand All @@ -418,6 +435,7 @@ const struct address_space_operations affs_aops = {
.writepage = affs_writepage,
.write_begin = affs_write_begin,
.write_end = generic_write_end,
.direct_IO = affs_direct_IO,
.bmap = _affs_bmap
};

Expand Down

0 comments on commit 9abb408

Please sign in to comment.