Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/affs/file.c: add support to O_DIRECT

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 <fabf@skynet.be>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Fabian Frederick and committed by
Linus Torvalds
9abb4083 1ee54b09

+18
+18
fs/affs/file.c
··· 12 12 * affs regular file handling primitives 13 13 */ 14 14 15 + #include <linux/aio.h> 15 16 #include "affs.h" 16 17 17 18 #if PAGE_SIZE < 4096 ··· 393 392 } 394 393 } 395 394 395 + static ssize_t 396 + affs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, 397 + loff_t offset) 398 + { 399 + struct file *file = iocb->ki_filp; 400 + struct address_space *mapping = file->f_mapping; 401 + struct inode *inode = mapping->host; 402 + size_t count = iov_iter_count(iter); 403 + ssize_t ret; 404 + 405 + ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, affs_get_block); 406 + if (ret < 0 && (rw & WRITE)) 407 + affs_write_failed(mapping, offset + count); 408 + return ret; 409 + } 410 + 396 411 static int affs_write_begin(struct file *file, struct address_space *mapping, 397 412 loff_t pos, unsigned len, unsigned flags, 398 413 struct page **pagep, void **fsdata) ··· 435 418 .writepage = affs_writepage, 436 419 .write_begin = affs_write_begin, 437 420 .write_end = generic_write_end, 421 + .direct_IO = affs_direct_IO, 438 422 .bmap = _affs_bmap 439 423 }; 440 424