Add cache-only generic file read
Subsystems (3)
RFC PATCH 1/1 Add cache-only generic file read
Hello everyone,
We're still hammering out O_DIRECT code for btrfs that doesn't go through the page cache. Until things are done, it helps to have O_DIRECT that goes through the page cache and just immediately invalidates. It doesn't give us AIO, but it is still useful for some workloads.
Btrfs has had O_DIRECT writes for a while by invalidating the cache in its own file_write. Reads are harder because filemap.c doesn't quite export enough. Rather than export things and make a btrfs read, I've made a generic cache-only read function that includes O_DIRECT invalidation.
What does everyone think of adding something like this:
-chris
include/linux/fs.h +3 -0
@@ -2203,6 +2203,9 @@ extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);extern int file_read_actor (read_descriptor_t * desc,struct page *page,unsigned long offset,unsigned long size);int generic_write_checks (struct file *file,loff_t *pos,size_t *count,int isblk);extern ssize_t generic_file_aio_read (struct kiocb *,const struct iovec *,unsigned long ,loff_t ); +extern ssize_t generic_file_cached_read (struct kiocb *iocb, +const struct iovec *iov, +unsigned long nr_segs,loff_t pos);extern ssize_t __generic_file_aio_write (struct kiocb *,const struct iovec *,unsigned long ,loff_t *);extern ssize_t generic_file_aio_write (struct kiocb *,const struct iovec *,unsigned long ,loff_t );
mm/filemap.c +79 -0
85 lines not on this page · raw message
Signature · 1 line
1.6.4.1
Quoted 1 line · Chris Mason
What does everyone think of adding something like this:
- duplicates too much of generic_file_aio_read. The patch should just change generic_file_aio_read to a small wrapper for an O_DIRECT and a buffered version, and btrfs would jsut use the buffered one directly.
- the name. We use the term buffered for pagecache I/O, not cached, e.g. generic_file_buffered_write.
- not sure if the invalidations around the core buffered helper are generic anough to put them into filemap.c. I'd just put them into btrfs for now, although that part isn't too important.