11 Oct, 2016

1 commit

  • 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
     

08 Oct, 2016

1 commit

  • 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
     

01 Oct, 2016

1 commit

  • 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
     

28 Sep, 2016

1 commit

  • CURRENT_TIME macro is not appropriate for filesystems as it
    doesn't use the right granularity for filesystem timestamps.
    Use current_time() instead.

    CURRENT_TIME is also not y2038 safe.

    This is also in preparation for the patch that transitions
    vfs timestamps to use 64 bit time and hence make them
    y2038 safe. As part of the effort current_time() will be
    extended to do range checks. Hence, it is necessary for all
    file system timestamps to use current_time(). Also,
    current_time() will be transitioned along with vfs to be
    y2038 safe.

    Note that whenever a single call to current_time() is used
    to change timestamps in different inodes, it is because they
    share the same time granularity.

    Signed-off-by: Deepa Dinamani
    Reviewed-by: Arnd Bergmann
    Acked-by: Felipe Balbi
    Acked-by: Steven Whitehouse
    Acked-by: Ryusuke Konishi
    Acked-by: David Sterba
    Signed-off-by: Al Viro

    Deepa Dinamani
     

23 Sep, 2016

1 commit


16 Sep, 2016

1 commit

  • Several filename crypto functions: fname_decrypt(),
    fscrypt_fname_disk_to_usr(), and fscrypt_fname_usr_to_disk(), returned
    the output length on success or -errno on failure. However, the output
    length was redundant with the value written to 'oname->len'. It is also
    potentially error-prone to make callers have to check for '< 0' instead
    of '!= 0'.

    Therefore, make these functions return 0 instead of a length, and make
    the callers who cared about the return value being a length use
    'oname->len' instead. For consistency also make other callers check for
    a nonzero result rather than a negative result.

    This change also fixes the inconsistency of fname_encrypt() actually
    already returning 0 on success, not a length like the other filename
    crypto functions and as documented in its function comment.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o
    Reviewed-by: Andreas Dilger
    Acked-by: Jaegeuk Kim

    Eric Biggers
     

08 Sep, 2016

4 commits

  • This fixes pointer panic when using inline_dentry, which was triggered when
    backporting to 3.10.

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • Add roll-forward recovery process for encrypted dentry, so the first fsync
    issued to an encrypted file does not need writing checkpoint.

    This improves the performance of the following test at thousands of small
    files: open -> write -> fsync -> close

    Signed-off-by: Shuoran Liu
    Acked-by: Chao Yu
    [Jaegeuk Kim: modify kernel message to show encrypted names]
    Signed-off-by: Jaegeuk Kim

    Shuoran Liu
     
  • When decrypting dirents in ->readdir, fscrypt_fname_disk_to_usr won't
    change content of original encrypted dirent, we don't need to allocate
    additional buffer for storing mirror of it, so get rid of it.

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

    Chao Yu
     
  • When creating new inode, security_inode_init_security will be called for
    initializing security info related to the inode, and filename is passed to
    security module, it helps security module such as SElinux to know which
    rule or label could be applied for the inode with specified name.

    Previously, if new inode is created as an encrypted one, f2fs will transfer
    encrypted filename to security module which may fail the check of security
    policy belong to the inode. So in order to this issue, alter to transfer
    original unencrypted filename instead.

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

    Chao Yu
     

30 Aug, 2016

1 commit

  • In the following scenario,

    1) we don't have the key and doing a lookup for encrypted file,
    2) and the encrypted filename is big name

    we should use fname->hash as name hash value instead of what is
    calculated by fname->disk_name. Because in such case,
    fname->disk_name is empty.

    Signed-off-by: Shuoran Liu
    Acked-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Shuoran Liu
     

06 Aug, 2016

