blob: 3035c791d934355989f796c812f7fb5361133705 [file] [log] [blame]
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +09001/*
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +09002 * fs/f2fs/file.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/fs.h>
12#include <linux/f2fs_fs.h>
13#include <linux/stat.h>
14#include <linux/buffer_head.h>
15#include <linux/writeback.h>
Jaegeuk Kimae51fb32013-03-16 11:13:04 +090016#include <linux/blkdev.h>
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090017#include <linux/falloc.h>
18#include <linux/types.h>
Namjae Jeone9750822013-02-04 23:41:41 +090019#include <linux/compat.h>
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090020#include <linux/uaccess.h>
21#include <linux/mount.h>
Jaegeuk Kim7f7670f2014-04-28 18:12:36 +090022#include <linux/pagevec.h>
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090023
24#include "f2fs.h"
25#include "node.h"
26#include "segment.h"
27#include "xattr.h"
28#include "acl.h"
Namjae Jeona2a4a7e2013-04-20 01:28:40 +090029#include <trace/events/f2fs.h>
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090030
31static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
32 struct vm_fault *vmf)
33{
34 struct page *page = vmf->page;
Al Viro6131ffa2013-02-27 16:59:05 -050035 struct inode *inode = file_inode(vma->vm_file);
Jaegeuk Kim40813632014-09-02 15:31:18 -070036 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090037 struct dnode_of_data dn;
Gu Zhenge4795562013-09-27 18:08:30 +080038 int err;
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090039
40 f2fs_balance_fs(sbi);
41
42 sb_start_pagefault(inode->i_sb);
43
Jaegeuk Kimb067ba1f2014-08-07 16:32:25 -070044 /* force to convert with normal data indices */
45 err = f2fs_convert_inline_data(inode, MAX_INLINE_DATA + 1, page);
46 if (err)
47 goto out;
48
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090049 /* block allocation */
Gu Zhenge4795562013-09-27 18:08:30 +080050 f2fs_lock_op(sbi);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090051 set_new_dnode(&dn, inode, NULL, NULL, 0);
Huajun Lib6009652013-11-10 23:13:18 +080052 err = f2fs_reserve_block(&dn, page->index);
Gu Zhenge4795562013-09-27 18:08:30 +080053 f2fs_unlock_op(sbi);
Huajun Lib6009652013-11-10 23:13:18 +080054 if (err)
55 goto out;
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090056
Namjae Jeon9851e6e2013-04-28 09:04:18 +090057 file_update_time(vma->vm_file);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090058 lock_page(page);
Jaegeuk Kim6bacf522013-12-06 15:00:58 +090059 if (unlikely(page->mapping != inode->i_mapping ||
Namjae Jeon9851e6e2013-04-28 09:04:18 +090060 page_offset(page) > i_size_read(inode) ||
Jaegeuk Kim6bacf522013-12-06 15:00:58 +090061 !PageUptodate(page))) {
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090062 unlock_page(page);
63 err = -EFAULT;
64 goto out;
65 }
66
67 /*
68 * check to see if the page is mapped already (no holes)
69 */
70 if (PageMappedToDisk(page))
Namjae Jeon9851e6e2013-04-28 09:04:18 +090071 goto mapped;
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090072
73 /* page is wholly or partially inside EOF */
74 if (((page->index + 1) << PAGE_CACHE_SHIFT) > i_size_read(inode)) {
75 unsigned offset;
76 offset = i_size_read(inode) & ~PAGE_CACHE_MASK;
77 zero_user_segment(page, offset, PAGE_CACHE_SIZE);
78 }
79 set_page_dirty(page);
80 SetPageUptodate(page);
81
Jaegeuk Kime943a102013-10-25 14:26:31 +090082 trace_f2fs_vm_page_mkwrite(page, DATA);
Namjae Jeon9851e6e2013-04-28 09:04:18 +090083mapped:
84 /* fill the page */
Jaegeuk Kim3cb5ad12014-03-18 13:29:07 +090085 f2fs_wait_on_page_writeback(page, DATA);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090086out:
87 sb_end_pagefault(inode->i_sb);
88 return block_page_mkwrite_return(err);
89}
90
91static const struct vm_operations_struct f2fs_file_vm_ops = {
Jaegeuk Kim692bb552013-01-17 18:37:41 +090092 .fault = filemap_fault,
Kirill A. Shutemovf1820362014-04-07 15:37:19 -070093 .map_pages = filemap_map_pages,
Jaegeuk Kim692bb552013-01-17 18:37:41 +090094 .page_mkwrite = f2fs_vm_page_mkwrite,
95 .remap_pages = generic_file_remap_pages,
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +090096};
97
Jaegeuk Kim354a3392013-06-14 08:52:35 +090098static int get_parent_ino(struct inode *inode, nid_t *pino)
99{
100 struct dentry *dentry;
101
102 inode = igrab(inode);
103 dentry = d_find_any_alias(inode);
104 iput(inode);
105 if (!dentry)
106 return 0;
107
Jaegeuk Kimf0947e52013-07-22 22:12:56 +0900108 if (update_dent_inode(inode, &dentry->d_name)) {
109 dput(dentry);
110 return 0;
111 }
Jaegeuk Kim354a3392013-06-14 08:52:35 +0900112
Jaegeuk Kimf0947e52013-07-22 22:12:56 +0900113 *pino = parent_ino(dentry);
114 dput(dentry);
Jaegeuk Kim354a3392013-06-14 08:52:35 +0900115 return 1;
116}
117
Chao Yu9d1589e2014-08-20 18:37:35 +0800118static inline bool need_do_checkpoint(struct inode *inode)
119{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700120 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Chao Yu9d1589e2014-08-20 18:37:35 +0800121 bool need_cp = false;
122
123 if (!S_ISREG(inode->i_mode) || inode->i_nlink != 1)
124 need_cp = true;
125 else if (file_wrong_pino(inode))
126 need_cp = true;
127 else if (!space_for_roll_forward(sbi))
128 need_cp = true;
129 else if (!is_checkpointed_node(sbi, F2FS_I(inode)->i_pino))
130 need_cp = true;
131 else if (F2FS_I(inode)->xattr_ver == cur_cp_version(F2FS_CKPT(sbi)))
132 need_cp = true;
133
134 return need_cp;
135}
136
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900137int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
138{
139 struct inode *inode = file->f_mapping->host;
Jaegeuk Kimd928bfb2014-03-20 19:10:08 +0900140 struct f2fs_inode_info *fi = F2FS_I(inode);
Jaegeuk Kim40813632014-09-02 15:31:18 -0700141 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kim2403c152014-09-10 14:58:18 -0700142 nid_t ino = inode->i_ino;
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900143 int ret = 0;
144 bool need_cp = false;
145 struct writeback_control wbc = {
Jaegeuk Kimc81bf1c2014-03-03 11:28:40 +0900146 .sync_mode = WB_SYNC_ALL,
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900147 .nr_to_write = LONG_MAX,
148 .for_reclaim = 0,
149 };
150
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900151 if (unlikely(f2fs_readonly(inode->i_sb)))
Namjae Jeon1fa95b02012-12-01 10:56:01 +0900152 return 0;
153
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900154 trace_f2fs_sync_file_enter(inode);
Jaegeuk Kimea1aa122014-07-24 19:11:43 -0700155
156 /* if fdatasync is triggered, let's do in-place-update */
Jaegeuk Kimc1ce1b02014-09-10 16:53:02 -0700157 if (get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)
Jaegeuk Kimea1aa122014-07-24 19:11:43 -0700158 set_inode_flag(fi, FI_NEED_IPU);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900159 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
Jaegeuk Kimc1ce1b02014-09-10 16:53:02 -0700160 clear_inode_flag(fi, FI_NEED_IPU);
161
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900162 if (ret) {
163 trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900164 return ret;
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900165 }
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900166
Jaegeuk Kim6d99ba412014-07-24 19:08:02 -0700167 /*
168 * if there is no written data, don't waste time to write recovery info.
169 */
170 if (!is_inode_flag_set(fi, FI_APPEND_WRITE) &&
Jaegeuk Kim2403c152014-09-10 14:58:18 -0700171 !exist_written_data(sbi, ino, APPEND_INO)) {
Jaegeuk Kim6d99ba412014-07-24 19:08:02 -0700172 if (is_inode_flag_set(fi, FI_UPDATE_WRITE) ||
Jaegeuk Kim2403c152014-09-10 14:58:18 -0700173 exist_written_data(sbi, ino, UPDATE_INO))
Jaegeuk Kim6d99ba412014-07-24 19:08:02 -0700174 goto flush_out;
175 goto out;
176 }
177
Jaegeuk Kim7d82db82013-01-11 13:10:49 +0900178 /* guarantee free sections for fsync */
179 f2fs_balance_fs(sbi);
180
Jaegeuk Kime5d23852013-07-03 10:55:52 +0900181 /*
182 * Both of fdatasync() and fsync() are able to be recovered from
183 * sudden-power-off.
184 */
Chao Yu9d1589e2014-08-20 18:37:35 +0800185 down_read(&fi->i_sem);
186 need_cp = need_do_checkpoint(inode);
Jaegeuk Kimd928bfb2014-03-20 19:10:08 +0900187 up_read(&fi->i_sem);
188
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900189 if (need_cp) {
Jaegeuk Kim354a3392013-06-14 08:52:35 +0900190 nid_t pino;
191
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900192 /* all the dirty node pages should be flushed for POR */
193 ret = f2fs_sync_fs(inode->i_sb, 1);
Jaegeuk Kimd928bfb2014-03-20 19:10:08 +0900194
195 down_write(&fi->i_sem);
196 F2FS_I(inode)->xattr_ver = 0;
Jaegeuk Kim354a3392013-06-14 08:52:35 +0900197 if (file_wrong_pino(inode) && inode->i_nlink == 1 &&
198 get_parent_ino(inode, &pino)) {
199 F2FS_I(inode)->i_pino = pino;
200 file_got_pino(inode);
Jaegeuk Kimd928bfb2014-03-20 19:10:08 +0900201 up_write(&fi->i_sem);
Jaegeuk Kim354a3392013-06-14 08:52:35 +0900202 mark_inode_dirty_sync(inode);
203 ret = f2fs_write_inode(inode, NULL);
204 if (ret)
205 goto out;
Jaegeuk Kimd928bfb2014-03-20 19:10:08 +0900206 } else {
207 up_write(&fi->i_sem);
Jaegeuk Kim354a3392013-06-14 08:52:35 +0900208 }
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900209 } else {
Jaegeuk Kim88bd02c2014-09-15 14:50:48 -0700210sync_nodes:
211 sync_node_pages(sbi, ino, &wbc);
212
213 if (need_inode_block_update(sbi, ino)) {
Jaegeuk Kimb3783872013-06-10 09:17:01 +0900214 mark_inode_dirty_sync(inode);
Jaegeuk Kim398b1ac2012-12-19 15:28:39 +0900215 ret = f2fs_write_inode(inode, NULL);
216 if (ret)
217 goto out;
Jaegeuk Kim88bd02c2014-09-15 14:50:48 -0700218 goto sync_nodes;
Jaegeuk Kim398b1ac2012-12-19 15:28:39 +0900219 }
Jaegeuk Kim88bd02c2014-09-15 14:50:48 -0700220
Jaegeuk Kim2403c152014-09-10 14:58:18 -0700221 ret = wait_on_node_pages_writeback(sbi, ino);
Jaegeuk Kimcfe58f92013-10-31 14:57:01 +0900222 if (ret)
223 goto out;
Jaegeuk Kim6d99ba412014-07-24 19:08:02 -0700224
225 /* once recovery info is written, don't need to tack this */
Jaegeuk Kim2403c152014-09-10 14:58:18 -0700226 remove_dirty_inode(sbi, ino, APPEND_INO);
Jaegeuk Kim6d99ba412014-07-24 19:08:02 -0700227 clear_inode_flag(fi, FI_APPEND_WRITE);
228flush_out:
Jaegeuk Kim2403c152014-09-10 14:58:18 -0700229 remove_dirty_inode(sbi, ino, UPDATE_INO);
Jaegeuk Kim6d99ba412014-07-24 19:08:02 -0700230 clear_inode_flag(fi, FI_UPDATE_WRITE);
Jaegeuk Kim40813632014-09-02 15:31:18 -0700231 ret = f2fs_issue_flush(F2FS_I_SB(inode));
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900232 }
233out:
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900234 trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900235 return ret;
236}
237
Jaegeuk Kim7f7670f2014-04-28 18:12:36 +0900238static pgoff_t __get_first_dirty_index(struct address_space *mapping,
239 pgoff_t pgofs, int whence)
240{
241 struct pagevec pvec;
242 int nr_pages;
243
244 if (whence != SEEK_DATA)
245 return 0;
246
247 /* find first dirty page index */
248 pagevec_init(&pvec, 0);
Jaegeuk Kim65b85cc2014-07-30 17:25:54 -0700249 nr_pages = pagevec_lookup_tag(&pvec, mapping, &pgofs,
250 PAGECACHE_TAG_DIRTY, 1);
251 pgofs = nr_pages ? pvec.pages[0]->index : LONG_MAX;
Jaegeuk Kim7f7670f2014-04-28 18:12:36 +0900252 pagevec_release(&pvec);
253 return pgofs;
254}
255
256static bool __found_offset(block_t blkaddr, pgoff_t dirty, pgoff_t pgofs,
257 int whence)
258{
259 switch (whence) {
260 case SEEK_DATA:
261 if ((blkaddr == NEW_ADDR && dirty == pgofs) ||
262 (blkaddr != NEW_ADDR && blkaddr != NULL_ADDR))
263 return true;
264 break;
265 case SEEK_HOLE:
266 if (blkaddr == NULL_ADDR)
267 return true;
268 break;
269 }
270 return false;
271}
272
Chao Yu267378d2014-04-23 14:10:24 +0800273static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
274{
275 struct inode *inode = file->f_mapping->host;
276 loff_t maxbytes = inode->i_sb->s_maxbytes;
277 struct dnode_of_data dn;
Jaegeuk Kim7f7670f2014-04-28 18:12:36 +0900278 pgoff_t pgofs, end_offset, dirty;
279 loff_t data_ofs = offset;
280 loff_t isize;
Chao Yu267378d2014-04-23 14:10:24 +0800281 int err = 0;
282
283 mutex_lock(&inode->i_mutex);
284
285 isize = i_size_read(inode);
286 if (offset >= isize)
287 goto fail;
288
289 /* handle inline data case */
290 if (f2fs_has_inline_data(inode)) {
291 if (whence == SEEK_HOLE)
292 data_ofs = isize;
293 goto found;
294 }
295
296 pgofs = (pgoff_t)(offset >> PAGE_CACHE_SHIFT);
297
Jaegeuk Kim7f7670f2014-04-28 18:12:36 +0900298 dirty = __get_first_dirty_index(inode->i_mapping, pgofs, whence);
299
Chao Yu267378d2014-04-23 14:10:24 +0800300 for (; data_ofs < isize; data_ofs = pgofs << PAGE_CACHE_SHIFT) {
301 set_new_dnode(&dn, inode, NULL, NULL, 0);
302 err = get_dnode_of_data(&dn, pgofs, LOOKUP_NODE_RA);
303 if (err && err != -ENOENT) {
304 goto fail;
305 } else if (err == -ENOENT) {
arter97e1c42042014-08-06 23:22:50 +0900306 /* direct node does not exists */
Chao Yu267378d2014-04-23 14:10:24 +0800307 if (whence == SEEK_DATA) {
308 pgofs = PGOFS_OF_NEXT_DNODE(pgofs,
309 F2FS_I(inode));
310 continue;
311 } else {
312 goto found;
313 }
314 }
315
Chao Yu6b2920a2014-07-07 11:21:59 +0800316 end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));
Chao Yu267378d2014-04-23 14:10:24 +0800317
318 /* find data/hole in dnode block */
319 for (; dn.ofs_in_node < end_offset;
320 dn.ofs_in_node++, pgofs++,
321 data_ofs = pgofs << PAGE_CACHE_SHIFT) {
322 block_t blkaddr;
323 blkaddr = datablock_addr(dn.node_page, dn.ofs_in_node);
324
Jaegeuk Kim7f7670f2014-04-28 18:12:36 +0900325 if (__found_offset(blkaddr, dirty, pgofs, whence)) {
Chao Yu267378d2014-04-23 14:10:24 +0800326 f2fs_put_dnode(&dn);
327 goto found;
328 }
329 }
330 f2fs_put_dnode(&dn);
331 }
332
333 if (whence == SEEK_DATA)
334 goto fail;
Chao Yu267378d2014-04-23 14:10:24 +0800335found:
Jaegeuk Kimfe369bc2014-04-28 17:02:48 +0900336 if (whence == SEEK_HOLE && data_ofs > isize)
337 data_ofs = isize;
Chao Yu267378d2014-04-23 14:10:24 +0800338 mutex_unlock(&inode->i_mutex);
339 return vfs_setpos(file, data_ofs, maxbytes);
340fail:
341 mutex_unlock(&inode->i_mutex);
342 return -ENXIO;
343}
344
345static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
346{
347 struct inode *inode = file->f_mapping->host;
348 loff_t maxbytes = inode->i_sb->s_maxbytes;
349
350 switch (whence) {
351 case SEEK_SET:
352 case SEEK_CUR:
353 case SEEK_END:
354 return generic_file_llseek_size(file, offset, whence,
355 maxbytes, i_size_read(inode));
356 case SEEK_DATA:
357 case SEEK_HOLE:
Jaegeuk Kim0b4c5afde2014-09-08 10:59:43 -0700358 if (offset < 0)
359 return -ENXIO;
Chao Yu267378d2014-04-23 14:10:24 +0800360 return f2fs_seek_block(file, offset, whence);
361 }
362
363 return -EINVAL;
364}
365
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900366static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
367{
368 file_accessed(file);
369 vma->vm_ops = &f2fs_file_vm_ops;
370 return 0;
371}
372
Jaegeuk Kimb292dcab2013-05-22 08:02:02 +0900373int truncate_data_blocks_range(struct dnode_of_data *dn, int count)
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900374{
375 int nr_free = 0, ofs = dn->ofs_in_node;
Jaegeuk Kim40813632014-09-02 15:31:18 -0700376 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900377 struct f2fs_node *raw_node;
378 __le32 *addr;
379
Gu Zheng45590712013-07-15 17:57:38 +0800380 raw_node = F2FS_NODE(dn->node_page);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900381 addr = blkaddr_in_node(raw_node) + ofs;
382
Chris Fries6c311ec2014-01-17 14:44:39 -0600383 for (; count > 0; count--, addr++, dn->ofs_in_node++) {
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900384 block_t blkaddr = le32_to_cpu(*addr);
385 if (blkaddr == NULL_ADDR)
386 continue;
387
388 update_extent_cache(NULL_ADDR, dn);
389 invalidate_blocks(sbi, blkaddr);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900390 nr_free++;
391 }
392 if (nr_free) {
Namjae Jeond7cc9502013-06-08 21:25:40 +0900393 dec_valid_block_count(sbi, dn->inode, nr_free);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900394 set_page_dirty(dn->node_page);
395 sync_inode_page(dn);
396 }
397 dn->ofs_in_node = ofs;
Namjae Jeon51dd6242013-04-20 01:28:52 +0900398
399 trace_f2fs_truncate_data_blocks_range(dn->inode, dn->nid,
400 dn->ofs_in_node, nr_free);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900401 return nr_free;
402}
403
404void truncate_data_blocks(struct dnode_of_data *dn)
405{
406 truncate_data_blocks_range(dn, ADDRS_PER_BLOCK);
407}
408
409static void truncate_partial_data_page(struct inode *inode, u64 from)
410{
411 unsigned offset = from & (PAGE_CACHE_SIZE - 1);
412 struct page *page;
413
Chao Yu8aa6f1c2014-04-29 09:03:03 +0800414 if (f2fs_has_inline_data(inode))
415 return truncate_inline_data(inode, from);
416
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900417 if (!offset)
418 return;
419
Jaegeuk Kimc718379b2013-04-24 13:19:56 +0900420 page = find_data_page(inode, from >> PAGE_CACHE_SHIFT, false);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900421 if (IS_ERR(page))
422 return;
423
424 lock_page(page);
Chao Yuca0a81b2014-06-12 13:31:50 +0800425 if (unlikely(!PageUptodate(page) ||
426 page->mapping != inode->i_mapping))
427 goto out;
428
Jaegeuk Kim3cb5ad12014-03-18 13:29:07 +0900429 f2fs_wait_on_page_writeback(page, DATA);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900430 zero_user(page, offset, PAGE_CACHE_SIZE - offset);
431 set_page_dirty(page);
Chao Yuca0a81b2014-06-12 13:31:50 +0800432
433out:
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900434 f2fs_put_page(page, 1);
435}
436
Jaegeuk Kim764aa3e2014-08-14 16:32:54 -0700437int truncate_blocks(struct inode *inode, u64 from, bool lock)
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900438{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700439 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900440 unsigned int blocksize = inode->i_sb->s_blocksize;
441 struct dnode_of_data dn;
442 pgoff_t free_from;
Huajun Li9ffe0fb2013-11-10 23:13:20 +0800443 int count = 0, err = 0;
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900444
Namjae Jeon51dd6242013-04-20 01:28:52 +0900445 trace_f2fs_truncate_blocks_enter(inode, from);
446
Jaegeuk Kimf185ff92013-12-27 11:01:54 +0900447 if (f2fs_has_inline_data(inode))
448 goto done;
449
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900450 free_from = (pgoff_t)
451 ((from + blocksize - 1) >> (sbi->log_blocksize));
452
Jaegeuk Kim764aa3e2014-08-14 16:32:54 -0700453 if (lock)
454 f2fs_lock_op(sbi);
Huajun Li9ffe0fb2013-11-10 23:13:20 +0800455
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900456 set_new_dnode(&dn, inode, NULL, NULL, 0);
Jaegeuk Kim266e97a2013-02-26 13:10:46 +0900457 err = get_dnode_of_data(&dn, free_from, LOOKUP_NODE);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900458 if (err) {
459 if (err == -ENOENT)
460 goto free_next;
Jaegeuk Kim764aa3e2014-08-14 16:32:54 -0700461 if (lock)
462 f2fs_unlock_op(sbi);
Namjae Jeon51dd6242013-04-20 01:28:52 +0900463 trace_f2fs_truncate_blocks_exit(inode, err);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900464 return err;
465 }
466
Chao Yu6403eb12014-04-26 19:59:52 +0800467 count = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900468
469 count -= dn.ofs_in_node;
Jaegeuk Kim9850cf42014-09-02 15:52:58 -0700470 f2fs_bug_on(sbi, count < 0);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900471
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900472 if (dn.ofs_in_node || IS_INODE(dn.node_page)) {
473 truncate_data_blocks_range(&dn, count);
474 free_from += count;
475 }
476
477 f2fs_put_dnode(&dn);
478free_next:
479 err = truncate_inode_blocks(inode, free_from);
Jaegeuk Kim764aa3e2014-08-14 16:32:54 -0700480 if (lock)
481 f2fs_unlock_op(sbi);
Jaegeuk Kimf185ff92013-12-27 11:01:54 +0900482done:
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900483 /* lastly zero out the first data page */
484 truncate_partial_data_page(inode, from);
485
Namjae Jeon51dd6242013-04-20 01:28:52 +0900486 trace_f2fs_truncate_blocks_exit(inode, err);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900487 return err;
488}
489
490void f2fs_truncate(struct inode *inode)
491{
492 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
493 S_ISLNK(inode->i_mode)))
494 return;
495
Namjae Jeon51dd6242013-04-20 01:28:52 +0900496 trace_f2fs_truncate(inode);
497
Jaegeuk Kim764aa3e2014-08-14 16:32:54 -0700498 if (!truncate_blocks(inode, i_size_read(inode), true)) {
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900499 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
500 mark_inode_dirty(inode);
501 }
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900502}
503
Jaegeuk Kim2d4d9fb52013-06-07 16:33:07 +0900504int f2fs_getattr(struct vfsmount *mnt,
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900505 struct dentry *dentry, struct kstat *stat)
506{
507 struct inode *inode = dentry->d_inode;
508 generic_fillattr(inode, stat);
509 stat->blocks <<= 3;
510 return 0;
511}
512
513#ifdef CONFIG_F2FS_FS_POSIX_ACL
514static void __setattr_copy(struct inode *inode, const struct iattr *attr)
515{
516 struct f2fs_inode_info *fi = F2FS_I(inode);
517 unsigned int ia_valid = attr->ia_valid;
518
519 if (ia_valid & ATTR_UID)
520 inode->i_uid = attr->ia_uid;
521 if (ia_valid & ATTR_GID)
522 inode->i_gid = attr->ia_gid;
523 if (ia_valid & ATTR_ATIME)
524 inode->i_atime = timespec_trunc(attr->ia_atime,
525 inode->i_sb->s_time_gran);
526 if (ia_valid & ATTR_MTIME)
527 inode->i_mtime = timespec_trunc(attr->ia_mtime,
528 inode->i_sb->s_time_gran);
529 if (ia_valid & ATTR_CTIME)
530 inode->i_ctime = timespec_trunc(attr->ia_ctime,
531 inode->i_sb->s_time_gran);
532 if (ia_valid & ATTR_MODE) {
533 umode_t mode = attr->ia_mode;
534
535 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
536 mode &= ~S_ISGID;
537 set_acl_inode(fi, mode);
538 }
539}
540#else
541#define __setattr_copy setattr_copy
542#endif
543
544int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
545{
546 struct inode *inode = dentry->d_inode;
547 struct f2fs_inode_info *fi = F2FS_I(inode);
548 int err;
549
550 err = inode_change_ok(inode, attr);
551 if (err)
552 return err;
553
554 if ((attr->ia_valid & ATTR_SIZE) &&
555 attr->ia_size != i_size_read(inode)) {
Jaegeuk Kimb067ba1f2014-08-07 16:32:25 -0700556 err = f2fs_convert_inline_data(inode, attr->ia_size, NULL);
Jaegeuk Kim9e09fc82013-12-27 12:28:59 +0900557 if (err)
558 return err;
Huajun Li9ffe0fb2013-11-10 23:13:20 +0800559
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900560 truncate_setsize(inode, attr->ia_size);
Jaegeuk Kim9e09fc82013-12-27 12:28:59 +0900561 f2fs_truncate(inode);
Jaegeuk Kim40813632014-09-02 15:31:18 -0700562 f2fs_balance_fs(F2FS_I_SB(inode));
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900563 }
564
565 __setattr_copy(inode, attr);
566
567 if (attr->ia_valid & ATTR_MODE) {
Christoph Hellwiga6dda0e2013-12-20 05:16:45 -0800568 err = posix_acl_chmod(inode, get_inode_mode(inode));
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900569 if (err || is_inode_flag_set(fi, FI_ACL_MODE)) {
570 inode->i_mode = fi->i_acl_mode;
571 clear_inode_flag(fi, FI_ACL_MODE);
572 }
573 }
574
575 mark_inode_dirty(inode);
576 return err;
577}
578
579const struct inode_operations f2fs_file_inode_operations = {
580 .getattr = f2fs_getattr,
581 .setattr = f2fs_setattr,
582 .get_acl = f2fs_get_acl,
Christoph Hellwiga6dda0e2013-12-20 05:16:45 -0800583 .set_acl = f2fs_set_acl,
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900584#ifdef CONFIG_F2FS_FS_XATTR
585 .setxattr = generic_setxattr,
586 .getxattr = generic_getxattr,
587 .listxattr = f2fs_listxattr,
588 .removexattr = generic_removexattr,
589#endif
Jaegeuk Kim9ab70132014-06-08 04:30:14 +0900590 .fiemap = f2fs_fiemap,
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900591};
592
593static void fill_zero(struct inode *inode, pgoff_t index,
594 loff_t start, loff_t len)
595{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700596 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900597 struct page *page;
598
599 if (!len)
600 return;
601
Jaegeuk Kimbd43df02013-01-25 18:33:41 +0900602 f2fs_balance_fs(sbi);
603
Gu Zhenge4795562013-09-27 18:08:30 +0800604 f2fs_lock_op(sbi);
Jaegeuk Kim64aa7ed2013-05-20 09:55:50 +0900605 page = get_new_data_page(inode, NULL, index, false);
Gu Zhenge4795562013-09-27 18:08:30 +0800606 f2fs_unlock_op(sbi);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900607
608 if (!IS_ERR(page)) {
Jaegeuk Kim3cb5ad12014-03-18 13:29:07 +0900609 f2fs_wait_on_page_writeback(page, DATA);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900610 zero_user(page, start, len);
611 set_page_dirty(page);
612 f2fs_put_page(page, 1);
613 }
614}
615
616int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end)
617{
618 pgoff_t index;
619 int err;
620
621 for (index = pg_start; index < pg_end; index++) {
622 struct dnode_of_data dn;
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900623
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900624 set_new_dnode(&dn, inode, NULL, NULL, 0);
Jaegeuk Kim266e97a2013-02-26 13:10:46 +0900625 err = get_dnode_of_data(&dn, index, LOOKUP_NODE);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900626 if (err) {
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900627 if (err == -ENOENT)
628 continue;
629 return err;
630 }
631
632 if (dn.data_blkaddr != NULL_ADDR)
633 truncate_data_blocks_range(&dn, 1);
634 f2fs_put_dnode(&dn);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900635 }
636 return 0;
637}
638
Chao Yua66c7b22013-11-22 16:52:50 +0800639static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900640{
641 pgoff_t pg_start, pg_end;
642 loff_t off_start, off_end;
643 int ret = 0;
644
Jaegeuk Kimb067ba1f2014-08-07 16:32:25 -0700645 ret = f2fs_convert_inline_data(inode, MAX_INLINE_DATA + 1, NULL);
Jaegeuk Kim8230a0a2013-12-27 11:13:21 +0900646 if (ret)
647 return ret;
Huajun Li9ffe0fb2013-11-10 23:13:20 +0800648
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900649 pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT;
650 pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT;
651
652 off_start = offset & (PAGE_CACHE_SIZE - 1);
653 off_end = (offset + len) & (PAGE_CACHE_SIZE - 1);
654
655 if (pg_start == pg_end) {
656 fill_zero(inode, pg_start, off_start,
657 off_end - off_start);
658 } else {
659 if (off_start)
660 fill_zero(inode, pg_start++, off_start,
661 PAGE_CACHE_SIZE - off_start);
662 if (off_end)
663 fill_zero(inode, pg_end, 0, off_end);
664
665 if (pg_start < pg_end) {
666 struct address_space *mapping = inode->i_mapping;
667 loff_t blk_start, blk_end;
Jaegeuk Kim40813632014-09-02 15:31:18 -0700668 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jason Hrycay1127a3d2013-04-08 20:16:44 -0500669
670 f2fs_balance_fs(sbi);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900671
672 blk_start = pg_start << PAGE_CACHE_SHIFT;
673 blk_end = pg_end << PAGE_CACHE_SHIFT;
674 truncate_inode_pages_range(mapping, blk_start,
675 blk_end - 1);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900676
Gu Zhenge4795562013-09-27 18:08:30 +0800677 f2fs_lock_op(sbi);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900678 ret = truncate_hole(inode, pg_start, pg_end);
Gu Zhenge4795562013-09-27 18:08:30 +0800679 f2fs_unlock_op(sbi);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900680 }
681 }
682
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900683 return ret;
684}
685
686static int expand_inode_data(struct inode *inode, loff_t offset,
687 loff_t len, int mode)
688{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700689 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900690 pgoff_t index, pg_start, pg_end;
691 loff_t new_size = i_size_read(inode);
692 loff_t off_start, off_end;
693 int ret = 0;
694
Chao Yu497a0932014-08-04 10:11:17 +0800695 f2fs_balance_fs(sbi);
696
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900697 ret = inode_newsize_ok(inode, (len + offset));
698 if (ret)
699 return ret;
700
Jaegeuk Kimb067ba1f2014-08-07 16:32:25 -0700701 ret = f2fs_convert_inline_data(inode, offset + len, NULL);
Jaegeuk Kim9e09fc82013-12-27 12:28:59 +0900702 if (ret)
703 return ret;
704
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900705 pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT;
706 pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT;
707
708 off_start = offset & (PAGE_CACHE_SIZE - 1);
709 off_end = (offset + len) & (PAGE_CACHE_SIZE - 1);
710
Jaegeuk Kimead43272014-06-13 13:05:55 +0900711 f2fs_lock_op(sbi);
712
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900713 for (index = pg_start; index <= pg_end; index++) {
714 struct dnode_of_data dn;
715
Jaegeuk Kim98397ff2014-06-13 13:07:31 +0900716 if (index == pg_end && !off_end)
717 goto noalloc;
718
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900719 set_new_dnode(&dn, inode, NULL, NULL, 0);
Huajun Lib6009652013-11-10 23:13:18 +0800720 ret = f2fs_reserve_block(&dn, index);
Huajun Lib6009652013-11-10 23:13:18 +0800721 if (ret)
722 break;
Jaegeuk Kim98397ff2014-06-13 13:07:31 +0900723noalloc:
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900724 if (pg_start == pg_end)
725 new_size = offset + len;
726 else if (index == pg_start && off_start)
727 new_size = (index + 1) << PAGE_CACHE_SHIFT;
728 else if (index == pg_end)
729 new_size = (index << PAGE_CACHE_SHIFT) + off_end;
730 else
731 new_size += PAGE_CACHE_SIZE;
732 }
733
734 if (!(mode & FALLOC_FL_KEEP_SIZE) &&
735 i_size_read(inode) < new_size) {
736 i_size_write(inode, new_size);
737 mark_inode_dirty(inode);
Jaegeuk Kimead43272014-06-13 13:05:55 +0900738 update_inode_page(inode);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900739 }
Jaegeuk Kimead43272014-06-13 13:05:55 +0900740 f2fs_unlock_op(sbi);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900741
742 return ret;
743}
744
745static long f2fs_fallocate(struct file *file, int mode,
746 loff_t offset, loff_t len)
747{
Al Viro6131ffa2013-02-27 16:59:05 -0500748 struct inode *inode = file_inode(file);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900749 long ret;
750
751 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
752 return -EOPNOTSUPP;
753
Chao Yu3375f692014-01-28 10:29:26 +0800754 mutex_lock(&inode->i_mutex);
755
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900756 if (mode & FALLOC_FL_PUNCH_HOLE)
Chao Yua66c7b22013-11-22 16:52:50 +0800757 ret = punch_hole(inode, offset, len);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900758 else
759 ret = expand_inode_data(inode, offset, len, mode);
760
Namjae Jeon3af60a42012-12-30 14:52:37 +0900761 if (!ret) {
762 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
763 mark_inode_dirty(inode);
764 }
Chao Yu3375f692014-01-28 10:29:26 +0800765
766 mutex_unlock(&inode->i_mutex);
767
Namjae Jeonc01e2852013-04-23 17:00:52 +0900768 trace_f2fs_fallocate(inode, mode, offset, len, ret);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900769 return ret;
770}
771
772#define F2FS_REG_FLMASK (~(FS_DIRSYNC_FL | FS_TOPDIR_FL))
773#define F2FS_OTHER_FLMASK (FS_NODUMP_FL | FS_NOATIME_FL)
774
775static inline __u32 f2fs_mask_flags(umode_t mode, __u32 flags)
776{
777 if (S_ISDIR(mode))
778 return flags;
779 else if (S_ISREG(mode))
780 return flags & F2FS_REG_FLMASK;
781 else
782 return flags & F2FS_OTHER_FLMASK;
783}
784
785long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
786{
Al Viro6131ffa2013-02-27 16:59:05 -0500787 struct inode *inode = file_inode(filp);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900788 struct f2fs_inode_info *fi = F2FS_I(inode);
789 unsigned int flags;
790 int ret;
791
792 switch (cmd) {
Namjae Jeon6a3e8ef2013-06-08 21:25:28 +0900793 case F2FS_IOC_GETFLAGS:
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900794 flags = fi->i_flags & FS_FL_USER_VISIBLE;
795 return put_user(flags, (int __user *) arg);
Namjae Jeon6a3e8ef2013-06-08 21:25:28 +0900796 case F2FS_IOC_SETFLAGS:
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900797 {
798 unsigned int oldflags;
799
Al Virobdaec332013-03-20 09:33:23 -0400800 ret = mnt_want_write_file(filp);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900801 if (ret)
802 return ret;
803
804 if (!inode_owner_or_capable(inode)) {
805 ret = -EACCES;
806 goto out;
807 }
808
809 if (get_user(flags, (int __user *) arg)) {
810 ret = -EFAULT;
811 goto out;
812 }
813
814 flags = f2fs_mask_flags(inode->i_mode, flags);
815
816 mutex_lock(&inode->i_mutex);
817
818 oldflags = fi->i_flags;
819
820 if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
821 if (!capable(CAP_LINUX_IMMUTABLE)) {
822 mutex_unlock(&inode->i_mutex);
823 ret = -EPERM;
824 goto out;
825 }
826 }
827
828 flags = flags & FS_FL_USER_MODIFIABLE;
829 flags |= oldflags & ~FS_FL_USER_MODIFIABLE;
830 fi->i_flags = flags;
831 mutex_unlock(&inode->i_mutex);
832
833 f2fs_set_inode_flags(inode);
834 inode->i_ctime = CURRENT_TIME;
835 mark_inode_dirty(inode);
836out:
Al Virobdaec332013-03-20 09:33:23 -0400837 mnt_drop_write_file(filp);
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900838 return ret;
839 }
840 default:
841 return -ENOTTY;
842 }
843}
844
Namjae Jeone9750822013-02-04 23:41:41 +0900845#ifdef CONFIG_COMPAT
846long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
847{
848 switch (cmd) {
849 case F2FS_IOC32_GETFLAGS:
850 cmd = F2FS_IOC_GETFLAGS;
851 break;
852 case F2FS_IOC32_SETFLAGS:
853 cmd = F2FS_IOC_SETFLAGS;
854 break;
855 default:
856 return -ENOIOCTLCMD;
857 }
858 return f2fs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
859}
860#endif
861
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900862const struct file_operations f2fs_file_operations = {
Chao Yu267378d2014-04-23 14:10:24 +0800863 .llseek = f2fs_llseek,
Al Viroaad4f8b2014-04-02 14:33:16 -0400864 .read = new_sync_read,
Al Viro81742022014-04-03 03:17:43 -0400865 .write = new_sync_write,
Al Viroaad4f8b2014-04-02 14:33:16 -0400866 .read_iter = generic_file_read_iter,
Al Viro81742022014-04-03 03:17:43 -0400867 .write_iter = generic_file_write_iter,
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900868 .open = generic_file_open,
869 .mmap = f2fs_file_mmap,
870 .fsync = f2fs_sync_file,
871 .fallocate = f2fs_fallocate,
872 .unlocked_ioctl = f2fs_ioctl,
Namjae Jeone9750822013-02-04 23:41:41 +0900873#ifdef CONFIG_COMPAT
874 .compat_ioctl = f2fs_compat_ioctl,
875#endif
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900876 .splice_read = generic_file_splice_read,
Al Viro8d020762014-04-05 04:27:08 -0400877 .splice_write = iter_file_splice_write,
Jaegeuk Kimfbfa2cc2012-11-02 17:09:44 +0900878};