12 Jan, 2017

2 commits

  • commit 230436b3ef3fd7d4a1da19edf5e87bb2d74e0fc2 upstream.

    gcc is unsure about the use of last_ofs_in_node, which might happen
    without a prior initialization:

    fs/f2fs//git/arm-soc/fs/f2fs/data.c: In function ‘f2fs_map_blocks’:
    fs/f2fs/data.c:799:54: warning: ‘last_ofs_in_node’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) {

    As pointed out by Chao Yu, the code is actually correct as 'prealloc'
    is only set if the last_ofs_in_node has been set, the two always
    get updated together.

    This initializes last_ofs_in_node to dn.ofs_in_node for each
    new dnode at the start of the 'next_block' loop, which at that
    point is a correct initialization as well. I assume that compilers
    that correctly track the contents of the variables and do not
    warn about the condition also figure out that they can eliminate
    the extra assignment here.

    Fixes: 46008c6d4232 ("f2fs: support in batch multi blocks preallocation")
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • commit 35782b233f37e48ecc469d9c7232f3f6a7fad41a upstream.

    This patch removes percpu_count usage due to performance regression in iozone.

    Fixes: 523be8a6b3 ("f2fs: use percpu_counter for page counters")
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Jaegeuk Kim
     

06 Jan, 2017

4 commits

  • commit 8508e44ae98622f841f5ef29d0bf3d5db4e0c1cc upstream.

    We don't guarantee cp_addr is fixed by cp_version.
    This is to sync with f2fs-tools.

    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Jaegeuk Kim
     
  • commit e87f7329bbd6760c2acc4f1eb423362b08851a71 upstream.

    In the last ilen case, i was already increased, resulting in accessing out-
    of-boundary entry of do_replace and blkaddr.
    Fix to check ilen first to exit the loop.

    Fixes: 2aa8fbb9693020 ("f2fs: refactor __exchange_data_block for speed up")
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Jaegeuk Kim
     
  • commit 05e6ea2685c964db1e675a24a4f4e2adc22d2388 upstream.

    The struct file_operations instance serving the f2fs/status debugfs file
    lacks an initialization of its ->owner.

    This means that although that file might have been opened, the f2fs module
    can still get removed. Any further operation on that opened file, releasing
    included, will cause accesses to unmapped memory.

    Indeed, Mike Marshall reported the following:

    BUG: unable to handle kernel paging request at ffffffffa0307430
    IP: [] full_proxy_release+0x24/0x90

    Call Trace:
    [] __fput+0xdf/0x1d0
    [] ____fput+0xe/0x10
    [] task_work_run+0x8e/0xc0
    [] do_exit+0x2ae/0xae0
    [] ? __audit_syscall_entry+0xae/0x100
    [] ? syscall_trace_enter+0x1ca/0x310
    [] do_group_exit+0x44/0xc0
    [] SyS_exit_group+0x14/0x20
    [] do_syscall_64+0x61/0x150
    [] entry_SYSCALL64_slow_path+0x25/0x25

    ---[ end trace f22ae883fa3ea6b8 ]---
    Fixing recursive fault but reboot is needed!

    Fix this by initializing the f2fs/status file_operations' ->owner with
    THIS_MODULE.

    This will allow debugfs to grab a reference to the f2fs module upon any
    open on that file, thus preventing it from getting removed.

    Fixes: 902829aa0b72 ("f2fs: move proc files to debugfs")
    Reported-by: Mike Marshall
    Reported-by: Martin Brandenburg
    Signed-off-by: Nicolai Stange
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Nicolai Stange
     
  • commit 204706c7accfabb67b97eef9f9a28361b6201199 upstream.

    This reverts commit 1beba1b3a953107c3ff5448ab4e4297db4619c76.

    The perpcu_counter doesn't provide atomicity in single core and consume more
    DRAM. That incurs fs_mark test failure due to ENOMEM.

    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Jaegeuk Kim
     

19 Oct, 2016

1 commit


13 Oct, 2016

1 commit


12 Oct, 2016

1 commit

  • The mapping_set_error() helper sets the correct AS_ flag for the mapping
    so there is no reason to open code it. Use the helper directly.

    [akpm@linux-foundation.org: be honest about conversion from -ENXIO to -EIO]
    Link: http://lkml.kernel.org/r/20160912111608.2588-2-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Hocko
     

11 Oct, 2016

4 commits

  • Pull more vfs updates from Al Viro:
    ">rename2() work from Miklos + current_time() from Deepa"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: Replace current_fs_time() with current_time()
    fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
    fs: Replace CURRENT_TIME with current_time() for inode timestamps
    fs: proc: Delete inode time initializations in proc_alloc_inode()
    vfs: Add current_time() api
    vfs: add note about i_op->rename changes to porting
    fs: rename "rename2" i_op to "rename"
    vfs: remove unused i_op->rename
    fs: make remaining filesystems use .rename2
    libfs: support RENAME_NOREPLACE in simple_rename()
    fs: support RENAME_NOREPLACE for local filesystems
    ncpfs: fix unused variable warning

    Linus Torvalds
     
  • Al Viro
     
  • Pull vfs xattr updates from Al Viro:
    "xattr stuff from Andreas

    This completes the switch to xattr_handler ->get()/->set() from
    ->getxattr/->setxattr/->removexattr"

    * 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    vfs: Remove {get,set,remove}xattr inode operations
    xattr: Stop calling {get,set,remove}xattr inode operations
    vfs: Check for the IOP_XATTR flag in listxattr
    xattr: Add __vfs_{get,set,remove}xattr helpers
    libfs: Use IOP_XATTR flag for empty directory handling
    vfs: Use IOP_XATTR flag for bad-inode handling
    vfs: Add IOP_XATTR inode operations flag
    vfs: Move xattr_resolve_name to the front of fs/xattr.c
    ecryptfs: Switch to generic xattr handlers
    sockfs: Get rid of getxattr iop
    sockfs: getxattr: Fail with -EOPNOTSUPP for invalid attribute names
    kernfs: Switch to generic xattr handlers
    hfs: Switch to generic xattr handlers
    jffs2: Remove jffs2_{get,set,remove}xattr macros
    xattr: Remove unnecessary NULL attribute name check

    Linus Torvalds
     
  • Pull misc vfs updates from Al Viro:
    "Assorted misc bits and pieces.

    There are several single-topic branches left after this (rename2
    series from Miklos, current_time series from Deepa Dinamani, xattr
    series from Andreas, uaccess stuff from from me) and I'd prefer to
    send those separately"

    * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (39 commits)
    proc: switch auxv to use of __mem_open()
    hpfs: support FIEMAP
    cifs: get rid of unused arguments of CIFSSMBWrite()
    posix_acl: uapi header split
    posix_acl: xattr representation cleanups
    fs/aio.c: eliminate redundant loads in put_aio_ring_file
    fs/internal.h: add const to ns_dentry_operations declaration
    compat: remove compat_printk()
    fs/buffer.c: make __getblk_slow() static
    proc: unsigned file descriptors
    fs/file: more unsigned file descriptors
    fs: compat: remove redundant check of nr_segs
    cachefiles: Fix attempt to read i_blocks after deleting file [ver #2]
    cifs: don't use memcpy() to copy struct iov_iter
    get rid of separate multipage fault-in primitives
    fs: Avoid premature clearing of capabilities
    fs: Give dentry to inode_change_ok() instead of inode
    fuse: Propagate dentry down to inode_change_ok()
    ceph: Propagate dentry down to inode_change_ok()
    xfs: Propagate dentry down to inode_change_ok()
    ...

    Linus Torvalds
     

08 Oct, 2016

3 commits

  • Al Viro
     
  • These inode operations are no longer used; remove them.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Al Viro

    Andreas Gruenbacher
     
  • Pull ext4 updates from Ted Ts'o:
    "Lots of bug fixes and cleanups"

    * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (40 commits)
    ext4: remove unused variable
    ext4: use journal inode to determine journal overhead
    ext4: create function to read journal inode
    ext4: unmap metadata when zeroing blocks
    ext4: remove plugging from ext4_file_write_iter()
    ext4: allow unlocked direct IO when pages are cached
    ext4: require encryption feature for EXT4_IOC_SET_ENCRYPTION_POLICY
    fscrypto: use standard macros to compute length of fname ciphertext
    ext4: do not unnecessarily null-terminate encrypted symlink data
    ext4: release bh in make_indexed_dir
    ext4: Allow parallel DIO reads
    ext4: allow DAX writeback for hole punch
    jbd2: fix lockdep annotation in add_transaction_credits()
    blockgroup_lock.h: simplify definition of NR_BG_LOCKS
    blockgroup_lock.h: remove debris from bgl_lock_ptr() conversion
    fscrypto: make filename crypto functions return 0 on success
    fscrypto: rename completion callbacks to reflect usage
    fscrypto: remove unnecessary includes
    fscrypto: improved validation when loading inode encryption metadata
    ext4: fix memory leak when symlink decryption fails
    ...

    Linus Torvalds
     

07 Oct, 2016

1 commit

  • Pull f2fs updates from Jaegeuk Kim:
    "In this round, we've investigated how f2fs deals with errors given by
    our fault injection facility. With this, we could fix several corner
    cases. And, in order to improve the performance, we set inline_dentry
    by default and enhance the exisiting discard issue flow. In addition,
    we added f2fs_migrate_page for better memory management.

    Enhancements:
    - set inline_dentry by default
    - improve discard issue flow
    - add more fault injection cases in f2fs
    - allow block preallocation for encrypted files
    - introduce migrate_page callback function
    - avoid truncating the next direct node block at every checkpoint

    Bug fixes:
    - set page flag correctly between write_begin and write_end
    - missing error handling cases detected by fault injection
    - preallocate blocks regarding to 4KB alignement correctly
    - dentry and filename handling of encryption
    - lost xattrs of directories"

    * tag 'for-f2fs-4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (69 commits)
    f2fs: introduce update_ckpt_flags to clean up
    f2fs: don't submit irrelevant page
    f2fs: fix to commit bio cache after flushing node pages
    f2fs: introduce get_checkpoint_version for cleanup
    f2fs: remove dead variable
    f2fs: remove redundant io plug
    f2fs: support checkpoint error injection
    f2fs: fix to recover old fault injection config in ->remount_fs
    f2fs: do fault injection initialization in default_options
    f2fs: remove redundant value definition
    f2fs: support configuring fault injection per superblock
    f2fs: adjust display format of segment bit
    f2fs: remove dirty inode pages in error path
    f2fs: do not unnecessarily null-terminate encrypted symlink data
    f2fs: handle errors during recover_orphan_inodes
    f2fs: avoid gc in cp_error case
    f2fs: should put_page for summary page
    f2fs: assign return value in f2fs_gc
    f2fs: add customized migrate_page callback
    f2fs: introduce cp_lock to protect updating of ckpt_flags
    ...

    Linus Torvalds
     

01 Oct, 2016

23 commits

  • This patch add update_ckpt_flags() to clean up the flow.

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • While we call ->writepages, there are two cases:
    a. we didn't writeout any dirty pages, since they are writebacked by other
    thread concurrently.
    b. we writeout dirty pages, and have already submitted bio to block layer.

    In these cases, we don't need to do additional bio flushing unnecessarily,
    it may split bio in cache into smaller one.

    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • In sync_node_pages, we won't check and commit last merged pages in private
    bio cache of f2fs, as these pages were taged as writeback, someone who is
    waiting for writebacking of the page will be blocked until the cache was
    committed by someone else.

    We need to commit node type bio cache to avoid potential deadlock or long
    delay of waiting writeback.

    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • There exists almost same codes when get the value of pre_version
    and cur_version in function validate_checkpoint, this patch adds
    get_checkpoint_version to clean up redundant codes.

    Signed-off-by: Tiezhu Yang
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Tiezhu Yang
     
  • Signed-off-by: Sheng Yong
    Acked-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Sheng Yong
     
  • Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • This patch adds to support checkpoint error injection in f2fs for testing
    fatal error tolerance, it will be useful that it can simulate abnormal
    power off by f2fs itself instead of calling godown ioctl by running apps.

    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • In ->remount_fs, we didn't recover original fault injection config if
    we encounter error, fix it.

    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • Do fault injection initialization in default_options to keep consistent
    with other default option configurating.

    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • This patch remove redundant value definition in build_sit_entries

    Signed-off-by: Yunlei He
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Yunlei He
     
  • Previously, we only support global fault injection configuration, so that
    when we configure type/rate of fault injection through sysfs, mount
    option, it will influence all f2fs partition which is being used.

    It is not make sence, since it will be not convenient if developer want
    to test separated partitions with different fault injection rate/type
    simultaneously, also it's not possible to enable fault injection in one
    partition and disable fault injection in other one.

    >From now on, we move global configuration of fault injection in module
    into per-superblock, hence injection testing can be more flexible.

    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • Just adjust segment bit info printed in procfs.

    Before:
    1008 5|0 |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    1009 3|183|0 0 61 20 20 0 0 21 80 c0 2 e4 e 54 0 21 21 17 a 44 d0 28 e4 50 40 30 8 0 2d 32 0 5 b0 80 1 43 2 8e f8 7b 2 25 93 bf e0 73 8e 9a 19 44 60 ff e4 cc e6 8e bf f9 ff 5 3d 31 3d 13
    1010 3|1 |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

    After:
    1008 5|0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    1009 4|434| ff 7d ff bf d9 3f ff e7 ff bf d7 bf ff bb be ff fb df f7 fb fa bf fb fe bb df dd ff fe ef ff fe ef e2 27 bf ab bf fb df fd bd bf fb db fc ff ff 3f ff ff bf ff 5f db 3f fb fb bf fb bf 4f ff ef
    1010 4|422| ff bb fe ff ef d7 ee ff ff fc bf ef 7d eb ec fd fb 3f 97 7f ef ff af ff db ff ff 69 bf ff f6 e7 ff fb f7 7b fb df be ff ff ef f3 fe ff ff df fe f7 fa ff b7 77 be fe fb a9 7f 87 a2 ac c7 ff 75

    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • When getting EIO while handling orphan inodes, we can get some dirty node
    pages. Then, f2fs_write_node_pages() called by iput(node_inode) will try
    to flush node pages. But in this case, we should prevent to do that, since
    we will try again from the start.

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • Null-terminating the fscrypt_symlink_data on read is unnecessary because
    it is not string data --- it contains binary ciphertext.

    Signed-off-by: Eric Biggers
    Signed-off-by: Jaegeuk Kim

    Eric Biggers
     
  • This patch fixes to handle EIO during recover_orphan_inode() given the below
    panic.

    F2FS-fs : inject IO error in f2fs_read_end_io+0xe6/0x100 [f2fs]
    ------------[ cut here ]------------
    RIP: 0010:[] [] f2fs_evict_inode+0x433/0x470 [f2fs]
    RSP: 0018:ffff92f8b7fb7c30 EFLAGS: 00010246
    RAX: ffff92fb88a13500 RBX: ffff92f890566ea0 RCX: 00000000fd3c255c
    RDX: 0000000000000001 RSI: ffff92fb88a13d90 RDI: ffff92fb8ee127e8
    RBP: ffff92f8b7fb7c58 R08: 0000000000000001 R09: ffff92fb88a13d58
    R10: 000000005a6a9373 R11: 0000000000000001 R12: 00000000fffffffb
    R13: ffff92fb8ee12000 R14: 00000000000034ca R15: ffff92fb8ee12620
    FS: 00007f1fefd8e880(0000) GS:ffff92fb95600000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fc211d34cdb CR3: 000000012d43a000 CR4: 00000000001406e0
    Stack:
    ffff92f890566ea0 ffff92f890567078 ffffffffc0b5a0c0 ffff92f890566f28
    ffff92fb888b2000 ffff92f8b7fb7c80 ffffffffbc27ff55 ffff92f890566ea0
    ffff92fb8bf10000 ffffffffc0b5a0c0 ffff92f8b7fb7cb0 ffffffffbc28090d
    Call Trace:
    [] evict+0xc5/0x1a0
    [] iput+0x1ad/0x2c0
    [] recover_orphan_inodes+0x10c/0x2e0 [f2fs]
    [] f2fs_fill_super+0x884/0x1150 [f2fs]
    [] mount_bdev+0x18c/0x1c0
    [] ? f2fs_commit_super+0x100/0x100 [f2fs]
    [] f2fs_mount+0x15/0x20 [f2fs]
    [] mount_fs+0x39/0x170
    [] vfs_kern_mount+0x6b/0x160
    [] do_mount+0x1cf/0xd00
    [] ? copy_mount_options+0xac/0x170
    [] SyS_mount+0x83/0xd0
    [] entry_SYSCALL_64_fastpath+0x23/0xc1

    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • Otherwise, we can hit
    f2fs_bug_on(sbi, !PageUptodate(sum_page));

    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • We should call put_page for preloaded summary pages in do_garbage_collect.

    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • This patch adds a return value of write_checkpoint for f2fs_gc.

    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • This patch improves the migration of dirty pages and allows migrating atomic
    written pages that F2FS uses in Page Cache. Instead of the fallback releasing
    page path, it provides better performance for memory compaction, CMA and other
    users of memory page migrating. For dirty pages, there is no need to write back
    first when migrating. For an atomic written page before committing, we can
    migrate the page and update the related 'inmem_pages' list at the same time.

    Signed-off-by: Weichao Guo
    Reviewed-by: Chao Yu
    [Jaegeuk Kim: fix some coding style]
    Signed-off-by: Jaegeuk Kim

    Weichao Guo
     
  • This patch introduces spinlock to protect updating process of ckpt_flags
    field in struct f2fs_checkpoint, it avoids incorrectly updating in race
    condition.

    Signed-off-by: Chao Yu
    [Jaegeuk Kim: add __is_set_ckpt_flags likewise __set_ckpt_flags]
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • Making updating of sbi flag atomic by using {test,set,clear}_bit,
    otherwise in concurrency scenario, the flag could be updated incorrectly.

    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • Before checkpoint, we'd be better drop any inodes.

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • Previously, we used cp_version only to detect recoverable dnodes.
    In order to avoid same garbage cp_version, we needed to truncate the next
    dnode during checkpoint, resulting in additional discard or data write.
    If we can distinguish this by using crc in addition to cp_version, we can
    remove this overhead.

    There is backward compatibility concern where it changes node_footer layout.
    So, this patch introduces a new checkpoint flag, CP_CRC_RECOVERY_FLAG, to
    detect new layout. New layout will be activated only when this flag is set.

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim