summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/super.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'work.misc' of ↵Linus Torvalds2016-07-281-1/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs Pull vfs updates from Al Viro: "Assorted cleanups and fixes. Probably the most interesting part long-term is ->d_init() - that will have a bunch of followups in (at least) ceph and lustre, but we'll need to sort the barrier-related rules before it can get used for really non-trivial stuff. Another fun thing is the merge of ->d_iput() callers (dentry_iput() and dentry_unlink_inode()) and a bunch of ->d_compare() ones (all except the one in __d_lookup_lru())" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (26 commits) fs/dcache.c: avoid soft-lockup in dput() vfs: new d_init method vfs: Update lookup_dcache() comment bdev: get rid of ->bd_inodes Remove last traces of ->sync_page new helper: d_same_name() dentry_cmp(): use lockless_dereference() instead of smp_read_barrier_depends() vfs: clean up documentation vfs: document ->d_real() vfs: merge .d_select_inode() into .d_real() unify dentry_iput() and dentry_unlink_inode() binfmt_misc: ->s_root is not going anywhere drop redundant ->owner initializations ufs: get rid of redundant checks orangefs: constify inode_operations missed comment updates from ->direct_IO() prototype change file_inode(f)->i_mapping is f->f_mapping trim fsnotify hooks a bit 9p: new helper - v9fs_parent_fid() debugfs: ->d_parent is never NULL or negative ...
| * drop redundant ->owner initializationsAl Viro2016-05-291-1/+0
| | | | | | | | | | | | | | it's not needed for file_operations of inodes located on fs defined in the hosting module and for file_operations that go into procfs. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | f2fs: fix to avoid data update racing between GC and DIOChao Yu2016-07-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Datas in file can be operated by GC and DIO simultaneously, so we will face race case as below: For write case: Thread A Thread B - generic_file_direct_write - invalidate_inode_pages2_range - f2fs_direct_IO - do_blockdev_direct_IO - do_direct_IO - get_more_blocks - f2fs_gc - do_garbage_collect - gc_data_segment - move_data_page - do_write_data_page migrate data block to new block address - dio_bio_submit update user data to old block address For read case: Thread A Thread B - generic_file_direct_write - invalidate_inode_pages2_range - f2fs_direct_IO - do_blockdev_direct_IO - do_direct_IO - get_more_blocks - f2fs_balance_fs - f2fs_gc - do_garbage_collect - gc_data_segment - move_data_page - do_write_data_page migrate data block to new block address - write_checkpoint - do_checkpoint - clear_prefree_segments - f2fs_issue_discard discard old block adress - dio_bio_submit update user buffer from obsolete block address In order to fix this, for one file, we should let DIO and GC getting exclusion against with each other. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: avoid mark_inode_dirtyJaegeuk Kim2016-07-081-17/+26
| | | | | | | | | | | | Let's check inode's dirtiness before calling mark_inode_dirty. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: fix incorrect f_bfree calculation in ->statfsChao Yu2016-07-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | As manual described, f_bfree indicates total free blocks in fs, in f2fs, it includes two parts: visible free blocks and over-provision blocks. This patch corrrects the calculation. fsblkcnt_t f_bfree; /* free blocks in fs */ Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: use percpu_rw_semaphoreJaegeuk Kim2016-07-081-1/+5
| | | | | | | | | | | | | | | | This patch replaces rw_semaphore with percpu_rw_semaphore for: sbi->cp_rwsem nm_i->nat_tree_lock Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: add nodiscard mount optionChao Yu2016-07-081-0/+4
| | | | | | | | | | | | | | This patch adds 'nodiscard' mount option. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: detect host-managed SMR by feature flagJaegeuk Kim2016-07-061-6/+10
| | | | | | | | | | | | | | If mkfs.f2fs gives a feature flag for host-managed SMR, we can set mode=lfs by default. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: call update_inode_page for orphan inodesJaegeuk Kim2016-07-061-15/+1
| | | | | | | | | | | | Let's store orphan inode pages right away. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: introduce mode=lfs mount optionJaegeuk Kim2016-06-131-0/+28
| | | | | | | | | | | | | | | | | | This mount option is to enable original log-structured filesystem forcefully. So, there should be no random writes for main area. Especially, this supports host-managed SMR device. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: avoid reverse IO order for NODE and DATAJaegeuk Kim2016-06-081-0/+2
| | | | | | | | | | | | | | There is a data race between allocate_data_block() and f2fs_sbumit_page_mbio(), which incur unnecessary reversed bio submission. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: remove obsolete parameter in f2fs_truncateJaegeuk Kim2016-06-071-1/+1
| | | | | | | | | | | | We don't need lock parameter, which is always true. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: avoid wrong count on dirty inodesJaegeuk Kim2016-06-071-2/+2
| | | | | | | | | | | | | | The number should be covered by spin_lock. Otherwise we can see wrong count in f2fs_stat. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: inject to produce some orphan inodesJaegeuk Kim2016-06-021-0/+1
| | | | | | | | Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: remove writepages lockJaegeuk Kim2016-06-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | This patch removes writepages lock. We can improve multi-threading performance. tiobench, 32 threads, 4KB write per fsync on SSD Before: 25.88 MB/s After: 28.03 MB/s Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: set flush_merge by defaultJaegeuk Kim2016-06-021-0/+6
| | | | | | | | | | | | This patch sets flush_merge by default. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: add lazytime mount optionJaegeuk Kim2016-06-021-0/+14
| | | | | | | | | | | | This patch adds lazytime support. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: avoid unnecessary updating inode during fsyncJaegeuk Kim2016-06-021-0/+4
| | | | | | | | | | | | | | If roll-forward recovery can recover i_size, we don't need to update inode's metadata during fsync. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: flush inode metadata when checkpoint is doingJaegeuk Kim2016-06-021-2/+52
| | | | | | | | | | | | | | This patch registers all the inodes which have dirty metadata to sync when checkpoint is doing. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: introduce f2fs_i_size_write with mark_inode_dirty_syncJaegeuk Kim2016-06-021-1/+1
| | | | | | | | | | | | | | This patch introduces f2fs_i_size_write() to call mark_inode_dirty_sync() with i_size_write(). Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | f2fs: use inode pointer for {set, clear}_inode_flagJaegeuk Kim2016-06-021-6/+1
|/ | | | | | | This patch refactors to use inode pointer for set_inode_flag and clear_inode_flag. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: make exit_f2fs_fs more clearTiezhu Yang2016-05-181-5/+5
| | | | | | | | | | | | | | | | | | | | | | init_f2fs_fs does: 1) f2fs_build_trace_ios 2) init_inodecache 3) create_node_manager_caches 4) create_segment_manager_caches 5) create_checkpoint_caches 6) create_extent_cache 7) kset_create_and_add 8) kobject_init_and_add 9) register_shrinker 10) register_filesystem 11) f2fs_create_root_stats 12) proc_mkdir exit_f2fs_fs should do cleanup in the reverse order to make the code more clear. Signed-off-by: Tiezhu Yang <kernelpatch@126.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: use percpu_counter for total_valid_inode_countJaegeuk Kim2016-05-181-3/+8
| | | | | | This patch uses percpu_counter to avoid stat_lock. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: use percpu_counter for alloc_valid_block_countJaegeuk Kim2016-05-181-2/+5
| | | | | | This patch uses percpu_count for sbi->alloc_valid_block_count. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: use percpu_counter for # of dirty pages in inodeJaegeuk Kim2016-05-181-1/+6
| | | | | | This patch adds percpu_counter for # of dirty pages in inode. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: use percpu_counter for page countersJaegeuk Kim2016-05-181-4/+27
| | | | | | | This patch substitutes percpu_counter for atomic_counter when counting various types of pages. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: use bio count instead of F2FS_WRITEBACK page countJaegeuk Kim2016-05-181-2/+1
| | | | | | This can reduce page counting overhead. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: add fault injection to sysfsSheng Yong2016-05-161-5/+65
| | | | | | | | | This patch introduces a new struct f2fs_fault_info and a global f2fs_fault to save fault injection status. Fault injection entries are created in /sys/fs/f2fs/fault_injection/ during initializing f2fs module. Signed-off-by: Sheng Yong <shengyong1@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: correct return value type of f2fs_fill_superSheng Yong2016-05-161-3/+3
| | | | | Signed-off-by: Sheng Yong <shengyong1@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* fscrypto/f2fs: allow fs-specific key prefix for fs encryptionJaegeuk Kim2016-05-071-0/+13
| | | | | | | | | | | | | | | | | | This patch allows fscrypto to handle a second key prefix given by filesystem. The main reason is to provide backward compatibility, since previously f2fs used "f2fs:" as a crypto prefix instead of "fscrypt:". Later, ext4 should also provide key_prefix() to give "ext4:". One concern decribed by Ted would be kinda double check overhead of prefixes. In x86, for example, validate_user_key consumes 8 ms after boot-up, which turns out derive_key_aes() consumed most of the time to load specific crypto module. After such the cold miss, it shows almost zero latencies, which treats as a negligible overhead. Note that request_key() detects wrong prefix in prior to derive_key_aes() even. Cc: Ted Tso <tytso@mit.edu> Cc: stable@vger.kernel.org # v4.6 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: fix leak of orphan inode objectsJaegeuk Kim2016-05-071-1/+1
| | | | | | When unmounting filesystem, we should release all the ino entries. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: inject ENOSPC failuresJaegeuk Kim2016-05-071-0/+4
| | | | | | This patch injects ENOSPC failures. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: inject page allocation failuresJaegeuk Kim2016-05-071-0/+1
| | | | | | This patch adds page allocation failures. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: inject kmalloc failureJaegeuk Kim2016-05-071-0/+6
| | | | | | This patch injects kmalloc failure given a fault injection rate. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: add mount option to select fault injection ratioJaegeuk Kim2016-05-071-0/+19
| | | | | | This patch adds a mount option to select fault ratio. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: add proc entry to show valid block bitmapJaegeuk Kim2016-05-071-1/+31
| | | | | | This patch adds a new proc entry to show segment information in more detail. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: introduce macros for proc entriesJaegeuk Kim2016-05-071-11/+14
| | | | | | This adds macros to be used multiple proc entries. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: treat as a normal umount when remounting roJaegeuk Kim2016-04-151-8/+10
| | | | | | When user remounts f2fs as read-only, we can mark the checkpoint as umount. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: give -EINVAL for norecovery and rw mountJaegeuk Kim2016-04-151-2/+12
| | | | | | | Once detecting something to recover, f2fs should stop mounting, given norecovery and rw mount options. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: recover superblock at RW remountsJaegeuk Kim2016-04-151-9/+27
| | | | | | | | This patch adds a sbi flag, SBI_NEED_SB_WRITE, which indicates it needs to recover superblock when (re)mounting as RW. This is set only when f2fs is mounted as RO. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: give RO message when recovering superblockJaegeuk Kim2016-04-151-1/+4
| | | | | | | When one of superblocks is missing, f2fs recovers it with the valid one. But, even if f2fs is mounted as RO, we'd better notify that too. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* Merge tag 'f2fs-for-linus' of ↵Linus Torvalds2016-04-041-38/+66
|\ | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs Pull f2fs fixes from Jaegeuk Kim. * tag 'f2fs-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: f2fs: retrieve IO write stat from the right place f2fs crypto: fix corrupted symlink in encrypted case f2fs: cover large section in sanity check of super
| * f2fs: retrieve IO write stat from the right placeShuoran Liu2016-03-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the following patch, f2fs: split journal cache from curseg cache journal cache is split from curseg cache. So IO write statistics should be retrived from journal cache but not curseg->sum_blk. Otherwise, it will get 0, and the stat is lost. Signed-off-by: Shuoran Liu <liushuoran@huawei.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
| * f2fs: cover large section in sanity check of superJaegeuk Kim2016-03-281-37/+65
| | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the bug which does not cover a large section case when checking the sanity of superblock. If f2fs detects misalignment, it will fix the superblock during the mount time, so it doesn't need to trigger fsck.f2fs further. Reported-by: Matthias Prager <linux@matthiasprager.de> Reported-by: David Gnedt <david.gnedt@davizone.at> Cc: stable 4.5+ <stable@vger.kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* | mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macrosKirill A. Shutemov2016-04-041-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time ago with promise that one day it will be possible to implement page cache with bigger chunks than PAGE_SIZE. This promise never materialized. And unlikely will. We have many places where PAGE_CACHE_SIZE assumed to be equal to PAGE_SIZE. And it's constant source of confusion on whether PAGE_CACHE_* or PAGE_* constant should be used in a particular case, especially on the border between fs and mm. Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much breakage to be doable. Let's stop pretending that pages in page cache are special. They are not. The changes are pretty straight-forward: - <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN}; - page_cache_get() -> get_page(); - page_cache_release() -> put_page(); This patch contains automated changes generated with coccinelle using script below. For some reason, coccinelle doesn't patch header files. I've called spatch for them manually. The only adjustment after coccinelle is revert of changes to PAGE_CAHCE_ALIGN definition: we are going to drop it later. There are few places in the code where coccinelle didn't reach. I'll fix them manually in a separate patch. Comments and documentation also will be addressed with the separate patch. virtual patch @@ expression E; @@ - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ expression E; @@ - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ @@ - PAGE_CACHE_SHIFT + PAGE_SHIFT @@ @@ - PAGE_CACHE_SIZE + PAGE_SIZE @@ @@ - PAGE_CACHE_MASK + PAGE_MASK @@ expression E; @@ - PAGE_CACHE_ALIGN(E) + PAGE_ALIGN(E) @@ expression E; @@ - page_cache_get(E) + get_page(E) @@ expression E; @@ - page_cache_release(E) + put_page(E) Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* f2fs: use cryptoapi crc32 functionsKeith Mok2016-03-171-0/+13
| | | | | | | | | The crc function is done bit by bit. Optimize this by use cryptoapi crc32 function which is backed by h/w acceleration. Signed-off-by: Keith Mok <ek9852@gmail.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* fs crypto: move per-file encryption from f2fs tree to fs/cryptoJaegeuk Kim2016-03-171-17/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the renamed functions moved from the f2fs crypto files. 1. definitions for per-file encryption used by ext4 and f2fs. 2. crypto.c for encrypt/decrypt functions a. IO preparation: - fscrypt_get_ctx / fscrypt_release_ctx b. before IOs: - fscrypt_encrypt_page - fscrypt_decrypt_page - fscrypt_zeroout_range c. after IOs: - fscrypt_decrypt_bio_pages - fscrypt_pullback_bio_page - fscrypt_restore_control_page 3. policy.c supporting context management. a. For ioctls: - fscrypt_process_policy - fscrypt_get_policy b. For context permission - fscrypt_has_permitted_context - fscrypt_inherit_context 4. keyinfo.c to handle permissions - fscrypt_get_encryption_info - fscrypt_free_encryption_info 5. fname.c to support filename encryption a. general wrapper functions - fscrypt_fname_disk_to_usr - fscrypt_fname_usr_to_disk - fscrypt_setup_filename - fscrypt_free_filename b. specific filename handling functions - fscrypt_fname_alloc_buffer - fscrypt_fname_free_buffer 6. Makefile and Kconfig Cc: Al Viro <viro@ftp.linux.org.uk> Signed-off-by: Michael Halcrow <mhalcrow@google.com> Signed-off-by: Ildar Muslukhov <ildarm@google.com> Signed-off-by: Uday Savagaonkar <savagaon@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: introduce f2fs_flush_merged_bios for cleanupChao Yu2016-02-261-5/+2
| | | | | | | Add a new helper f2fs_flush_merged_bios to clean up redundant codes. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: show more info about superblock recoveryChao Yu2016-02-221-2/+4
| | | | | | | | | This patch changes to show more info in message log about the recovery of the corrupted superblock during ->mount, e.g. the index of corrupted superblock and the result of recovery. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs: move sanity checking of cp into get_valid_checkpointShawn Lin2016-02-221-9/+1
| | | | | | | | | | | | | | | >From the function name of get_valid_checkpoint, it seems to return the valid cp or NULL for caller to check. If no valid one is found, f2fs_fill_super will print the err log. But if get_valid_checkpoint get one valid(the return value indicate that it's valid, however actually it is invalid after sanity checking), then print another similar err log. That seems strange. Let's keep sanity checking inside the procedure of geting valid cp. Another improvement we gained from this move is that even the large volume is supported, we check the cp in advanced to skip the following procedure if failing the sanity checking. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>