1 commit

  • Pull qstr constification updates from Al Viro:
    "Fairly self-contained bunch - surprising lot of places passes struct
    qstr * as an argument when const struct qstr * would suffice; it
    complicates analysis for no good reason.

    I'd prefer to feed that separately from the assorted fixes (those are
    in #for-linus and with somewhat trickier topology)"

    * 'work.const-qstr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    qstr: constify instances in adfs
    qstr: constify instances in lustre
    qstr: constify instances in f2fs
    qstr: constify instances in ext2
    qstr: constify instances in vfat
    qstr: constify instances in procfs
    qstr: constify instances in fuse
    qstr constify instances in fs/dcache.c
    qstr: constify instances in nfs
    qstr: constify instances in ocfs2
    qstr: constify instances in autofs4
    qstr: constify instances in hfs
    qstr: constify instances in hfsplus
    qstr: constify instances in logfs
    qstr: constify dentry_init_security

    Linus Torvalds
     

31 Jul, 2016

1 commit


21 Jul, 2016

1 commit


09 Jul, 2016

1 commit


07 Jul, 2016

1 commit


16 Jun, 2016

1 commit

  • If dotdot directory is corrupted, its slot may be ocupied by another
    file. In this case, dentry[1] is not the parent directory. Rename and
    cross-rename will update the inode in dentry[1] incorrectly. This
    patch finds dotdot dentry by name.

    Signed-off-by: Sheng Yong
    [Jaegeuk Kim: remove wron bug_on]
    Signed-off-by: Jaegeuk Kim

    Sheng Yong
     

14 Jun, 2016

1 commit

  • mkdir sync_dirty_inode
    - init_inode_metadata
    - lock_page(node)
    - make_empty_dir
    - filemap_fdatawrite()
    - do_writepages
    - lock_page(data)
    - write_page(data)
    - lock_page(node)
    - f2fs_init_acl
    - error
    - truncate_inode_pages
    - lock_page(data)

    So, we don't need to truncate data pages in this error case, which will
    be done by f2fs_evict_inode.

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     

08 Jun, 2016

1 commit


03 Jun, 2016

7 commits


22 May, 2016

1 commit

  • Pull f2fs updates from Jaegeuk Kim:
    "In this round, as Ted pointed out, fscrypto allows one more key prefix
    given by filesystem to resolve backward compatibility issues. Other
    than that, we've fixed several error handling cases by introducing
    a fault injection facility. We've also achieved performance
    improvement in some workloads as well as a bunch of bug fixes.

    Summary:

    Enhancements:
    - fs-specific prefix for fscrypto
    - fault injection facility
    - expose validity bitmaps for user to be aware of fragmentation
    - fallocate/rm/preallocation speed up
    - use percpu counters

    Bug fixes:
    - some inline_dentry/inline_data bugs
    - error handling for atomic/volatile/orphan inodes
    - recover broken superblock"

    * tag 'for-f2fs-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (73 commits)
    f2fs: fix to update dirty page count correctly
    f2fs: flush pending bios right away when error occurs
    f2fs: avoid ENOSPC fault in the recovery process
    f2fs: make exit_f2fs_fs more clear
    f2fs: use percpu_counter for total_valid_inode_count
    f2fs: use percpu_counter for alloc_valid_block_count
    f2fs: use percpu_counter for # of dirty pages in inode
    f2fs: use percpu_counter for page counters
    f2fs: use bio count instead of F2FS_WRITEBACK page count
    f2fs: manipulate dirty file inodes when DATA_FLUSH is set
    f2fs: add fault injection to sysfs
    f2fs: no need inc dirty pages under inode lock
    f2fs: fix incorrect error path handling in f2fs_move_rehashed_dirents
    f2fs: fix i_current_depth during inline dentry conversion
    f2fs: correct return value type of f2fs_fill_super
    f2fs: fix deadlock when flush inline data
    f2fs: avoid f2fs_bug_on during recovery
    f2fs: show # of orphan inodes
    f2fs: support in batch fzero in dnode page
    f2fs: support in batch multi blocks preallocation
    ...

    Linus Torvalds
     

11 May, 2016

1 commit


08 May, 2016

3 commits


28 Apr, 2016

