1. 09 Oct, 2015 14 commits
    • Chao Yu's avatar
      f2fs: do in batches truncation in truncate_hole · ea58711e
      Chao Yu authored
      truncate_data_blocks_range can do in batches truncation which makes all
      changes in dnode page content, dnode page status, extent cache, block
      count updating together.
      
      But previously, truncate_hole() always truncates one block in dnode page
      at a time by invoking truncate_data_blocks_range(,1), which make thing
      slow.
      
      This patch changes truncate_hole() to do in batches truncation for all
      target blocks in one direct node inside truncate_data_blocks_range, which
      can make our punch hole operation in ->fallocate more efficent.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      ea58711e
    • Fan Li's avatar
      f2fs: optimize code of f2fs_update_extent_tree_range · 4d1fa815
      Fan Li authored
      Fix 2 potential problems:
      1. when largest extent needs to be invalidated, it will be reset in
         __drop_largest_extent, which makes __is_extent_same after always
         return false, and largest extent unchanged. Now we update it properly.
      
      2. when extent is split and the latter part remains in tree, next_en
         should be the latter part instead of next extent of original extent.
         It will cause merge failure if there is in-place update, although
         there is not, I think this fix will still makes codes less ambiguous.
      
      This patch also simplifies codes of invalidating extents, and optimizes the
      procedues that split extent into two.
      There are a few modifications after last patch:
      1. prev_en now is updated properly.
      2. more codes and branches are simplified.
      Signed-off-by: default avatarFan li <fanofcode.li@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      4d1fa815
    • Fan Li's avatar
      f2fs: drop largest extent by range · 41a099de
      Fan Li authored
      now we update extent by range, fofs may not be on the largest
      extent if the new extent overlaps with it. so add a new function
      to drop largest extent properly.
      Signed-off-by: default avatarFan li <fanofcode.li@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      41a099de
    • Jaegeuk Kim's avatar
      f2fs: check end_io for metapages before making next checkpoint blocks · a7230d16
      Jaegeuk Kim authored
      This patch avoids to produce new checkpoint blocks before the previous meta
      pages were written completely.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      a7230d16
    • Jaegeuk Kim's avatar
      f2fs crypto: allocate buffer for decrypting filename · 569cf187
      Jaegeuk Kim authored
      We got dentry pages from high_mem, and its address space directly goes into the
      decryption path via f2fs_fname_disk_to_usr.
      But, sg_init_one assumes the address is not from high_mem, so we can get this
      panic since it doesn't call kmap_high but kunmap_high is triggered at the end.
      
      kernel BUG at ../../../../../../kernel/mm/highmem.c:290!
      Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
      ...
       (kunmap_high+0xb0/0xb8) from [<c0114534>] (__kunmap_atomic+0xa0/0xa4)
       (__kunmap_atomic+0xa0/0xa4) from [<c035f028>] (blkcipher_walk_done+0x128/0x1ec)
       (blkcipher_walk_done+0x128/0x1ec) from [<c0366c24>] (crypto_cbc_decrypt+0xc0/0x170)
       (crypto_cbc_decrypt+0xc0/0x170) from [<c0367148>] (crypto_cts_decrypt+0xc0/0x114)
       (crypto_cts_decrypt+0xc0/0x114) from [<c035ea98>] (async_decrypt+0x40/0x48)
       (async_decrypt+0x40/0x48) from [<c032ca34>] (f2fs_fname_disk_to_usr+0x124/0x304)
       (f2fs_fname_disk_to_usr+0x124/0x304) from [<c03056fc>] (f2fs_fill_dentries+0xac/0x188)
       (f2fs_fill_dentries+0xac/0x188) from [<c03059c8>] (f2fs_readdir+0x1f0/0x300)
       (f2fs_readdir+0x1f0/0x300) from [<c0218054>] (vfs_readdir+0x90/0xb4)
       (vfs_readdir+0x90/0xb4) from [<c0218418>] (SyS_getdents64+0x64/0xcc)
       (SyS_getdents64+0x64/0xcc) from [<c0105ba0>] (ret_fast_syscall+0x0/0x30)
      
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      569cf187
    • Chao Yu's avatar
      f2fs: reorganize f2fs_map_blocks · 973163fc
      Chao Yu authored
      In this patch, we try to reorganize f2fs_map_blocks to make block mapping
      flow more clear by using following structure:
      
      /* check status of mapping */
      
      if (unmapped) {
      	/* blkaddr == NULL_ADDR || blkaddr == NEW_ADDR */
      
      	if (create) {
      		/* write path, handle dio write case here */
      		alloc_and_map;
      	} else {
      		/*
      		 * handle read cases from all call paths:
      		 *     1. generic read;
      		 *     2. dio read;
      		 *     3. fiemap;
      		 *     4. bmap
      		 */
      	}
      }
      
      /* map buffer_header */
      
      Besides, this patch handles the missing case correctly for dio write:
      When we fail in __allocate_data_blocks, then in f2fs_map_blocks, we will
      not allocate blocks correctly for preallocated blocks, but returning with
      an unmapped buffer head, which will result in failure of dio write.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      973163fc
    • Jaegeuk Kim's avatar
      f2fs: declare f2fs_update_extent_tree_range as static · 514053e4
      Jaegeuk Kim authored
      This function should be static.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      514053e4
    • Chao Yu's avatar
      f2fs: fix overflow of size calculation · 9edcdabf
      Chao Yu authored
      We have potential overflow issue when calculating size of object, when
      we left shift index with PAGE_CACHE_SHIFT bits, if type of index has only
      32-bits space in 32-bit architecture, left shifting will incur overflow,
      i.e:
      
      pgoff_t index =  0xFFFFFFFF;
      loff_t size = index << PAGE_CACHE_SHIFT;
      size: 0xFFFFF000
      
      So we should cast index with 64-bits type to avoid this issue.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      9edcdabf
    • Chao Yu's avatar
      f2fs: fix incorrect searching position when shrinking extent cache · 100136ac
      Chao Yu authored
      When shrinking extent cache, we have two steps in the flow:
      1) shrink objects which are unreferenced by inodes;
      2) shrink objects from LRU list of extent cache.
      
      In step 1, if we haven't shrunk enough number of objects, we will try
      step 2, but before that we didn't update the searching position which
      may point to last inode index in global extent tree, result in failing
      to shrink objects by traversing the all inodes' extent tree.
      
      In this patch, we reset searching position to beginning of global extent
      tree for fixing.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      100136ac
    • Chao Yu's avatar
      f2fs: verify file type early in f2fs_fallocate · c998012b
      Chao Yu authored
      This patch changes to verify file type early in f2fs_fallocate for
      cleanup, meanwhile this also fixes to add missing verification for
      expand_inode_data.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      c998012b
    • Jaegeuk Kim's avatar
      f2fs: no need to lock for update_inode_page all the time · c5cd29d2
      Jaegeuk Kim authored
      As comment says, we don't need to call f2fs_lock_op in write_inode to prevent
      from producing dirty node pages all the time.
      That happens only when there is not enough free sections and we can avoid that
      by calling balance_fs in prior to that.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      c5cd29d2
    • Jaegeuk Kim's avatar
      f2fs: cover number of dirty node pages under node_write lock · 25b93346
      Jaegeuk Kim authored
      This number is referenced by checkpoint under node_write lock.
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      25b93346
    • Nicholas Krause's avatar
      f2fs: fix incorrect return statement in the function f2fs_ioc_release_volatile_write · 538e17e7
      Nicholas Krause authored
      This fixes the incorrect return statement at the end of the function
      f2fs_ioc_release_volatile_write's body for returning zero as this is
      incorrect due to the function call before this return statement to
      the function punch_hole being able to fail and we should return this
      function's return fail directly in order to signal to callers of the
      function f2fs_ioc_release_volatile if a failure arises with this call
      to punch_hole fails.
      Signed-off-by: default avatarNicholas Krause <xerofoify@gmail.com>
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      538e17e7
    • Chao Yu's avatar
      f2fs: trace in batches extent info update · 744288c7
      Chao Yu authored
      Rename trace_f2fs_update_extent_tree to trace_f2fs_update_extent_tree_range,
      then expand and enable it to trace in batches extent info updates.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      744288c7
  2. 07 Oct, 2015 11 commits
  3. 06 Oct, 2015 12 commits
    • Anna Schumaker's avatar
      NFS: Fix a tracepoint NULL-pointer dereference · 39d0d3bd
      Anna Schumaker authored
      Running xfstest generic/013 with the tracepoint nfs:nfs4_open_file
      enabled produces a NULL-pointer dereference when calculating fileid and
      filehandle of the opened file.  Fix this by checking if state is NULL
      before trying to use the inode pointer.
      Reported-by: default avatarOlga Kornievskaia <aglo@umich.edu>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      39d0d3bd
    • Chris Metcalf's avatar
      strscpy: zero any trailing garbage bytes in the destination · 990486c8
      Chris Metcalf authored
      It's possible that the destination can be shadowed in userspace
      (as, for example, the perf buffers are now).  So we should take
      care not to leak data that could be inspected by userspace.
      Signed-off-by: default avatarChris Metcalf <cmetcalf@ezchip.com>
      990486c8
    • Chris Metcalf's avatar
      word-at-a-time.h: support zero_bytemask() on alpha and tile · c753bf34
      Chris Metcalf authored
      Both alpha and tile needed implementations of zero_bytemask.
      
      The alpha version is untested.
      Signed-off-by: default avatarChris Metcalf <cmetcalf@ezchip.com>
      c753bf34
    • Chris Metcalf's avatar
      word-at-a-time.h: fix some Kbuild files · 19c22f3a
      Chris Metcalf authored
      arch/tile added word-at-a-time.h after the patch that added generic-y
      entries; the generic-y entry is now stale.
      
      arch/h8300 is newer than the generic-y patch for word-at-a-time.h,
      and needs a generic-y entry.
      
      arch/powerpc seems to have gotten a generic-y entry by mistake in
      the first patch; this change removes it.
      Signed-off-by: default avatarChris Metcalf <cmetcalf@ezchip.com>
      19c22f3a
    • Yang Shi's avatar
      arm64: replace read_lock to rcu lock in call_break_hook · 62c6c61a
      Yang Shi authored
      BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917
      in_atomic(): 0, irqs_disabled(): 128, pid: 342, name: perf
      1 lock held by perf/342:
       #0:  (break_hook_lock){+.+...}, at: [<ffffffc0000851ac>] call_break_hook+0x34/0xd0
      irq event stamp: 62224
      hardirqs last  enabled at (62223): [<ffffffc00010b7bc>] __call_rcu.constprop.59+0x104/0x270
      hardirqs last disabled at (62224): [<ffffffc0000fbe20>] vprintk_emit+0x68/0x640
      softirqs last  enabled at (0): [<ffffffc000097928>] copy_process.part.8+0x428/0x17f8
      softirqs last disabled at (0): [<          (null)>]           (null)
      CPU: 0 PID: 342 Comm: perf Not tainted 4.1.6-rt5 #4
      Hardware name: linux,dummy-virt (DT)
      Call trace:
      [<ffffffc000089968>] dump_backtrace+0x0/0x128
      [<ffffffc000089ab0>] show_stack+0x20/0x30
      [<ffffffc0007030d0>] dump_stack+0x7c/0xa0
      [<ffffffc0000c878c>] ___might_sleep+0x174/0x260
      [<ffffffc000708ac8>] __rt_spin_lock+0x28/0x40
      [<ffffffc000708db0>] rt_read_lock+0x60/0x80
      [<ffffffc0000851a8>] call_break_hook+0x30/0xd0
      [<ffffffc000085a70>] brk_handler+0x30/0x98
      [<ffffffc000082248>] do_debug_exception+0x50/0xb8
      Exception stack(0xffffffc00514fe30 to 0xffffffc00514ff50)
      fe20:                                     00000000 00000000 c1594680 0000007f
      fe40: ffffffff ffffffff 92063940 0000007f 0550dcd8 ffffffc0 00000000 00000000
      fe60: 0514fe70 ffffffc0 000be1f8 ffffffc0 0514feb0 ffffffc0 0008948c ffffffc0
      fe80: 00000004 00000000 0514fed0 ffffffc0 ffffffff ffffffff 9282a948 0000007f
      fea0: 00000000 00000000 9282b708 0000007f c1592820 0000007f 00083914 ffffffc0
      fec0: 00000000 00000000 00000010 00000000 00000064 00000000 00000001 00000000
      fee0: 005101e0 00000000 c1594680 0000007f c1594740 0000007f ffffffd8 ffffff80
      ff00: 00000000 00000000 00000000 00000000 c1594770 0000007f c1594770 0000007f
      ff20: 00665e10 00000000 7f7f7f7f 7f7f7f7f 01010101 01010101 00000000 00000000
      ff40: 928e4cc0 0000007f 91ff11e8 0000007f
      
      call_break_hook is called in atomic context (hard irq disabled), so replace
      the sleepable lock to rcu lock, replace relevant list operations to rcu
      version and call synchronize_rcu() in unregister_break_hook().
      
      And, replace write lock to spinlock in {un}register_break_hook.
      Signed-off-by: default avatarYang Shi <yang.shi@linaro.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      62c6c61a
    • Mark Rutland's avatar
      arm64: Don't relocate non-existent initrd · 4ca3bc86
      Mark Rutland authored
      When booting a kernel without an initrd, the kernel reports that it
      moves -1 bytes worth, having gone through the motions with initrd_start
      equal to initrd_end:
      
          Moving initrd from [4080000000-407fffffff] to [9fff49000-9fff48fff]
      
      Prevent this by bailing out early when the initrd size is zero (i.e. we
      have no initrd), avoiding the confusing message and other associated
      work.
      
      Fixes: 1570f0d7 ("arm64: support initrd outside kernel linear map")
      Cc: Mark Salter <msalter@redhat.com>
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      4ca3bc86
    • Linus Torvalds's avatar
      Merge tag 'for-linus-4.3b-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · f6702681
      Linus Torvalds authored
      Pull xen bug fixes from David Vrabel:
      
       - Fix VM save performance regression with x86 PV guests
      
       - Make kexec work in x86 PVHVM guests (if Xen has the soft-reset ABI)
      
       - Other minor fixes.
      
      * tag 'for-linus-4.3b-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        x86/xen/p2m: hint at the last populated P2M entry
        x86/xen: Do not clip xen_e820_map to xen_e820_map_entries when sanitizing map
        x86/xen: Support kexec/kdump in HVM guests by doing a soft reset
        xen/x86: Don't try to write syscall-related MSRs for PV guests
        xen: use correct type for HYPERVISOR_memory_op()
      f6702681
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux · 3ec20e2e
      Linus Torvalds authored
      Pull s390 fixes from Martin Schwidefsky:
       "Three bug fixes and an update to the default configuration"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
        s390/defconfig: set SCSI_DH=y
        s390/vtime: correct scaled cputime of partially idle CPUs
        s390/boot/decompression: disable floating point in decompressor
        s390/numa: use correct type for node_to_cpumask_map
      3ec20e2e
    • Linus Torvalds's avatar
      Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6 · 3c68319b
      Linus Torvalds authored
      Pull CIFS fixes from Steve French:
       "Two fixes for problems pointed out by automated tools.
      
        Thanks PaX/grsecurity team and Dan Carpenter (and the Smatch tool)"
      
      * 'for-next' of git://git.samba.org/sfrench/cifs-2.6:
        [CIFS] Update cifs version number
        [SMB3] Do not fall back to SMBWriteX in set_file_size error cases
        [SMB3] Missing null tcon check
      3c68319b
    • David Vrabel's avatar
      x86/xen/p2m: hint at the last populated P2M entry · 98dd166e
      David Vrabel authored
      With commit 633d6f17 (x86/xen: prepare
      p2m list for memory hotplug) the P2M may be sized to accomdate a much
      larger amount of memory than the domain currently has.
      
      When saving a domain, the toolstack must scan all the P2M looking for
      populated pages.  This results in a performance regression due to the
      unnecessary scanning.
      
      Instead of reporting (via shared_info) the maximum possible size of
      the P2M, hint at the last PFN which might be populated.  This hint is
      increased as new leaves are added to the P2M (in the expectation that
      they will be used for populated entries).
      Signed-off-by: default avatarDavid Vrabel <david.vrabel@citrix.com>
      Cc: <stable@vger.kernel.org> # 4.0+
      98dd166e
    • Mark Brown's avatar
    • Mark Brown's avatar
  4. 05 Oct, 2015 3 commits
    • Yang Shi's avatar
      arm64: convert patch_lock to raw lock · abffa6f3
      Yang Shi authored
      When running kprobe test on arm64 rt kernel, it reports the below warning:
      
      root@qemu7:~# modprobe kprobe_example
      BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917
      in_atomic(): 0, irqs_disabled(): 128, pid: 484, name: modprobe
      CPU: 0 PID: 484 Comm: modprobe Not tainted 4.1.6-rt5 #2
      Hardware name: linux,dummy-virt (DT)
      Call trace:
      [<ffffffc0000891b8>] dump_backtrace+0x0/0x128
      [<ffffffc000089300>] show_stack+0x20/0x30
      [<ffffffc00061dae8>] dump_stack+0x1c/0x28
      [<ffffffc0000bbad0>] ___might_sleep+0x120/0x198
      [<ffffffc0006223e8>] rt_spin_lock+0x28/0x40
      [<ffffffc000622b30>] __aarch64_insn_write+0x28/0x78
      [<ffffffc000622e48>] aarch64_insn_patch_text_nosync+0x18/0x48
      [<ffffffc000622ee8>] aarch64_insn_patch_text_cb+0x70/0xa0
      [<ffffffc000622f40>] aarch64_insn_patch_text_sync+0x28/0x48
      [<ffffffc0006236e0>] arch_arm_kprobe+0x38/0x48
      [<ffffffc00010e6f4>] arm_kprobe+0x34/0x50
      [<ffffffc000110374>] register_kprobe+0x4cc/0x5b8
      [<ffffffbffc002038>] kprobe_init+0x38/0x7c [kprobe_example]
      [<ffffffc000084240>] do_one_initcall+0x90/0x1b0
      [<ffffffc00061c498>] do_init_module+0x6c/0x1cc
      [<ffffffc0000fd0c0>] load_module+0x17f8/0x1db0
      [<ffffffc0000fd8cc>] SyS_finit_module+0xb4/0xc8
      
      Convert patch_lock to raw loc kto avoid this issue.
      
      Although the problem is found on rt kernel, the fix should be applicable to
      mainline kernel too.
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarYang Shi <yang.shi@linaro.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      abffa6f3
    • Mark Salyzyn's avatar
      arm64: readahead: fault retry breaks mmap file read random detection · 569ba74a
      Mark Salyzyn authored
      This is the arm64 portion of commit 45cac65b ("readahead: fault
      retry breaks mmap file read random detection"), which was absent from
      the initial port and has since gone unnoticed. The original commit says:
      
      > .fault now can retry.  The retry can break state machine of .fault.  In
      > filemap_fault, if page is miss, ra->mmap_miss is increased.  In the second
      > try, since the page is in page cache now, ra->mmap_miss is decreased.  And
      > these are done in one fault, so we can't detect random mmap file access.
      >
      > Add a new flag to indicate .fault is tried once.  In the second try, skip
      > ra->mmap_miss decreasing.  The filemap_fault state machine is ok with it.
      
      With this change, Mark reports that:
      
      > Random read improves by 250%, sequential read improves by 40%, and
      > random write by 400% to an eMMC device with dm crypto wrapped around it.
      
      Cc: Shaohua Li <shli@kernel.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Wu Fengguang <fengguang.wu@intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMark Salyzyn <salyzyn@android.com>
      Signed-off-by: default avatarRiley Andrews <riandrews@android.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      569ba74a
    • Yang Shi's avatar
      arm64: debug: Fix typo in debug-monitors.c · 95485fdc
      Yang Shi authored
      Fix comment typo: s/handers/handlers/
      Signed-off-by: default avatarYang Shi <yang.shi@linaro.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      95485fdc