aboutsummaryrefslogtreecommitdiff
path: root/fs/f2fs/inline.c
AgeCommit message (Collapse)AuthorFilesLines
2015-05-28f2fs crypto: activate encryption support for fs APIsJaegeuk Kim1-0/+3
This patch activates the following APIs for encryption support. The rules quoted by ext4 are: - An unencrypted directory may contain encrypted or unencrypted files or directories. - All files or directories in a directory must be protected using the same key as their containing directory. - Encrypted inode for regular file should not have inline_data. - Encrypted symlink and directory may have inline_data and inline_dentry. This patch activates the following APIs. 1. f2fs_link : validate context 2. f2fs_lookup : '' 3. f2fs_rename : '' 4. f2fs_create/f2fs_mkdir : inherit its dir's context 5. f2fs_direct_IO : do buffered io for regular files 6. f2fs_open : check encryption info 7. f2fs_file_mmap : '' 8. f2fs_setattr : '' 9. f2fs_file_write_iter : '' (Called by sys_io_submit) 10. f2fs_fallocate : do not support fcollapse 11. f2fs_evict_inode : free_encryption_info Signed-off-by: Michael Halcrow <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2015-05-28f2fs: add sbi and page pointer in f2fs_io_infoJaegeuk Kim1-1/+3
This patch adds f2fs_sb_info and page pointers in f2fs_io_info structure. With this change, we can reduce a lot of parameters for IO functions. Signed-off-by: Jaegeuk Kim <[email protected]>
2015-05-28f2fs: add f2fs_may_inline_{data, dentry}Jaegeuk Kim1-1/+12
This patch adds f2fs_may_inline_data and f2fs_may_inline_dentry. Signed-off-by: Jaegeuk Kim <[email protected]>
2015-04-10f2fs: add F2FS_INLINE_DOTS to recover missing dot dentriesJaegeuk Kim1-12/+17
If f2fs was corrupted with missing dot dentries, it needs to recover them after fsck.f2fs detection. The underlying precedure is: 1. The fsck.f2fs remains F2FS_INLINE_DOTS flag in directory inode, if it detects missing dot dentries. 2. When f2fs looks up the corrupted directory, it triggers f2fs_add_link with proper inode numbers and their dot and dotdot names. 3. Once f2fs recovers the directory without errors, it removes F2FS_INLINE_DOTS finally. Signed-off-by: Jaegeuk Kim <[email protected]>
2015-04-10f2fs: split set_data_blkaddr from f2fs_update_extent_cacheChao Yu1-0/+1
Split __set_data_blkaddr from f2fs_update_extent_cache for readability. Additionally rename __set_data_blkaddr to set_data_blkaddr for exporting. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2015-04-10f2fs: enable fast symlink by utilizing inline dataWanpeng Li1-1/+1
Fast symlink can utilize inline data flow to avoid using any i_addr region, since we need to handle many cases such as truncation, roll-forward recovery, and fsck/dump tools. Signed-off-by: Wanpeng Li <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2015-04-10f2fs: avoid wrong f2fs_bug_on when truncating inline_dataJaegeuk Kim1-7/+0
This patch removes wrong f2fs_bug_on in truncate_inline_inode. When there is no space, it can happen a corner case where i_isze is over MAX_INLINE_SIZE while its inode is still inline_data. The scenario is 1. write small data into file #A. 2. fill the whole partition to 100%. 3. truncate 4096 on file #A. 4. write data at 8192 offset. --> f2fs_write_begin -> -ENOSPC = f2fs_convert_inline_page -> f2fs_write_failed -> truncate_blocks -> truncate_inline_inode BUG_ON, since i_size is 4096. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2015-04-10f2fs: fix to truncate inline data past EOFChao Yu1-5/+21
Previously if inode is with inline data, we will try to invalid partial inline data in page #0 when we truncate size of inode in truncate_partial_data_page(). And then we set page #0 to dirty, after this we can synchronize inode page with page #0 at ->writepage(). But sometimes we will fail to operate page #0 in truncate_partial_data_page() due to below reason: a) if offset is zero, we will skip setting page #0 to dirty. b) if page #0 is not uptodate, we will fail to update it as it has no mapping data. So with following operations, we will meet recent data which should be truncated. 1.write inline data to file 2.sync first data page to inode page 3.truncate file size to 0 4.truncate file size to max_inline_size 5.echo 1 > /proc/sys/vm/drop_caches 6.read file --> meet original inline data which is remained in inode page. This patch renames truncate_inline_data() to truncate_inline_inode() for code readability, then use truncate_inline_inode() to truncate inline data in inode page in truncate_blocks() and truncate page #0 in truncate_partial_data_page() for fixing. v2: o truncate partially #0 page in truncate_partial_data_page to avoid keeping old data in #0 page. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2015-03-03f2fs: introduce universal lookup/update interface for extent cacheChao Yu1-1/+1
In this patch, we do these jobs: 1. rename {check,update}_extent_cache to {lookup,update}_extent_info; 2. introduce universal lookup/update interface of extent cache: f2fs_{lookup,update}_extent_cache including above two real functions, then export them to function callers. So after above cleanup, we can add new rb-tree based extent cache into exported interfaces. v2: o remove "f2fs_" for inner function {lookup,update}_extent_info suggested by Jaegeuk Kim. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2015-03-03f2fs: introduce f2fs_update_dentry to clean up duplicated codesChao Yu1-12/+6
This patch introduces f2fs_update_dentry to remove redundant code in f2fs_add_inline_entry and __f2fs_add_link. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2015-02-11f2fs: make truncate_inline_date staticChao Yu1-16/+9
1. make truncate_inline_date static; 2. remove parameter @from of truncate_inline_date as callers only pass zero. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2015-01-09f2fs: clean up to remove parameterJaegeuk Kim1-1/+1
This patch uses dn->data_blkaddr as a parameter for the destination block address. Signed-off-by: Jaegeuk Kim <[email protected]>
2015-01-09f2fs: use f2fs_io_info to clean up messy parameters during IO pathJaegeuk Kim1-4/+3
This patch cleans up parameters on IO paths. The key idea is to use f2fs_io_info adding a parameter, block address, and then use this structure as parameters. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-25f2fs: fix to recover converted inline_dataJaegeuk Kim1-0/+3
If an inode has converted inline_data which was written to the disk, we should set its inode flag for further fsync so that this inline_data can be recovered from sudden power off. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-25f2fs: make clean the page before writingJaegeuk Kim1-1/+6
If a page is set to be written to the disk, we can make clean the page. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-23f2fs: call flush_dcache_page when the page was updatedJaegeuk Kim1-0/+1
Whenever f2fs updates mapped pages, it needs to call flush_dcache_page. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-18f2fs: fix to call put_page at the error handling routineJaegeuk Kim1-3/+3
The locked page should be released before returning the function. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-11f2fs: convert inline_data when i_size becomes largeJaegeuk Kim1-0/+3
If i_size becomes large outside of MAX_INLINE_DATA, we shoud convert the inode. Otherwise, we can make some dirty pages during the truncation, and those pages will be written through f2fs_write_data_page. At that moment, the inode has still inline_data, so that it tries to write non- zero pages into inline_data area. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-10f2fs: reduce the number of inline_data inode before clearing itJaegeuk Kim1-1/+1
The # of inline_data inode is decreased only when it has inline_data. After clearing the flag, we can't decreased the number. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-04f2fs: revisit inline_data to avoid data races and potential bugsJaegeuk Kim1-105/+98
This patch simplifies the inline_data usage with the following rule. 1. inline_data is set during the file creation. 2. If new data is requested to be written ranges out of inline_data, f2fs converts that inode permanently. 3. There is no cases which converts non-inline_data inode to inline_data. 4. The inline_data flag should be changed under inode page lock. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: flush_dcache_page for inline dataJaegeuk Kim1-0/+1
When reading inline data, we should call flush_dcache_page. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: declare f2fs_convert_inline_dir as a static functionJaegeuk Kim1-1/+1
This patch declares f2fs_convert_inline_dir as a static function, which was reported by kbuild test robot. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: use kmap_atomic instead of kmapJaegeuk Kim1-9/+8
For better performance, we need to use kmap_atomic instead of kmap. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: reuse make_empty_dir code for inline_dentryJaegeuk Kim1-17/+3
This patch introduces do_make_empty_dir to mitigate code redundancy for inline_dentry. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: introduce f2fs_dentry_ptr structure for code clean-upJaegeuk Kim1-9/+9
This patch introduces f2fs_dentry_ptr structure for the use of a function parameter in inline_dentry operations. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: reuse core function in f2fs_readdir for inline_dentryJaegeuk Kim1-32/+7
This patch introduces a core function, f2fs_fill_dentries, to remove redundant code in f2fs_readdir and f2fs_read_inline_dir. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: add stat info for inline_dentry inodesJaegeuk Kim1-1/+1
This patch adds status information for inline_dentry inodes. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: avoid deadlock on init_inode_metadataJaegeuk Kim1-3/+3
Previously, init_inode_metadata does not hold any parent directory's inode page. So, f2fs_init_acl can grab its parent inode page without any problem. But, when we use inline_dentry, that page is grabbed during f2fs_add_link, so that we can fall into deadlock condition like below. INFO: task mknod:11006 blocked for more than 120 seconds. Tainted: G OE 3.17.0-rc1+ #13 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. mknod D ffff88003fc94580 0 11006 11004 0x00000000 ffff880007717b10 0000000000000002 ffff88003c323220 ffff880007717fd8 0000000000014580 0000000000014580 ffff88003daecb30 ffff88003c323220 ffff88003fc94e80 ffff88003ffbb4e8 ffff880007717ba0 0000000000000002 Call Trace: [<ffffffff8173dc40>] ? bit_wait+0x50/0x50 [<ffffffff8173d4cd>] io_schedule+0x9d/0x130 [<ffffffff8173dc6c>] bit_wait_io+0x2c/0x50 [<ffffffff8173da3b>] __wait_on_bit_lock+0x4b/0xb0 [<ffffffff811640a7>] __lock_page+0x67/0x70 [<ffffffff810acf50>] ? autoremove_wake_function+0x40/0x40 [<ffffffff811652cc>] pagecache_get_page+0x14c/0x1e0 [<ffffffffa029afa9>] get_node_page+0x59/0x130 [f2fs] [<ffffffffa02a63ad>] read_all_xattrs+0x24d/0x430 [f2fs] [<ffffffffa02a6ca2>] f2fs_getxattr+0x52/0xe0 [f2fs] [<ffffffffa02a7481>] f2fs_get_acl+0x41/0x2d0 [f2fs] [<ffffffff8122d847>] get_acl+0x47/0x70 [<ffffffff8122db5a>] posix_acl_create+0x5a/0x150 [<ffffffffa02a7759>] f2fs_init_acl+0x29/0xcb [f2fs] [<ffffffffa0286a8d>] init_inode_metadata+0x5d/0x340 [f2fs] [<ffffffffa029253a>] f2fs_add_inline_entry+0x12a/0x2e0 [f2fs] [<ffffffffa0286ea5>] __f2fs_add_link+0x45/0x4a0 [f2fs] [<ffffffffa028b5b6>] ? f2fs_new_inode+0x146/0x220 [f2fs] [<ffffffffa028b816>] f2fs_mknod+0x86/0xf0 [f2fs] [<ffffffff811e3ec1>] vfs_mknod+0xe1/0x160 [<ffffffff811e4b26>] SyS_mknod+0x1f6/0x200 [<ffffffff81741d7f>] tracesys+0xe1/0xe6 Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: fix to wait correct block typeJaegeuk Kim1-2/+2
The inode page needs to wait NODE block io. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: reuse find_in_block code for find_in_inline_dirJaegeuk Kim1-35/+17
This patch removes redundant copied code in find_in_inline_dir. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: reuse room_for_filename for inline dentry operationJaegeuk Kim1-25/+2
This patch introduces to reuse the existing room_for_filename for inline dentry operation. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: enable inline dir handlingChao Yu1-1/+1
Add inline dir functions into normal dir ops' function to handle inline ops. Besides, we enable inline dir mode when a new dir inode is created if inline_data option is on. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: add key function to handle inline dirChao Yu1-0/+346
Adds Functions to implement inline dir init/lookup/insert/delete/convert ops. Signed-off-by: Chao Yu <[email protected]> [Jaegeuk Kim: remove needless reserved area copy, pointed by Dan Carpenter] Signed-off-by: Jaegeuk Kim <[email protected]>
2014-11-03f2fs: should truncate any allocated block for inline_data writeJaegeuk Kim1-7/+8
When trying to write inline_data, we should truncate any data block allocated and pointed by the inode block. We should consider the data index is not 0. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-10-06f2fs: support atomic writesJaegeuk Kim1-0/+3
This patch introduces a very limited functionality for atomic write support. In order to support atomic write, this patch adds two ioctls: o F2FS_IOC_START_ATOMIC_WRITE o F2FS_IOC_COMMIT_ATOMIC_WRITE The database engine should be aware of the following sequence. 1. open -> ioctl(F2FS_IOC_START_ATOMIC_WRITE); 2. writes : all the written data will be treated as atomic pages. 3. commit -> ioctl(F2FS_IOC_COMMIT_ATOMIC_WRITE); : this flushes all the data blocks to the disk, which will be shown all or nothing by f2fs recovery procedure. 4. repeat to #2. The IO pattens should be: ,- START_ATOMIC_WRITE ,- COMMIT_ATOMIC_WRITE CP | D D D D D D | FSYNC | D D D D | FSYNC ... `- COMMIT_ATOMIC_WRITE Signed-off-by: Jaegeuk Kim <[email protected]>
2014-09-09f2fs: need fsck.f2fs when f2fs_bug_on is triggeredJaegeuk Kim1-2/+2
If any f2fs_bug_on is triggered, fsck.f2fs is needed. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-09-03f2fs: introduce F2FS_I_SB, F2FS_M_SB, and F2FS_P_SBJaegeuk Kim1-8/+5
This patch adds three inline functions to clean up dirty casting codes. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-08-21f2fs: skip if inline_data was converted alreadyJaegeuk Kim1-1/+5
This patch checks inline_data one more time under the inode page lock whether its inline_data is converted or not. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-08-21f2fs: avoid double lock in truncate_blocksJaegeuk Kim1-1/+1
The init_inode_metadata calls truncate_blocks when error is occurred. The callers holds f2fs_lock_op, so we should not call it again in truncate_blocks. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-08-19f2fs: make clear on test condition and return typesJaegeuk Kim1-5/+5
This patch adds a parentheses to make clear for condition check. And also it changes the return type for better meanings. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-08-19f2fs: should convert inline_data during the mkwriteJaegeuk Kim1-8/+12
If mkwrite is called to an inode having inline_data, it can overwrite the data index space as NEW_ADDR. (e.g., the first 4 bytes are coincidently zero) Signed-off-by: Jaegeuk Kim <[email protected]>
2014-07-29f2fs: add info of appended or updated data writesJaegeuk Kim1-0/+1
This patch introduces a inode number list in which represents inodes having appended data writes or updated data writes after last checkpoint. This will be used at fsync to determine whether the recovery information should be written or not. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-05-07f2fs: avoid grab_cache_page_write_begin for data pagesJaegeuk Kim1-1/+2
We don't need to wait on page writeback for these cases. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-05-07f2fs: split grab_cache_page and wait_on_page_writeback for node pagesJaegeuk Kim1-0/+6
This patch splits grab_cache_page_write_begin into grab_cache_page and wait_on_page_writeback for node pages. This patch intends to enhance the latency to get node pages by alleviating unnecessary wait_on_page_writeback. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-05-07f2fs: fix to truncate inline data in inode page when setattrChao Yu1-0/+18
Previous we do not truncate inline data in inode page when setattr, so following case could still read the inline data which has already truncated: 1.write inline data 2.ftruncate size to 0 3.ftruncate size to max inline data size 4.read from offset 0 This patch introduces truncate_inline_data() to fix this problem. change log from v1: o fix a bug and do not truncate first page data after truncate inline data. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-05-07f2fs: fix to unlock f2fs_lock at the omitted error caseJaegeuk Kim1-6/+7
If it occurs an error, we should call f2fs_unlock_op. Signed-off-by: Jaegeuk Kim <[email protected]>
2014-04-02f2fs: fix error path when fail to read inline dataChao Yu1-1/+3
We should unlock page in ->readpage() path and also should unlock & release page in error path of ->write_begin() to avoid deadlock or memory leak. So let's add release code to fix the problem when we fail to read inline data. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-01-14f2fs: remove the needless parameter of f2fs_wait_on_page_writebackYuan Zhong1-1/+1
"boo sync" parameter is never referenced in f2fs_wait_on_page_writeback. We should remove this parameter. Signed-off-by: Yuan Zhong <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-01-06f2fs: avoid to read inline data except first pageChao Yu1-0/+6
Here is a case which could read inline page data not from first page. 1. write inline data 2. lseek to offset 4096 3. read 4096 bytes from offset 4096 (read_inline_data read inline data page to non-first page, And previously VFS has add this page to page cache) 4. ftruncate offset 8192 5. read 4096 bytes from offset 4096 (we meet this updated page with inline data in cache) So we should leave this page with inited data and uptodate flag for this case. Change log from v1: o fix a deadlock bug Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
2014-01-06f2fs: avoid to left uninitialized data in page when read inline dataChao Yu1-3/+2
Change log from v1: o reduce unneeded memset in __f2fs_convert_inline_data >From 58796be2bd2becbe8d52305210fb2a64e7dd80b6 Mon Sep 17 00:00:00 2001 From: Chao Yu <[email protected]> Date: Mon, 30 Dec 2013 09:21:33 +0800 Subject: [PATCH] f2fs: avoid to left uninitialized data in page when read inline data We left uninitialized data in the tail of page when we read an inline data page. So let's initialize left part of the page excluding inline data region. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>