aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-02-17 11:38:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-17 11:38:30 -0500
commitc397f8fa4379040bada53256c848e62c8b060392 (patch)
tree8101efb5c0c3b0a73e5e65f3474843c0914cc4d0 /fs/ext4/file.c
parent796e1c55717e9a6ff5c81b12289ffa1ffd919b6f (diff)
parentaaaf5fbf56f16c81a653713cc333b18ad6e25ea9 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge fifth set of updates from Andrew Morton: - A few things which were awaiting merges from linux-next: - rtc - ocfs2 - misc others - Willy's "dax" feature: direct fs access to memory (mainly NV-DIMMs) which isn't backed by pageframes. * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (37 commits) rtc: add driver for DS1685 family of real time clocks MAINTAINERS: add entry for Maxim PMICs on Samsung boards lib/Kconfig: use bool instead of boolean powerpc: drop _PAGE_FILE and pte_file()-related helpers ocfs2: set append dio as a ro compat feature ocfs2: wait for orphan recovery first once append O_DIRECT write crash ocfs2: complete the rest request through buffer io ocfs2: do not fallback to buffer I/O write if appending ocfs2: allocate blocks in ocfs2_direct_IO_get_blocks ocfs2: implement ocfs2_direct_IO_write ocfs2: add orphan recovery types in ocfs2_recover_orphans ocfs2: add functions to add and remove inode in orphan dir ocfs2: prepare some interfaces used in append direct io MAINTAINERS: fix spelling mistake & remove trailing WS dax: does not work correctly with virtual aliasing caches brd: rename XIP to DAX ext4: add DAX functionality dax: add dax_zero_page_range ext2: get rid of most mentions of XIP in ext2 ext2: remove ext2_aops_xip ...
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r--fs/ext4/file.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 7cb592386121..33a09da16c9c 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -95,7 +95,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
95 struct inode *inode = file_inode(iocb->ki_filp); 95 struct inode *inode = file_inode(iocb->ki_filp);
96 struct mutex *aio_mutex = NULL; 96 struct mutex *aio_mutex = NULL;
97 struct blk_plug plug; 97 struct blk_plug plug;
98 int o_direct = file->f_flags & O_DIRECT; 98 int o_direct = io_is_direct(file);
99 int overwrite = 0; 99 int overwrite = 0;
100 size_t length = iov_iter_count(from); 100 size_t length = iov_iter_count(from);
101 ssize_t ret; 101 ssize_t ret;
@@ -191,6 +191,26 @@ errout:
191 return ret; 191 return ret;
192} 192}
193 193
194#ifdef CONFIG_FS_DAX
195static int ext4_dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
196{
197 return dax_fault(vma, vmf, ext4_get_block);
198 /* Is this the right get_block? */
199}
200
201static int ext4_dax_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
202{
203 return dax_mkwrite(vma, vmf, ext4_get_block);
204}
205
206static const struct vm_operations_struct ext4_dax_vm_ops = {
207 .fault = ext4_dax_fault,
208 .page_mkwrite = ext4_dax_mkwrite,
209};
210#else
211#define ext4_dax_vm_ops ext4_file_vm_ops
212#endif
213
194static const struct vm_operations_struct ext4_file_vm_ops = { 214static const struct vm_operations_struct ext4_file_vm_ops = {
195 .fault = filemap_fault, 215 .fault = filemap_fault,
196 .map_pages = filemap_map_pages, 216 .map_pages = filemap_map_pages,
@@ -200,7 +220,12 @@ static const struct vm_operations_struct ext4_file_vm_ops = {
200static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) 220static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
201{ 221{
202 file_accessed(file); 222 file_accessed(file);
203 vma->vm_ops = &ext4_file_vm_ops; 223 if (IS_DAX(file_inode(file))) {
224 vma->vm_ops = &ext4_dax_vm_ops;
225 vma->vm_flags |= VM_MIXEDMAP;
226 } else {
227 vma->vm_ops = &ext4_file_vm_ops;
228 }
204 return 0; 229 return 0;
205} 230}
206 231
@@ -599,6 +624,26 @@ const struct file_operations ext4_file_operations = {
599 .fallocate = ext4_fallocate, 624 .fallocate = ext4_fallocate,
600}; 625};
601 626
627#ifdef CONFIG_FS_DAX
628const struct file_operations ext4_dax_file_operations = {
629 .llseek = ext4_llseek,
630 .read = new_sync_read,
631 .write = new_sync_write,
632 .read_iter = generic_file_read_iter,
633 .write_iter = ext4_file_write_iter,
634 .unlocked_ioctl = ext4_ioctl,
635#ifdef CONFIG_COMPAT
636 .compat_ioctl = ext4_compat_ioctl,
637#endif
638 .mmap = ext4_file_mmap,
639 .open = ext4_file_open,
640 .release = ext4_release_file,
641 .fsync = ext4_sync_file,
642 /* Splice not yet supported with DAX */
643 .fallocate = ext4_fallocate,
644};
645#endif
646
602const struct inode_operations ext4_file_inode_operations = { 647const struct inode_operations ext4_file_inode_operations = {
603 .setattr = ext4_setattr, 648 .setattr = ext4_setattr,
604 .getattr = ext4_getattr, 649 .getattr = ext4_getattr,