1. 01 Jun, 2015 12 commits
    • Jaegeuk Kim's avatar
      f2fs crypto: split f2fs_crypto_init/exit with two parts · cfc4d971
      Jaegeuk Kim authored
      This patch splits f2fs_crypto_init/exit with two parts: base initialization and
      memory allocation.
      
      Firstly, f2fs module declares the base encryption memory pointers.
      Then, allocating internal memories is done at the first encrypted inode access.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      cfc4d971
    • Chao Yu's avatar
      f2fs crypto: fix incorrect release for crypto ctx · b9da898b
      Chao Yu authored
      When encryption feature is enable, if we rmmod f2fs module,
      we will encounter a stack backtrace reported in syslog:
      
      "BUG: Bad page state in process rmmod  pfn:aaf8a
      page:f0f4f148 count:0 mapcount:129 mapping:ee2f4104 index:0x80
      flags: 0xee2830a4(referenced|lru|slab|private_2|writeback|swapbacked|mlocked)
      page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set
      bad because of flags:
      flags: 0x2030a0(lru|slab|private_2|writeback|mlocked)
      Modules linked in: f2fs(O-) fuse bnep rfcomm bluetooth dm_crypt binfmt_misc snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm
      snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer snd_seq_device joydev ppdev mac_hid lp hid_generic i2c_piix4
      parport_pc psmouse snd serio_raw parport soundcore ext4 jbd2 mbcache usbhid hid e1000 [last unloaded: f2fs]
      CPU: 1 PID: 3049 Comm: rmmod Tainted: G    B      O    4.1.0-rc3+ #10
      Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      00000000 00000000 c0021eb4 c15b7518 f0f4f148 c0021ed8 c112e0b7 c1779174
      c9b75674 000aaf8a 01b13ce1 c17791a4 f0f4f148 ee2830a4 c0021ef8 c112e3c3
      00000000 f0f4f148 c0021f34 f0f4f148 ee2830a4 ef9f0000 c0021f20 c112fdf8
      Call Trace:
      [<c15b7518>] dump_stack+0x41/0x52
      [<c112e0b7>] bad_page.part.72+0xa7/0x100
      [<c112e3c3>] free_pages_prepare+0x213/0x220
      [<c112fdf8>] free_hot_cold_page+0x28/0x120
      [<c1073380>] ? try_to_wake_up+0x2b0/0x2b0
      [<c112ff15>] __free_pages+0x25/0x30
      [<c112c4fd>] mempool_free_pages+0xd/0x10
      [<c112c5f1>] mempool_free+0x31/0x90
      [<f0f441cf>] f2fs_exit_crypto+0x6f/0xf0 [f2fs]
      [<f0f456c4>] exit_f2fs_fs+0x23/0x95f [f2fs]
      [<c10c30e0>] SyS_delete_module+0x130/0x180
      [<c11556d6>] ? vm_munmap+0x46/0x60
      [<c15bd888>] sysenter_do_call+0x12/0x12"
      
      The reason is that:
      
      since commit 0827e645fd35
      ("f2fs crypto: shrink size of the f2fs_crypto_ctx structure") is merged,
      some fields in f2fs_crypto_ctx structure are merged into a union as they
      will never be used simultaneously in write path, read path or on free list.
      
      In f2fs_exit_crypto, we traverse each crypto ctx from free list, in this
      moment, our free_list field in union is valid, but still we will try to
      release memory space which is pointed by other invalid field in union
      structure for each ctx.
      
      Then the error occurs, let's fix it with this patch.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      b9da898b
    • Chao Yu's avatar
      f2fs crypto: fix to release buffer for fname crypto · 7bf4b557
      Chao Yu authored
      This patch fixes memory leak issue in error path of f2fs_fname_setup_filename().
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7bf4b557
    • Jaegeuk Kim's avatar
      f2fs crypto: shrink size of the f2fs_crypto_ctx structure · ca40b030
      Jaegeuk Kim authored
      This patch integrates the below patch into f2fs.
      
      "ext4 crypto: shrink size of the ext4_crypto_ctx structure
      
      Some fields are only used when the crypto_ctx is being used on the
      read path, some are only used on the write path, and some are only
      used when the structure is on free list.  Optimize memory use by using
      a union."
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      ca40b030
    • Jaegeuk Kim's avatar
      f2fs crypto: get rid of ci_mode from struct f2fs_crypt_info · 640778fb
      Jaegeuk Kim authored
      This patch integrates the below patch into f2fs.
      
      "ext4 crypto: get rid of ci_mode from struct ext4_crypt_info
      
      The ci_mode field was superfluous, and getting rid of it gets rid of
      an unused hole in the structure."
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      640778fb
    • Jaegeuk Kim's avatar
      f2fs crypto: use slab caches · 8bacf6de
      Jaegeuk Kim authored
      This patch integrates the below patch into f2fs.
      
      "ext4 crypto: use slab caches
      
      Use slab caches the ext4_crypto_ctx and ext4_crypt_info structures for
      slighly better memory efficiency and debuggability."
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      8bacf6de
    • Jaegeuk Kim's avatar
      f2fs: truncate data blocks for orphan inode · 06e1bc05
      Jaegeuk Kim authored
      As Hu reported, F2FS has a space leak problem, when conducting:
      
      1) format a 4GB f2fs partition
      2) dd a 3G file,
      3) unlink it.
      
      So, when doing f2fs_drop_inode(), we need to truncate data blocks
      before skipping it.
      We can also drop unused caches assigned to each inode.
      Reported-by: default avatarhujianyang <hujianyang@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      06e1bc05
    • Dan Carpenter's avatar
      f2fs: cleanup a confusing indent · 912a83b5
      Dan Carpenter authored
      The return was not indented far enough so it looked like it was supposed
      to go with the other if statement.
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      912a83b5
    • Arnd Bergmann's avatar
      f2fs: fix building on 32-bit architectures · 7beb428e
      Arnd Bergmann authored
      A bug fix to the debug output extended the type of some local
      variables to 64-bit, which now causes the kernel to fail building
      because of missing 64-bit division functions:
      
      ERROR: "__aeabi_uldivmod" [fs/f2fs/f2fs.ko] undefined!
      
      In the kernel, we have to use div_u64 or do_div to do this,
      in order to annotate that this is an expensive operation.
      
      As the function is only called for debug out, we know this
      is not performance critical, so it is safe to use div_u64.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Fixes: d1f85bd38db19 ("f2fs: avoid value overflow in showing current status")
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7beb428e
    • Jaegeuk Kim's avatar
      f2fs: avoid buggy functions · e19ef527
      Jaegeuk Kim authored
      This patch avoids to use a buggy function for now.
      It needs to fix them later.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e19ef527
    • hujianyang's avatar
      f2fs: add compat_ioctl to provide backward compatability · 08b95126
      hujianyang authored
      introduce compat_ioctl to regular files, but doesn't add this
      functionality to f2fs_dir_operations.
      
      While running a 32-bit busybox, I met an error like this:
      (A is a directory)
      
      chattr: reading flags on A: Inappropriate ioctl for device
      
      This patch copies compat_ioctl from f2fs_file_operations and
      fix this problem.
      Signed-off-by: default avatarhujianyang <hujianyang@huawei.com>
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      08b95126
    • Jaegeuk Kim's avatar
      f2fs: do not issue next dnode discard redundantly · 40a02be1
      Jaegeuk Kim authored
      We have a discard map, so that we can avoid redundant discard issues.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      40a02be1
  2. 28 May, 2015 28 commits