2 commits

  • Commit 57b62d29ad5b384775974973087d47755a8c6fcc ("f2fs: fix to report
    error in f2fs_readdir") causes f2fs_readdir to return -ENOENT when
    get_lock_data_page returns -ENOENT. However, the original logic is to
    continue when get_lock_data_page returns -ENOENT, but it forgets to
    reset err to 0.

    This will cause getdents64 incorretly return -ENOENT when lastdirent is
    NULL in getdents64. This will lead to a wrong return value for syscall
    caller.

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

    Yunlong Song
     
  • The filename length in dirent of may become zero-sized after random junk
    data injection, once encounter such dirent, find_target_dentry or
    f2fs_add_inline_entries will run into an infinite loop. So let f2fs being
    aware of that to avoid deadloop.

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

    Chao Yu
     

15 Apr, 2016

1 commit

  • With below serials, we will lose parts of dirents:

    1) mount f2fs with inline_dentry option
    2) echo 1 > /sys/fs/f2fs/sdX/dir_level
    3) mkdir dir
    4) touch 180 files named [1-180] in dir
    5) touch 181 in dir
    6) echo 3 > /proc/sys/vm/drop_caches
    7) ll dir

    ls: cannot access 2: No such file or directory
    ls: cannot access 4: No such file or directory
    ls: cannot access 5: No such file or directory
    ls: cannot access 6: No such file or directory
    ls: cannot access 8: No such file or directory
    ls: cannot access 9: No such file or directory
    ...
    total 360
    drwxr-xr-x 2 root root 4096 Feb 19 15:12 ./
    drwxr-xr-x 3 root root 4096 Feb 19 15:11 ../
    -rw-r--r-- 1 root root 0 Feb 19 15:12 1
    -rw-r--r-- 1 root root 0 Feb 19 15:12 10
    -rw-r--r-- 1 root root 0 Feb 19 15:12 100
    -????????? ? ? ? ? ? 101
    -????????? ? ? ? ? ? 102
    -????????? ? ? ? ? ? 103
    ...

    The reason is: when doing the inline dir conversion, we didn't consider
    that directory has hierarchical hash structure which can be configured
    through sysfs interface 'dir_level'.

    By default, dir_level of directory inode is 0, it means we have one bucket
    in hash table located in first level, all dirents will be hashed in this
    bucket, so it has no problem for us to do the duplication simply between
    inline dentry page and converted normal dentry page.

    However, if we configured dir_level with the value N (greater than 0), it
    will expand the bucket number of first level hash table by 2^N - 1, it
    hashs dirents into different buckets according their hash value, if we
    still move all dirents to first bucket, it makes incorrent locating for
    inline dirents, the result is, although we can iterate all dirents through
    ->readdir, we can't stat some of them in ->lookup which based on hash
    table searching.

    This patch fixes this issue by rehashing dirents into correct position
    when converting inline directory.

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

    Chao Yu
     

05 Apr, 2016

1 commit

  • 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:

    - << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - 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
    Acked-by: Michal Hocko
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

18 Mar, 2016

3 commits

  • Just clean up opened code with existing function, no logic change.

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

    Chao Yu
     
  • This patch tries to catch up with lookup and open policies in ext4.

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • 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
    Signed-off-by: Michael Halcrow
    Signed-off-by: Ildar Muslukhov
    Signed-off-by: Uday Savagaonkar
    Signed-off-by: Theodore Ts'o
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     

23 Feb, 2016

2 commits

  • This patch syncs f2fs with commit 6bc445e0ff44 ("ext4 crypto: make
    sure the encryption info is initialized on opendir(2)") from ext4.

    Signed-off-by: Theodore Ts'o
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • This patch fixes to eliminate garbage name lengths in dentries in order
    to provide correct answers of readdir.

    For example, if a valid dentry consists of:
    bitmap : 1 1 1 1
    len : 32 0 x 0,

    readdir can start with second bit_pos having len = 0.
    Or, it can start with third bit_pos having garbage.

    In both of cases, we should avoid to try filling dentries.
    So, this patch not only removes any garbage length, but also avoid entering
    zero length case in readdir.

    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim