07 Jan, 2021

1 commit

  • * aosp/upstream-f2fs-stable-linux-5.10.y:
    fs-verity: move structs needed for file signing to UAPI header
    fs-verity: rename "file measurement" to "file digest"
    fs-verity: rename fsverity_signed_digest to fsverity_formatted_digest
    fs-verity: remove filenames from file comments
    fscrypt: allow deleting files with unsupported encryption policy
    fscrypt: unexport fscrypt_get_encryption_info()
    fscrypt: move fscrypt_require_key() to fscrypt_private.h
    fscrypt: move body of fscrypt_prepare_setattr() out-of-line
    fscrypt: introduce fscrypt_prepare_readdir()
    ext4: don't call fscrypt_get_encryption_info() from dx_show_leaf()
    ubifs: remove ubifs_dir_open()
    f2fs: remove f2fs_dir_open()
    ext4: remove ext4_dir_open()
    fscrypt: simplify master key locking
    fscrypt: remove unnecessary calls to fscrypt_require_key()
    ubifs: prevent creating duplicate encrypted filenames
    f2fs: prevent creating duplicate encrypted filenames
    ext4: prevent creating duplicate encrypted filenames
    fscrypt: add fscrypt_is_nokey_name()
    fscrypt: remove kernel-internal constants from UAPI header

    Conflicts:
    fs/crypto/hooks.c

    Bug: 174873661
    Signed-off-by: Jaegeuk Kim
    Change-Id: Id56d42fc959242524628752223e9d773a2c8681c

    Jaegeuk Kim
     

29 Dec, 2020

