diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2008-07-11 19:27:31 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-07-11 19:27:31 -0400 |
commit | 2e9ee850355593e311d9a26542290fe51e152f74 (patch) | |
tree | e860a33119edf36e367ad354428dfc0d6201273c /fs/ext4/file.c | |
parent | 93e3270c87549dc531a0b0e5d06362d998d810cb (diff) |
ext4: Use page_mkwrite vma_operations to get mmap write notification.
We would like to get notified when we are doing a write on mmap section.
This is needed with respect to preallocated area. We split the preallocated
area into initialzed extent and uninitialzed extent in the call back. This
let us handle ENOSPC better. Otherwise we get ENOSPC in the writepage and
that would result in data loss. The changes are also needed to handle ENOSPC
when writing to an mmap section of files with holes.
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r-- | fs/ext4/file.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 4159be6366ab..b9510ba66a2d 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -123,6 +123,23 @@ force_commit: | |||
123 | return ret; | 123 | return ret; |
124 | } | 124 | } |
125 | 125 | ||
126 | static struct vm_operations_struct ext4_file_vm_ops = { | ||
127 | .fault = filemap_fault, | ||
128 | .page_mkwrite = ext4_page_mkwrite, | ||
129 | }; | ||
130 | |||
131 | static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) | ||
132 | { | ||
133 | struct address_space *mapping = file->f_mapping; | ||
134 | |||
135 | if (!mapping->a_ops->readpage) | ||
136 | return -ENOEXEC; | ||
137 | file_accessed(file); | ||
138 | vma->vm_ops = &ext4_file_vm_ops; | ||
139 | vma->vm_flags |= VM_CAN_NONLINEAR; | ||
140 | return 0; | ||
141 | } | ||
142 | |||
126 | const struct file_operations ext4_file_operations = { | 143 | const struct file_operations ext4_file_operations = { |
127 | .llseek = generic_file_llseek, | 144 | .llseek = generic_file_llseek, |
128 | .read = do_sync_read, | 145 | .read = do_sync_read, |
@@ -133,7 +150,7 @@ const struct file_operations ext4_file_operations = { | |||
133 | #ifdef CONFIG_COMPAT | 150 | #ifdef CONFIG_COMPAT |
134 | .compat_ioctl = ext4_compat_ioctl, | 151 | .compat_ioctl = ext4_compat_ioctl, |
135 | #endif | 152 | #endif |
136 | .mmap = generic_file_mmap, | 153 | .mmap = ext4_file_mmap, |
137 | .open = generic_file_open, | 154 | .open = generic_file_open, |
138 | .release = ext4_release_file, | 155 | .release = ext4_release_file, |
139 | .fsync = ext4_sync_file, | 156 | .fsync = ext4_sync_file, |