4 commits

  • The last remaining use of fscrypt_get_encryption_info() from filesystems
    is for readdir (->iterate_shared()). Every other call is now in
    fs/crypto/ as part of some other higher-level operation.

    We need to add a new argument to fscrypt_get_encryption_info() to
    indicate whether the encryption policy is allowed to be unrecognized or
    not. Doing this is easier if we can work with high-level operations
    rather than direct filesystem use of fscrypt_get_encryption_info().

    So add a function fscrypt_prepare_readdir() which wraps the call to
    fscrypt_get_encryption_info() for the readdir use case.

    Reviewed-by: Andreas Dilger
    Link: https://lore.kernel.org/r/20201203022041.230976-6-ebiggers@kernel.org
    Signed-off-by: Eric Biggers

    Eric Biggers
     
  • Since encrypted directories can be opened and searched without their key
    being available, and each readdir and ->lookup() tries to set up the
    key, trying to set up the key in ->open() too isn't really useful.

    Just remove it so that directories don't need an ->open() method
    anymore, and so that we eliminate a use of fscrypt_get_encryption_info()
    (which I'd like to stop exporting to filesystems).

    Reviewed-by: Chao Yu
    Link: https://lore.kernel.org/r/20201203022041.230976-3-ebiggers@kernel.org
    Signed-off-by: Eric Biggers

    Eric Biggers
     
  • As described in "fscrypt: add fscrypt_is_nokey_name()", it's possible to
    create a duplicate filename in an encrypted directory by creating a file
    concurrently with adding the directory's encryption key.

    Fix this bug on f2fs by rejecting no-key dentries in f2fs_add_link().

    Note that the weird check for the current task in f2fs_do_add_link()
    seems to make this bug difficult to reproduce on f2fs.

    Fixes: 9ea97163c6da ("f2fs crypto: add filename encryption for f2fs_add_link")
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201118075609.120337-4-ebiggers@kernel.org
    Signed-off-by: Eric Biggers

    Eric Biggers
     
  • * aosp/upstream-f2fs-stable-linux-5.10.y:
    f2fs: compress: fix compression chksum
    f2fs: fix shift-out-of-bounds in sanity_check_raw_super()
    f2fs: fix race of pending_pages in decompression
    f2fs: fix to account inline xattr correctly during recovery
    f2fs: inline: fix wrong inline inode stat
    f2fs: inline: correct comment in f2fs_recover_inline_data
    f2fs: don't check PAGE_SIZE again in sanity_check_raw_super()
    f2fs: convert to F2FS_*_INO macro
    f2fs: introduce max_io_bytes, a sysfs entry, to limit bio size
    f2fs: don't allow any writes on readonly mount
    f2fs: avoid race condition for shrinker count
    f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE
    f2fs: add compress_mode mount option
    f2fs: Remove unnecessary unlikely()
    f2fs: init dirty_secmap incorrectly
    f2fs: remove buffer_head which has 32bits limit
    f2fs: fix wrong block count instead of bytes
    f2fs: use new conversion functions between blks and bytes
    f2fs: rename logical_to_blk and blk_to_logical
    f2fs: fix kbytes written stat for multi-device case
    f2fs: compress: support chksum
    f2fs: fix to avoid REQ_TIME and CP_TIME collision
    f2fs: change to use rwsem for cp_mutex
    f2fs: Handle casefolding with Encryption
    fscrypt: Have filesystems handle their d_ops
    libfs: Add generic function for setting dentry_ops
    f2fs: Remove the redundancy initialization
    f2fs: remove writeback_inodes_sb in f2fs_remount
    f2fs: fix double free of unicode map
    f2fs: fix compat F2FS_IOC_{MOVE,GARBAGE_COLLECT}_RANGE
    f2fs: avoid unneeded data copy in f2fs_ioc_move_range()
    f2fs: add F2FS_IOC_SET_COMPRESS_OPTION ioctl
    f2fs: add F2FS_IOC_GET_COMPRESS_OPTION ioctl
    f2fs: move ioctl interface definitions to separated file
    f2fs: fix to seek incorrect data offset in inline data file
    f2fs: call f2fs_get_meta_page_retry for nat page

    Bug: 174873661
    Signed-off-by: Jaegeuk Kim
    Change-Id: I1edcbc31855a7b9d5fd5623ad0fd420e4885eaf2

    Jaegeuk Kim
     

27 Dec, 2020

1 commit

  • Changes in 5.10.3
    net: ipconfig: Avoid spurious blank lines in boot log
    x86/split-lock: Avoid returning with interrupts enabled
    exfat: Avoid allocating upcase table using kcalloc()
    soc/tegra: fuse: Fix index bug in get_process_id
    usb: mtu3: fix memory corruption in mtu3_debugfs_regset()
    USB: serial: option: add interface-number sanity check to flag handling
    USB: gadget: f_acm: add support for SuperSpeed Plus
    USB: gadget: f_midi: setup SuperSpeed Plus descriptors
    usb: gadget: f_fs: Re-use SS descriptors for SuperSpeedPlus
    USB: gadget: f_rndis: fix bitrate for SuperSpeed and above
    usb: chipidea: ci_hdrc_imx: Pass DISABLE_DEVICE_STREAMING flag to imx6ul
    ARM: dts: exynos: fix roles of USB 3.0 ports on Odroid XU
    ARM: dts: exynos: fix USB 3.0 VBUS control and over-current pins on Exynos5410
    ARM: dts: exynos: fix USB 3.0 pins supply being turned off on Odroid XU
    coresight: tmc-etf: Fix NULL ptr dereference in tmc_enable_etf_sink_perf()
    coresight: tmc-etr: Check if page is valid before dma_map_page()
    coresight: tmc-etr: Fix barrier packet insertion for perf buffer
    coresight: etb10: Fix possible NULL ptr dereference in etb_enable_perf()
    coresight: etm4x: Skip setting LPOVERRIDE bit for qcom, skip-power-up
    coresight: etm4x: Fix accesses to TRCVMIDCTLR1
    coresight: etm4x: Fix accesses to TRCCIDCTLR1
    coresight: etm4x: Fix accesses to TRCPROCSELR
    coresight: etm4x: Handle TRCVIPCSSCTLR accesses
    f2fs: fix to seek incorrect data offset in inline data file
    f2fs: init dirty_secmap incorrectly
    scsi: megaraid_sas: Check user-provided offsets
    HID: i2c-hid: add Vero K147 to descriptor override
    serial_core: Check for port state when tty is in error state
    fscrypt: remove kernel-internal constants from UAPI header
    fscrypt: add fscrypt_is_nokey_name()
    ubifs: prevent creating duplicate encrypted filenames
    ext4: prevent creating duplicate encrypted filenames
    f2fs: prevent creating duplicate encrypted filenames
    Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt()
    quota: Sanity-check quota file headers on load
    fs: quota: fix array-index-out-of-bounds bug by passing correct argument to vfs_cleanup_quota_inode()
    media: msi2500: assign SPI bus number dynamically
    crypto: af_alg - avoid undefined behavior accessing salg_name
    nl80211: validate key indexes for cfg80211_registered_device
    md: fix a warning caused by a race between concurrent md_ioctl()s
    Linux 5.10.3

    Signed-off-by: Greg Kroah-Hartman
    Change-Id: Ia12e3bc535549040a55f8dfb70921d99882e79f5

    Greg Kroah-Hartman
     

26 Dec, 2020

3 commits

  • commit bfc2b7e8518999003a61f91c1deb5e88ed77b07d upstream.

    As described in "fscrypt: add fscrypt_is_nokey_name()", it's possible to
    create a duplicate filename in an encrypted directory by creating a file
    concurrently with adding the directory's encryption key.

    Fix this bug on f2fs by rejecting no-key dentries in f2fs_add_link().

    Note that the weird check for the current task in f2fs_do_add_link()
    seems to make this bug difficult to reproduce on f2fs.

    Fixes: 9ea97163c6da ("f2fs crypto: add filename encryption for f2fs_add_link")
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201118075609.120337-4-ebiggers@kernel.org
    Signed-off-by: Eric Biggers
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • commit 5335bfc6eb688344bfcd4b4133c002c0ae0d0719 upstream.

    section is dirty, but dirty_secmap may not set

    Reported-by: Jia Yang
    Fixes: da52f8ade40b ("f2fs: get the right gc victim section when section has several segments")
    Cc:
    Signed-off-by: Jack Qiu
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Jack Qiu
     
  • commit 7a6e59d719ef0ec9b3d765cba3ba98ee585cbde3 upstream.

    As kitestramuort reported:

    F2FS-fs (nvme0n1p4): access invalid blkaddr:1598541474
    [ 25.725898] ------------[ cut here ]------------
    [ 25.725903] WARNING: CPU: 6 PID: 2018 at f2fs_is_valid_blkaddr+0x23a/0x250
    [ 25.725923] Call Trace:
    [ 25.725927] ? f2fs_llseek+0x204/0x620
    [ 25.725929] ? ovl_copy_up_data+0x14f/0x200
    [ 25.725931] ? ovl_copy_up_inode+0x174/0x1e0
    [ 25.725933] ? ovl_copy_up_one+0xa22/0xdf0
    [ 25.725936] ? ovl_copy_up_flags+0xa6/0xf0
    [ 25.725938] ? ovl_aio_cleanup_handler+0xd0/0xd0
    [ 25.725939] ? ovl_maybe_copy_up+0x86/0xa0
    [ 25.725941] ? ovl_open+0x22/0x80
    [ 25.725943] ? do_dentry_open+0x136/0x350
    [ 25.725945] ? path_openat+0xb7e/0xf40
    [ 25.725947] ? __check_sticky+0x40/0x40
    [ 25.725948] ? do_filp_open+0x70/0x100
    [ 25.725950] ? __check_sticky+0x40/0x40
    [ 25.725951] ? __check_sticky+0x40/0x40
    [ 25.725953] ? __x64_sys_openat+0x1db/0x2c0
    [ 25.725955] ? do_syscall_64+0x2d/0x40
    [ 25.725957] ? entry_SYSCALL_64_after_hwframe+0x44/0xa9

    llseek() reports invalid block address access, the root cause is if
    file has inline data, f2fs_seek_block() will access inline data regard
    as block address index in inode block, which should be wrong, fix it.

    Reported-by: kitestramuort
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Chao Yu
     

22 Dec, 2020

31 commits

  • This patch addresses minor issues in compression chksum.

    Fixes: b28f047b28c5 ("f2fs: compress: support chksum")
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • syzbot reported a bug which could cause shift-out-of-bounds issue,
    fix it.

    Call Trace:
    __dump_stack lib/dump_stack.c:79 [inline]
    dump_stack+0x107/0x163 lib/dump_stack.c:120
    ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
    __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:395
    sanity_check_raw_super fs/f2fs/super.c:2812 [inline]
    read_raw_super_block fs/f2fs/super.c:3267 [inline]
    f2fs_fill_super.cold+0x16c9/0x16f6 fs/f2fs/super.c:3519
    mount_bdev+0x34d/0x410 fs/super.c:1366
    legacy_get_tree+0x105/0x220 fs/fs_context.c:592
    vfs_get_tree+0x89/0x2f0 fs/super.c:1496
    do_new_mount fs/namespace.c:2896 [inline]
    path_mount+0x12ae/0x1e70 fs/namespace.c:3227
    do_mount fs/namespace.c:3240 [inline]
    __do_sys_mount fs/namespace.c:3448 [inline]
    __se_sys_mount fs/namespace.c:3425 [inline]
    __x64_sys_mount+0x27f/0x300 fs/namespace.c:3425
    do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Reported-by: syzbot+ca9a785f8ac472085994@syzkaller.appspotmail.com
    Signed-off-by: Anant Thazhemadam
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • I found out f2fs_free_dic() is invoked in a wrong timing, but
    f2fs_verify_bio() still needed the dic info and it triggered the
    below kernel panic. It has been caused by the race condition of
    pending_pages value between decompression and verity logic, when
    the same compression cluster had been split in different bios.
    By split bios, f2fs_verify_bio() ended up with decreasing
    pending_pages value before it is reset to nr_cpages by
    f2fs_decompress_pages() and caused the kernel panic.

    [ 4416.564763] Unable to handle kernel NULL pointer dereference
    at virtual address 0000000000000000
    ...
    [ 4416.896016] Workqueue: fsverity_read_queue f2fs_verity_work
    [ 4416.908515] pc : fsverity_verify_page+0x20/0x78
    [ 4416.913721] lr : f2fs_verify_bio+0x11c/0x29c
    [ 4416.913722] sp : ffffffc019533cd0
    [ 4416.913723] x29: ffffffc019533cd0 x28: 0000000000000402
    [ 4416.913724] x27: 0000000000000001 x26: 0000000000000100
    [ 4416.913726] x25: 0000000000000001 x24: 0000000000000004
    [ 4416.913727] x23: 0000000000001000 x22: 0000000000000000
    [ 4416.913728] x21: 0000000000000000 x20: ffffffff2076f9c0
    [ 4416.913729] x19: ffffffff2076f9c0 x18: ffffff8a32380c30
    [ 4416.913731] x17: ffffffc01f966d97 x16: 0000000000000298
    [ 4416.913732] x15: 0000000000000000 x14: 0000000000000000
    [ 4416.913733] x13: f074faec89ffffff x12: 0000000000000000
    [ 4416.913734] x11: 0000000000001000 x10: 0000000000001000
    [ 4416.929176] x9 : ffffffff20d1f5c7 x8 : 0000000000000000
    [ 4416.929178] x7 : 626d7464ff286b6b x6 : ffffffc019533ade
    [ 4416.929179] x5 : 000000008049000e x4 : ffffffff2793e9e0
    [ 4416.929180] x3 : 000000008049000e x2 : ffffff89ecfa74d0
    [ 4416.929181] x1 : 0000000000000c40 x0 : ffffffff2076f9c0
    [ 4416.929184] Call trace:
    [ 4416.929187] fsverity_verify_page+0x20/0x78
    [ 4416.929189] f2fs_verify_bio+0x11c/0x29c
    [ 4416.929192] f2fs_verity_work+0x58/0x84
    [ 4417.050667] process_one_work+0x270/0x47c
    [ 4417.055354] worker_thread+0x27c/0x4d8
    [ 4417.059784] kthread+0x13c/0x320
    [ 4417.063693] ret_from_fork+0x10/0x18

    Chao pointed this can happen by the below race condition.

    Thread A f2fs_post_read_wq fsverity_wq
    - f2fs_read_multi_pages()
    - f2fs_alloc_dic
    - dic->pending_pages = 2
    - submit_bio()
    - submit_bio()
    - f2fs_post_read_work() handle first bio
    - f2fs_decompress_work()
    - __read_end_io()
    - f2fs_decompress_pages()
    - dic->pending_pages--
    - enqueue f2fs_verity_work()
    - f2fs_verity_work() handle first bio
    - f2fs_verify_bio()
    - dic->pending_pages--
    - f2fs_post_read_work() handle second bio
    - f2fs_decompress_work()
    - enqueue f2fs_verity_work()
    - f2fs_verify_pages()
    - f2fs_free_dic()

    - f2fs_verity_work() handle second bio
    - f2fs_verfy_bio()
    - use-after-free on dic

    Signed-off-by: Daeho Jeong
    Signed-off-by: Jaegeuk Kim

    Daeho Jeong
     
  • During recovery, we may missed to update inline xattr count correctly,
    fix it.

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

    Chao Yu
     
  • Miss to stat inline inode in f2fs_recover_inline_data.

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

    Jack Qiu
     
  • In 3rd scene, it should remove data blocks instead of inline_data.

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

    Jack Qiu
     
  • Many flash devices read and write a single IO based on a multiple
    of 4KB, and we support only 4KB page cache size now.

    Since we already check page size in init_f2fs_fs(), so remove page
    size check in sanity_check_raw_super().

    Signed-off-by: Yangtao Li
    Signed-off-by: Shaohua Liu
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Yangtao Li
     
  • Use F2FS_ROOT_INO, F2FS_NODE_INO and F2FS_META_INO macro
    for better code readability.

    Signed-off-by: Yangtao Li
    Signed-off-by: Shaohua Liu
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Yangtao Li
     
  • This patch adds max_io_bytes to limit bio size when f2fs tries to merge
    consecutive IOs. This can give a testing point to split out bios and check
    end_io handles those bios correctly. This is used to capture a recent bug
    on the decompression and fsverity flow.

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

    Jaegeuk Kim
     
  • generic_make_request: Trying to write to read-only block-device dm-5 (partno 0)
    WARNING: CPU: 7 PID: 546 at block/blk-core.c:2190 generic_make_request_checks+0x664/0x690
    pc : generic_make_request_checks+0x664/0x690
    lr : generic_make_request_checks+0x664/0x690
    Call trace:
    generic_make_request_checks+0x664/0x690
    generic_make_request+0xf0/0x3a4
    submit_bio+0x80/0x250
    __submit_merged_bio+0x368/0x4e0
    __submit_merged_write_cond.llvm.12294350193007536502+0xe0/0x3e8
    f2fs_wait_on_page_writeback+0x84/0x128
    f2fs_convert_inline_page+0x35c/0x6f8
    f2fs_convert_inline_inode+0xe0/0x2e0
    f2fs_file_mmap+0x48/0x9c
    mmap_region+0x41c/0x74c
    do_mmap+0x40c/0x4fc
    vm_mmap_pgoff+0xb8/0x114
    vm_mmap+0x34/0x48
    elf_map+0x68/0x108
    load_elf_binary+0x538/0xb70
    search_binary_handler+0xac/0x1dc
    exec_binprm+0x50/0x15c
    __do_execve_file+0x620/0x740
    __arm64_sys_execve+0x54/0x68
    el0_svc_common+0x9c/0x168
    el0_svc_handler+0x60/0x6c
    el0_svc+0x8/0xc

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

    Jaegeuk Kim
     
  • Light reported sometimes shinker gets nat_cnt < dirty_nat_cnt resulting in
    wrong do_shinker work. Let's avoid to return insane overflowed value by adding
    single tracking value.

    Reported-by: Light Hsieh
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • Added two ioctl to decompress/compress explicitly the compression
    enabled file in "compress_mode=user" mount option.

    Using these two ioctls, the users can make a control of compression
    and decompression of their files.

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

    Daeho Jeong
     
  • We will add a new "compress_mode" mount option to control file
    compression mode. This supports "fs" and "user". In "fs" mode (default),
    f2fs does automatic compression on the compression enabled files.
    In "user" mode, f2fs disables the automaic compression and gives the
    user discretion of choosing the target file and the timing. It means
    the user can do manual compression/decompression on the compression
    enabled files using ioctls.

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

    Daeho Jeong
     
  • WARN_ON() already contains an unlikely(), so it's not necessary
    to use unlikely.

    Signed-off-by: Yangtao Li
    Signed-off-by: Shuosheng Huang
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Yangtao Li
     
  • section is dirty, but dirty_secmap may not set

    Reported-by: Jia Yang
    Fixes: da52f8ade40b ("f2fs: get the right gc victim section when section has several segments")
    Cc:
    Signed-off-by: Jack Qiu
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Jack Qiu
     
  • This patch removes buffer_head dependency when getting block addresses.
    Light reported there's a 32bit issue in f2fs_fiemap where map_bh.b_size is
    32bits while len is 64bits given by user. This will give wrong length to
    f2fs_map_block.

    Reported-by: Light Hsieh
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • We should convert cur_lblock, a block count, to bytes for len.

    Fixes: af4b6b8edf6a ("f2fs: introduce check_swap_activate_fast()")
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • This patch cleans up blks and bytes conversions.

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

    Jaegeuk Kim
     
  • This patch renames two functions like below having u64.
    - logical_to_blk to bytes_to_blks
    - blk_to_logical to blks_to_bytes

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

    Jaegeuk Kim
     
  • For multi-device case, one f2fs image includes multi devices, so it
    needs to account bytes written of all block devices belong to the image
    rather than one main block device, fix it.

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

    Chao Yu
     
  • This patch supports to store chksum value with compressed
    data, and verify the integrality of compressed data while
    reading the data.

    The feature can be enabled through specifying mount option
    'compress_chksum'.

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

    Chao Yu
     
  • Lei Li reported a issue: if foreground operations are frequent, background
    checkpoint may be always skipped due to below check, result in losing more
    data after sudden power-cut.

    f2fs_balance_fs_bg()
    ...
    if (!is_idle(sbi, REQ_TIME) &&
    (!excess_dirty_nats(sbi) && !excess_dirty_nodes(sbi)))
    return;

    E.g:
    cp_interval = 5 second
    idle_interval = 2 second
    foreground operation interval = 1 second (append 1 byte per second into file)

    In such case, no matter when it calls f2fs_balance_fs_bg(), is_idle(, REQ_TIME)
    returns false, result in skipping background checkpoint.

    This patch changes as below to make trigger condition being more reasonable:
    - trigger sync_fs() if dirty_{nats,nodes} and prefree segs exceeds threshold;
    - skip triggering sync_fs() if there is any background inflight IO or there is
    foreground operation recently and meanwhile cp_rwsem is being held by someone;

    Reported-by: Lei Li
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • Use rwsem to ensure serialization of the callers and to avoid
    starvation of high priority tasks, when the system is under
    heavy IO workload.

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

    Sahitya Tummala
     
  • Expand f2fs's casefolding support to include encrypted directories. To
    index casefolded+encrypted directories, we use the SipHash of the
    casefolded name, keyed by a key derived from the directory's fscrypt
    master key. This ensures that the dirhash doesn't leak information
    about the plaintext filenames.

    Encryption keys are unavailable during roll-forward recovery, so we
    can't compute the dirhash when recovering a new dentry in an encrypted +
    casefolded directory. To avoid having to force a checkpoint when a new
    file is fsync'ed, store the dirhash on-disk appended to i_name.

    This patch incorporates work by Eric Biggers
    and Jaegeuk Kim .

    Co-developed-by: Eric Biggers
    Signed-off-by: Eric Biggers
    Signed-off-by: Daniel Rosenberg
    Reviewed-by: Eric Biggers
    Signed-off-by: Jaegeuk Kim

    Daniel Rosenberg
     
  • This shifts the responsibility of setting up dentry operations from
    fscrypt to the individual filesystems, allowing them to have their own
    operations while still setting fscrypt's d_revalidate as appropriate.

    Most filesystems can just use generic_set_encrypted_ci_d_ops, unless
    they have their own specific dentry operations as well. That operation
    will set the minimal d_ops required under the circumstances.

    Since the fscrypt d_ops are set later on, we must set all d_ops there,
    since we cannot adjust those later on. This should not result in any
    change in behavior.

    Signed-off-by: Daniel Rosenberg
    Acked-by: Theodore Ts'o
    Acked-by: Eric Biggers
    Signed-off-by: Jaegeuk Kim

    Daniel Rosenberg
     
  • There are two assignments are meaningless, and remove them.

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

    Zhang Qilong
     
  • Since sync_inodes_sb has been used, there is no need to
    use writeback_inodes_sb, so remove it.

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

    Liu Song
     
  • In case of retrying fill_super with skip_recovery,
    s_encoding for casefold would not be loaded again even though it's
    already been freed because it's not NULL.
    Set NULL after free to prevent double freeing when unmount.

    Fixes: eca4873ee1b6 ("f2fs: Use generic casefolding support")
    Signed-off-by: Hyeongseok Kim
    Reviewed-by: Chao Yu
    Signed-off-by: Jaegeuk Kim

    Hyeongseok Kim
     
  • Eric reported a ioctl bug in below link:

    https://lore.kernel.org/linux-f2fs-devel/20201103032234.GB2875@sol.localdomain/

    That said, on some 32-bit architectures, u64 has only 32-bit alignment,
    notably i386 and x86_32, so that size of struct f2fs_gc_range compiled
    in x86_32 is 20 bytes, however the size in x86_64 is 24 bytes, binary
    compiled in x86_32 can not call F2FS_IOC_GARBAGE_COLLECT_RANGE successfully
    due to mismatched value of ioctl command in between binary and f2fs
    module, similarly, F2FS_IOC_MOVE_RANGE will fail too.

    In this patch we introduce two ioctls for compatibility of above special
    32-bit binary:
    - F2FS_IOC32_GARBAGE_COLLECT_RANGE
    - F2FS_IOC32_MOVE_RANGE

    Reported-by: Eric Biggers
    Signed-off-by: Chao Yu
    Reviewed-by: Eric Biggers
    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • Fields in struct f2fs_move_range won't change in f2fs_ioc_move_range(),
    let's avoid copying this structure's data to userspace.

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

    Chao Yu
     
  • Added a new F2FS_IOC_SET_COMPRESS_OPTION ioctl to change file
    compression option of a file.

    struct f2fs_comp_option {
    u8 algorithm; => compression algorithm
    => 0:lzo, 1:lz4, 2:zstd, 3:lzorle
    u8 log_cluster_size; => log scale cluster size
    => 2 ~ 8
    };

    struct f2fs_comp_option option;

    option.algorithm = 1;
    option.log_cluster_size = 7;

    ioctl(fd, F2FS_IOC_SET_COMPRESS_OPTION, &option);

    Signed-off-by: Daeho Jeong
    [Chao Yu: remove f2fs_is_compress_algorithm_valid()]
    Signed-off-by: Jaegeuk Kim

    Daeho Jeong