1. 12 Nov, 2013 29 commits
    • Josef Bacik's avatar
      Btrfs: cleanup reserved space when freeing tree log on error · 681ae509
      Josef Bacik authored
      On error we will wait and free the tree log at unmount without a transaction.
      This means that the actual freeing of the blocks doesn't happen which means we
      complain about space leaks on unmount.  So to fix this just skip the transaction
      specific cleanup part of the tree log free'ing if we don't have a transaction
      and that way we can free up our reserved space and our counters stay happy.
      Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      681ae509
    • Josef Bacik's avatar
      Btrfs: do not free the dirty bytes from the trans block rsv on cleanup · eb58bb37
      Josef Bacik authored
      The transactions should be cleaning up their reservations on failure, this just
      causes us to have warnings on unmount because we go negative by free'ing
      reservations that have already been free'ed.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      eb58bb37
    • Filipe David Borba Manana's avatar
      Btrfs: fix memory leaks on transaction commit failure · 80d94fb3
      Filipe David Borba Manana authored
      Structures of the types tree_mod_elem and qgroup_update are allocated
      during transaction commit but were not being released if the call to
      btrfs_run_delayed_items() returned an error.
      
      Stack trace reported by kmemleak:
      
      unreferenced object 0xffff880679f0b398 (size 128):
        comm "umount", pid 21508, jiffies 4295967793 (age 36718.112s)
        hex dump (first 32 bytes):
          60 b5 f0 79 06 88 ff ff 00 00 00 00 00 00 00 00  `..y............
          00 00 00 00 00 00 00 00 50 1c 00 00 00 00 00 00  ........P.......
        backtrace:
          [<ffffffff81742d26>] kmemleak_alloc+0x26/0x50
          [<ffffffff811889c2>] kmem_cache_alloc_trace+0x112/0x200
          [<ffffffffa046f2d3>] tree_mod_log_insert_key.constprop.45+0x93/0x150 [btrfs]
          [<ffffffffa04720f9>] __btrfs_cow_block+0x299/0x4f0 [btrfs]
          [<ffffffffa0472510>] btrfs_cow_block+0x120/0x1f0 [btrfs]
          [<ffffffffa0476679>] btrfs_search_slot+0x449/0x930 [btrfs]
          [<ffffffffa048eecf>] btrfs_lookup_inode+0x2f/0xa0 [btrfs]
          [<ffffffffa04eb49c>] __btrfs_update_delayed_inode+0x1c/0x1d0 [btrfs]
          [<ffffffffa04eb9e2>] __btrfs_run_delayed_items+0x162/0x1e0 [btrfs]
          [<ffffffffa04eba63>] btrfs_delayed_inode_exit+0x3/0x20 [btrfs]
          [<ffffffffa0499c63>] btrfs_commit_transaction+0x203/0xa50 [btrfs]
          [<ffffffffa046b519>] btrfs_sync_fs+0x69/0x110 [btrfs]
          [<ffffffff811cb210>] __sync_filesystem+0x30/0x60
          [<ffffffff811cb2bb>] sync_filesystem+0x4b/0x70
          [<ffffffff8119ce7b>] generic_shutdown_super+0x3b/0xf0
          [<ffffffff8119cfc6>] kill_anon_super+0x16/0x30
      unreferenced object 0xffff880677e0dd88 (size 32):
        comm "umount", pid 21508, jiffies 4295967793 (age 36718.112s)
        hex dump (first 32 bytes):
          78 75 11 a9 06 88 ff ff 00 c0 e0 77 06 88 ff ff  xu.........w....
          40 c3 a2 70 06 88 ff ff 00 00 00 00 00 00 00 00  @..p............
        backtrace:
          [<ffffffff81742d26>] kmemleak_alloc+0x26/0x50
          [<ffffffff811889c2>] kmem_cache_alloc_trace+0x112/0x200
          [<ffffffffa04fa54f>] btrfs_qgroup_record_ref+0xf/0x90 [btrfs]
          [<ffffffffa04e1914>] btrfs_add_delayed_tree_ref+0xf4/0x170 [btrfs]
          [<ffffffffa048518a>] btrfs_free_tree_block+0x9a/0x220 [btrfs]
          [<ffffffffa0472163>] __btrfs_cow_block+0x303/0x4f0 [btrfs]
          [<ffffffffa0472510>] btrfs_cow_block+0x120/0x1f0 [btrfs]
          [<ffffffffa0476679>] btrfs_search_slot+0x449/0x930 [btrfs]
          [<ffffffffa048eecf>] btrfs_lookup_inode+0x2f/0xa0 [btrfs]
          [<ffffffffa04eb49c>] __btrfs_update_delayed_inode+0x1c/0x1d0 [btrfs]
          [<ffffffffa04eb9e2>] __btrfs_run_delayed_items+0x162/0x1e0 [btrfs]
          [<ffffffffa04eba63>] btrfs_delayed_inode_exit+0x3/0x20 [btrfs]
          [<ffffffffa0499c63>] btrfs_commit_transaction+0x203/0xa50 [btrfs]
          [<ffffffffa046b519>] btrfs_sync_fs+0x69/0x110 [btrfs]
          [<ffffffff811cb210>] __sync_filesystem+0x30/0x60
          [<ffffffff811cb2bb>] sync_filesystem+0x4b/0x70
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      80d94fb3
    • Ilya Dryomov's avatar
      Btrfs: fix the dev-replace suspend sequence · 539f358a
      Ilya Dryomov authored
      Replace progresses strictly from lower to higher offsets, and the
      progress is tracked in chunks, by storing the physical offset of the
      dev_extent which is being copied in the cursor_left field of
      btrfs_dev_replace_item.  When we are done copying the chunk,
      left_cursor is updated to point one byte past the dev_extent, so that
      on resume we can skip the dev_extents that have already been copied.
      
      There is a major bug (which goes all the way back to the inception of
      dev-replace in 3.8) in the way left_cursor is bumped: the bump is done
      unconditionally, without any regard to the scrub_chunk return value.
      On suspend (and also on any kind of error) scrub_chunk returns early,
      i.e. without completing the copy.  This leads to us skipping the chunk
      that hasn't been fully copied yet when resuming.
      
      Fix this by doing the cursor_left update only if scrub_chunk ret is 0.
      (On suspend scrub_chunk returns with -ECANCELED, so this fix covers
      both suspend and error cases.)
      
      Cc: Stefan Behrens <sbehrens@giantdisaster.de>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      539f358a
    • Filipe David Borba Manana's avatar
      Btrfs: improve inode hash function/inode lookup · 778ba82b
      Filipe David Borba Manana authored
      Currently the hash value used for adding an inode to the VFS's inode
      hash table consists of the plain inode number, which is a 64 bits
      integer. This results in hash table buckets (hlist_head lists) with
      too many elements for at least 2 important scenarios:
      
      1) When we have many subvolumes. Each subvolume has its own btree
         where its files and directories are added to, and each has its
         own objectid (inode number) namespace. This means that if we have
         N subvolumes, and all have inode number X associated to a file or
         directory, the corresponding inodes all map to the same hash table
         entry, resulting in a bucket (hlist_head list) with N elements;
      
      2) On 32 bits machines. Th VFS hash values are unsigned longs, which
         are 32 bits wide on 32 bits machines, and the inode (objectid)
         numbers are 64 bits unsigned integers. We simply cast the inode
         numbers to hash values, which means that for all inodes with the
         same 32 bits lower half, the same hash bucket is used for all of
         them. For example, all inodes with a number (objectid) between
         0x0000_0000_ffff_ffff and 0xffff_ffff_ffff_ffff will end up in
         the same hash table bucket.
      
      This change ensures the inode's hash value depends both on the
      objectid (inode number) and its subvolume's (btree root) objectid.
      For 32 bits machines, this change gives better entropy by making
      the hash value depend on both the upper and lower 32 bits of the
      64 bits hash previously computed.
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      778ba82b
    • Filipe David Borba Manana's avatar
      Btrfs: remove unnecessary tree search when logging inode · 3d41d702
      Filipe David Borba Manana authored
      In tree-log.c:btrfs_log_inode(), we keep calling btrfs_search_forward()
      until it returns a key whose objectid is higher than our inode or until
      the key's type is higher than our maximum allowed type.
      
      At the end of the loop, we increment our mininum search key's objectid
      and type regardless of our desired target objectid and maximum desired
      type, which causes another loop iteration that will call again
      btrfs_search_forward() just to figure out we've gone beyond our maximum
      key and exit the loop. Therefore while incrementing our minimum key,
      don't do it blindly and exit the loop immiediately if the next search
      key's objectid or type is beyond what we seek.
      
      Also after incrementing the type, set the key's offset to 0, which was
      missing and could make us loose some of the inode's items.
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      3d41d702
    • Filipe David Borba Manana's avatar
      6174d3cb
    • Liu Bo's avatar
      Btrfs: fix memory leak of chunks' extent map · 7d3d1744
      Liu Bo authored
      As we're hold a ref on looking up the extent map, we need to drop the ref
      before returning to callers.
      Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      7d3d1744
    • Miao Xie's avatar
      Btrfs: improve jitter performance of the sequential buffered write · fa7c1494
      Miao Xie authored
      The performance was slowed down sometimes when we ran sysbench to measure
      the performance of the sequential buffered write by 2 or more threads.
      
      It was because the write order of the test threads might be confused
      by the task scheduler, and the coming write would be beyond the end of
      the file, in this case, we need insert dummy file extents and create
      a hole for the area we skip. But in order to avoid the ongoing ordered
      extents which are in the area, we need wait for them. Unfortunately,
      the current code doesn't check if there are ordered extents in the area
      or not, try to find and flush the dirty pages directly, but in fact,
      there is no dirty page in that area, this step of the current code is
      unnecessary, and just wastes time. Sometimes, it would increase
      the contention of some locks, and makes the performance slow down suddenly.
      
      So we remove the ordered extent flush function before the check, and flush
      the dirty pages and wait for the ordered extents only when we find them.
      
      According to my test, we got 1-2 times of the performance regression when
      we ran the test by 10 times before applying this patch. After applying
      this patch, the regression went away.
      
      Test Environment:
       CPU:		1CPU * 4Cores
       Memory:	6GB
       Partition:	20GB
      
      Test Command:
       # sysbench --test=fileio --file-total-size=16G --file-test-mode=seqwr \
       > --num-threads=512 --file-block-size=16384 --max-time=60 --max-requests=0 run
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      fa7c1494
    • Miao Xie's avatar
      Btrfs: fix BUG_ON() casued by the reserved space migration · 20dd2cbf
      Miao Xie authored
      When we did space balance and snapshot creation at the same time, we might
      meet the following oops:
       kernel BUG at fs/btrfs/inode.c:3038!
       [SNIP]
       Call Trace:
       [<ffffffffa0411ec7>] btrfs_orphan_cleanup+0x293/0x407 [btrfs]
       [<ffffffffa042dc45>] btrfs_mksubvol.isra.28+0x259/0x373 [btrfs]
       [<ffffffffa042de85>] btrfs_ioctl_snap_create_transid+0x126/0x156 [btrfs]
       [<ffffffffa042dff1>] btrfs_ioctl_snap_create_v2+0xd0/0x121 [btrfs]
       [<ffffffffa0430b2c>] btrfs_ioctl+0x414/0x1854 [btrfs]
       [<ffffffff813b60b7>] ? __do_page_fault+0x305/0x379
       [<ffffffff811215a9>] vfs_ioctl+0x1d/0x39
       [<ffffffff81121d7c>] do_vfs_ioctl+0x32d/0x3e2
       [<ffffffff81057fe7>] ? finish_task_switch+0x80/0xb8
       [<ffffffff81121e88>] SyS_ioctl+0x57/0x83
       [<ffffffff813b39ff>] ? do_device_not_available+0x12/0x14
       [<ffffffff813b99c2>] system_call_fastpath+0x16/0x1b
       [SNIP]
       RIP  [<ffffffffa040da40>] btrfs_orphan_add+0xc3/0x126 [btrfs]
      
      The reason of the problem is that the relocation root creation stole
      the reserved space, which was reserved for orphan item deletion.
      
      There are several ways to fix this problem, one is to increasing
      the reserved space size of the space balace, and then we can use
      that space to create the relocation tree for each fs/file trees.
      But it is hard to calculate the suitable size because we doesn't
      know how many fs/file trees we need relocate.
      
      We fixed this problem by reserving the space for relocation root creation
      actively since the space it need is very small (one tree block, used for
      root node copy), then we use that reserved space to create the
      relocation tree. If we don't reserve space for relocation tree creation,
      we will use the reserved space of the balance.
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      20dd2cbf
    • Ross Kirk's avatar
      btrfs: remove unused parameter from btrfs_header_fsid · 0a4e5586
      Ross Kirk authored
      Remove unused parameter, 'eb'. Unused since introduction in
      5f39d397
      
      Updated to be rebased against current upstream and correct diff supplied this time!
      Signed-off-by: default avatarRoss Kirk <ross.kirk@gmail.com>
      Reviewed-by: default avatarEric Sandeen <sandeen@redhat.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      0a4e5586
    • Josef Bacik's avatar
      Btrfs: fix two use-after-free bugs with transaction cleanup · 724e2315
      Josef Bacik authored
      I was noticing the slab redzone stuff going off every once and a while during
      transaction aborts.  This was caused by two things
      
      1) We would walk the pending snapshots and set their error to -ECANCELED.  We
      don't need to do this, the snapshot stuff waits for a transaction commit and if
      there is a problem we just free our pending snapshot object and exit.  Doing
      this was causing us to touch the pending snapshot object after the thing had
      already been freed.
      
      2) We were freeing the transaction manually with wanton disregard for it's
      use_count reference counter.  To fix this I cleaned up the transaction freeing
      loop to either wait for the transaction commit to finish if it was in the middle
      of that (since it will be cleaned and freed up there) or to do the cleanup
      oursevles.
      
      I also moved the global "kill all things dirty everywhere" stuff outside of the
      transaction cleanup loop since that only needs to be done once.  With this patch
      I'm no longer seeing slab corruption because of use after frees.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      724e2315
    • Josef Bacik's avatar
      Btrfs: remove all BUG_ON()'s from commit_cowonly_roots · c16ce190
      Josef Bacik authored
      Noticed this when forcing errors to happen during delayed ref running.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      c16ce190
    • Josef Bacik's avatar
      Btrfs: don't delete ordered roots from list during cleanup · 1de2cfde
      Josef Bacik authored
      During transaction cleanup after an abort we are just removing roots from the
      ordered roots list which is incorrect.  We have a BUG_ON() to make sure that the
      root is still part of the ordered roots list when we put our ordered extent
      which we were tripping in this case.  So do like we do everywhere else and just
      move it to the tail of the ordered roots list and allow the normal cleanup to
      take care of stuff.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      1de2cfde
    • Josef Bacik's avatar
      Btrfs: cleanup transaction on abort · 4e121c06
      Josef Bacik authored
      If we abort not during a transaction commit we won't clean up anything until we
      unmount.  Unfortunately if we abort in the middle of writing out an ordered
      extent we won't clean it up and if somebody is waiting on that ordered extent
      they will wait forever.  To fix this just make the transaction kthread call the
      cleanup transaction stuff if it notices theres an error, and make
      btrfs_end_transaction wake up the transaction kthread if there is an error.
      Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      4e121c06
    • Josef Bacik's avatar
      Btrfs: do not release metadata for space cache inodes · b6d08f06
      Josef Bacik authored
      I've been testing our error paths and I was tripping the BUG_ON() in
      drop_outstanding_extent because our outstanding_extents is 0 for space cache
      inodes.  This is because we don't reserve metadata space for these inodes since
      we depend on the global block reserve for our space.  To fix this we need to
      make sure the DO_ACCOUNTING stuff doesn't actually call release_metadata for
      space cache inodes.  With this patch I'm no longer panicing.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      b6d08f06
    • Josef Bacik's avatar
      Btrfs: reset intwrite on transaction abort · e0228285
      Josef Bacik authored
      If we abort a transaction in the middle of a commit we weren't undoing the
      intwrite locking.  This patch fixes that problem.
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      e0228285
    • Josef Bacik's avatar
      Btrfs: relocate csums properly with prealloc extents · 4577b014
      Josef Bacik authored
      A user reported a problem where they were getting csum errors when running a
      balance and running systemd's journal.  This is because systemd is awesome and
      fallocate()'s its log space and writes into it.  Unfortunately we assume that
      when we read in all the csums for an extent that they are sequential starting at
      the bytenr we care about.  This obviously isn't the case for prealloc extents,
      where we could have written to the middle of the prealloc extent only, which
      means the csum would be for the bytenr in the middle of our range and not the
      front of our range.  Fix this by offsetting the new bytenr we are logging to
      based on the original bytenr the csum was for.  With this patch I no longer see
      the csum errors I was seeing.  Thanks,
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarChris Murphy <lists@colorremedies.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      4577b014
    • Filipe David Borba Manana's avatar
      Btrfs: don't leak block group on error · e84cc142
      Filipe David Borba Manana authored
      In extent-tree.c:btrfs_write_dirty_block_groups(), if the call to
      write_one_cache_group() failed, we would return without putting
      the block group first.
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      e84cc142
    • Filipe David Borba Manana's avatar
      Btrfs: fix sync fs to actually wait for all data to be persisted · 9b199859
      Filipe David Borba Manana authored
      Currently the fs sync function (super.c:btrfs_sync_fs()) doesn't
      wait for delayed work to finish before returning success to the
      caller. This change fixes this, ensuring that there's no data loss
      if a power failure happens right after fs sync returns success to
      the caller and before the next commit happens.
      
      Steps to reproduce the data loss issue:
      
      $ mkfs.btrfs -f /dev/sdb3
      $ mount /dev/sdb3 /mnt/btrfs
      $ perl -e '$d = ("\x41" x 6001); open($f,">","/mnt/btrfs/foobar"); print $f $d; close($f);' && btrfs fi sync /mnt/btrfs
      
      Right after the btrfs fi sync command (a second or 2 for example), power
      off the machine and reboot it. The file will be empty, as it can be verified
      after mounting the filesystem and through btrfs-debug-tree:
      
      $ btrfs-debug-tree /dev/sdb3 | egrep '\(257 INODE_ITEM 0\) itemoff' -B 3 -A 8
              item 3 key (256 DIR_INDEX 2) itemoff 3751 itemsize 36
                      location key (257 INODE_ITEM 0) type FILE
                      namelen 6 datalen 0 name: foobar
              item 4 key (257 INODE_ITEM 0) itemoff 3591 itemsize 160
                      inode generation 7 transid 7 size 0 block group 0 mode 100644 links 1
              item 5 key (257 INODE_REF 256) itemoff 3575 itemsize 16
                      inode ref index 2 namelen 6 name: foobar
      checksum tree key (CSUM_TREE ROOT_ITEM 0)
      leaf 29429760 items 0 free space 3995 generation 7 owner 7
      fs uuid 6192815c-af2a-4b75-b3db-a959ffb6166e
      chunk uuid b529c44b-938c-4d3d-910a-013b4700bcae
      uuid tree key (UUID_TREE ROOT_ITEM 0)
      
      After this patch, the data loss no longer happens after a power failure and
      btrfs-debug-tree shows:
      
      $ btrfs-debug-tree /dev/sdb3 | egrep '\(257 INODE_ITEM 0\) itemoff' -B 3 -A 8
      	item 3 key (256 DIR_INDEX 2) itemoff 3751 itemsize 36
      		location key (257 INODE_ITEM 0) type FILE
      		namelen 6 datalen 0 name: foobar
      	item 4 key (257 INODE_ITEM 0) itemoff 3591 itemsize 160
      		inode generation 6 transid 6 size 6001 block group 0 mode 100644 links 1
      	item 5 key (257 INODE_REF 256) itemoff 3575 itemsize 16
      		inode ref index 2 namelen 6 name: foobar
      	item 6 key (257 EXTENT_DATA 0) itemoff 3522 itemsize 53
      		extent data disk byte 12845056 nr 8192
      		extent data offset 0 nr 8192 ram 8192
      		extent compression 0
      checksum tree key (CSUM_TREE ROOT_ITEM 0)
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Reviewed-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      9b199859
    • Filipe David Borba Manana's avatar
      Btrfs: fix tracking of orphan inode count · 703c88e0
      Filipe David Borba Manana authored
      In inode.c:btrfs_orphan_add() if we failed to insert the orphan
      item, we would return without decrementing the orphan count that
      we just incremented before attempting the insertion, leaving the
      orphan inode count wrong.
      
      In inode.c:btrfs_orphan_del(), we were decrementing the inode
      orphan count if the bit BTRFS_INODE_ORPHAN_META_RESERVED was set,
      which is logically wrong because it should be decremented if the
      bit BTRFS_INODE_HAS_ORPHAN_ITEM was set - after all we increment
      the count when we set the bit BTRFS_INODE_HAS_ORPHAN_ITEM elsewhere.
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      703c88e0
    • Liu Bo's avatar
      Btrfs: export btrfs space shared info to userspace · fe09e16c
      Liu Bo authored
      Similar to ocfs2, btrfs also supports that extents can be shared by
      different inodes, and there are some userspace tools requesting
      for this kind of 'space shared infomation'.[1]
      
      ocfs2 uses flag FIEMAP_EXTENT_SHARED, so does btrfs.
      
      [1]: http://thr3ads.net/ocfs2-devel/2010/09/489052-PATCH-3-3-shared-du-using-fiemap-to-figure-up-the-shared-extents-per-file-and-the-footprint-inReviewed-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      fe09e16c
    • Filipe David Borba Manana's avatar
      Btrfs: remove path arg from btrfs_truncate_free_space_cache · 74514323
      Filipe David Borba Manana authored
      Not used for anything, and removing it avoids caller's need to
      allocate a path structure.
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      74514323
    • Filipe David Borba Manana's avatar
      Btrfs: remove duplicated ino cache's inode lookup · 53645a91
      Filipe David Borba Manana authored
      We're doing a unnecessary extra lookup of the ino cache's
      inode when we already have it (and holding a reference)
      during the process of saving the ino cache contents to disk.
      Therefore remove this extra lookup.
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      53645a91
    • Josef Bacik's avatar
      Btrfs: do a full search everytime in btrfs_search_old_slot · d4b4087c
      Josef Bacik authored
      While running some snashot aware defrag tests I noticed I was panicing every
      once and a while in key_search.  This is because of the optimization that says
      if we find a key at slot 0 it will be at slot 0 all the way down the rest of the
      tree.  This isn't the case for btrfs_search_old_slot since it will likely replay
      changes to a buffer if something has changed since we took our sequence number.
      So short circuit this optimization by setting prev_cmp to -1 every time we call
      key_search so we will do our normal binary search.  With this patch I am no
      longer seeing the panics I was seeing before.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      d4b4087c
    • Josef Bacik's avatar
      Btrfs: add a sanity test for btrfs_split_item · 06ea65a3
      Josef Bacik authored
      While looking at somebodys corruption I became completely convinced that
      btrfs_split_item was broken, so I wrote this test to verify that it was working
      as it was supposed to.  Thankfully it appears to be working as intended, so just
      add this test to make sure nobody breaks it in the future.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      06ea65a3
    • Ross Kirk's avatar
      btrfs: drop unused parameter from btrfs_item_nr · dd3cc16b
      Ross Kirk authored
      Remove unused eb parameter from btrfs_item_nr
      Signed-off-by: default avatarRoss Kirk <ross.kirk@gmail.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      dd3cc16b
    • Filipe David Borba Manana's avatar
      Btrfs: don't store NULL byte in symlink extents · f06becc4
      Filipe David Borba Manana authored
      It is not necessary to store the NULL byte in a symlink inline file
      extent. There's currently no code that requires the NULL byte to be
      present in the extent. This change also doesn't break file format
      compatibility nor the send/receive feature.
      
      The VFS also doesn't need the NULL byte to be present in the extent,
      as it reads up to inode->i_size bytes (which already excluded the NULL
      byte) and sets the NULL byte for us (in fs/namei.c:page_getlink()).
      
      So with this change we save 1 byte per symlink file extent (which is
      always inlined in the btree leaf) without losing backward and forward
      compatibility.
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      f06becc4
    • Stefan Behrens's avatar
      Btrfs: eliminate the exceptional root_tree refs=0 · 69e9c6c6
      Stefan Behrens authored
      The fact that btrfs_root_refs() returned 0 for the tree_root caused
      bugs in the past, therefore it is set to 1 with this patch and
      (hopefully) all affected code is adapted to this change.
      
      I verified this change by temporarily adding WARN_ON() checks
      everywhere where btrfs_root_refs() is used, checking whether the
      logic of the code is changed by btrfs_root_refs() returning 1
      instead of 0 for root->root_key.objectid == BTRFS_ROOT_TREE_OBJECTID.
      With these added checks, I ran the xfstests './check -g auto'.
      
      The two roots chunk_root and log_root_tree that are only referenced
      by the superblock and the log_roots below the log_root_tree still
      have btrfs_root_refs() == 0, only the tree_root is changed.
      Signed-off-by: default avatarStefan Behrens <sbehrens@giantdisaster.de>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      69e9c6c6
  2. 03 Nov, 2013 3 commits
  3. 02 Nov, 2013 2 commits
  4. 01 Nov, 2013 6 commits
    • Ming Lei's avatar
      scripts/kallsyms: filter symbols not in kernel address space · f6537f2f
      Ming Lei authored
      This patch uses CONFIG_PAGE_OFFSET to filter symbols which
      are not in kernel address space because these symbols are
      generally for generating code purpose and can't be run at
      kernel mode, so we needn't keep them in /proc/kallsyms.
      
      For example, on ARM there are some symbols which may be
      linked in relocatable code section, then perf can't parse
      symbols any more from /proc/kallsyms, this patch fixes the
      problem (introduced b9b32bf7)
      
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: Michal Marek <mmarek@suse.cz>
      Signed-off-by: default avatarMing Lei <tom.leiming@gmail.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Cc: stable@vger.kernel.org
      f6537f2f
    • Linus Torvalds's avatar
      Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 9581b7d2
      Linus Torvalds authored
      Pull perf fixes from Ingo Molnar:
       "Two fixes:
      
         - Fix 'NMI handler took too long to run' false positives
      
           [ Genuine NMI overhead speedups will come for v3.13, this commit
             only fixes a measurement bug ]
      
         - Fix perf ring-buffer missed barrier causing (rare) ring-buffer data
           corruption on ppc64"
      
      * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        perf/x86: Fix NMI measurements
        perf: Fix perf ring buffer memory ordering
      9581b7d2
    • Linus Torvalds's avatar
      Merge tag 'usb-3.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 9119e33e
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here is a set of patches that revert all of the changes done to the
        pl2303 USB serial driver in the 3.12-rc timeframe, as it turns out
        they break some devices that work just fine on 3.11.  As it's not a
        good idea to break working systems, drop them all and they will be
        reworked for future kernel versions such that there is no breakage.
      
        I've also included a MAINTAINERS update for the USB serial subsystem
        and a new device id for the ftdi_sio driver as well"
      
      * tag 'usb-3.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        USB: serial: ftdi_sio: add id for Z3X Box device
        USB: Maintainers change for usb serial drivers
        Revert "USB: pl2303: restrict the divisor based baud rate encoding method to the "HX" chip type"
        Revert "usb: pl2303: fix+improve the divsor based baud rate encoding method"
        Revert "usb: pl2303: do not round to the next nearest standard baud rate for the divisor based baud rate encoding method"
        Revert "usb: pl2303: remove 500000 baud from the list of standard baud rates"
        Revert "usb: pl2303: move the two baud rate encoding methods to separate functions"
        Revert "usb: pl2303: increase the allowed baud rate range for the divisor based encoding method"
        Revert "usb: pl2303: also use the divisor based baud rate encoding method for baud rates < 115200 with HX chips"
        Revert "usb: pl2303: add two comments concerning the supported baud rates with HX chips"
        Revert "pl2303: simplify the else-if contruct for type_1 chips in pl2303_startup()"
        Revert "pl2303: improve the chip type information output on startup"
        Revert "pl2303: improve the chip type detection/distinction"
        Revert "USB: pl2303: distinguish between original and cloned HX chips"
      9119e33e
    • Linus Torvalds's avatar
      Merge tag 'sound-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · f9adfbfb
      Linus Torvalds authored
      Pull more sound fixes from Takashi Iwai:
       "The fixes for random bugs that have been reported lately in the game:
        a few fixes in ASoC dpam and wm_hubs bugs spotted by Coverity, a
        one-liner HD-audio fixup, and a fix for Oops with DPCM.
      
        They are not so critically urgent bugs, but all small and safe"
      
      * tag 'sound-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ALSA: fix oops in snd_pcm_info() caused by ASoC DPCM
        ASoC: wm_hubs: Add missing break in hp_supply_event()
        ALSA: hda - Add a fixup for ASUS N76VZ
        ASoC: dapm: Return -ENOMEM in snd_soc_dapm_new_dai_widgets()
        ASoC: dapm: Fix source list debugfs outputs
      f9adfbfb
    • Linus Torvalds's avatar
      Merge tag 'clk-fixes-for-linus' of git://git.linaro.org/people/mturquette/linux · 68e952d5
      Linus Torvalds authored
      Pull clock subsystem fixes from Mike Turquette.
      
      * tag 'clk-fixes-for-linus' of git://git.linaro.org/people/mturquette/linux:
        clk: fixup argument order when setting VCO parameters
        clk: socfpga: Fix incorrect sdmmc clock name
        clk: armada-370: fix tclk frequencies
        clk: nomadik: set all timers to use 2.4 MHz TIMCLK
      68e952d5
    • Greg Thelen's avatar
      memcg: remove incorrect underflow check · 6920a1bd
      Greg Thelen authored
      When a memcg is deleted mem_cgroup_reparent_charges() moves charged
      memory to the parent memcg.  As of v3.11-9444-g3ea67d06 "memcg: add per
      cgroup writeback pages accounting" there's bad pointer read.  The goal
      was to check for counter underflow.  The counter is a per cpu counter
      and there are two problems with the code:
      
       (1) per cpu access function isn't used, instead a naked pointer is used
           which easily causes oops.
       (2) the check doesn't sum all cpus
      
      Test:
        $ cd /sys/fs/cgroup/memory
        $ mkdir x
        $ echo 3 > /proc/sys/vm/drop_caches
        $ (echo $BASHPID >> x/tasks && exec cat) &
        [1] 7154
        $ grep ^mapped x/memory.stat
        mapped_file 53248
        $ echo 7154 > tasks
        $ rmdir x
        <OOPS>
      
      The fix is to remove the check.  It's currently dangerous and isn't
      worth fixing it to use something expensive, such as
      percpu_counter_sum(), for each reparented page.  __this_cpu_read() isn't
      enough to fix this because there's no guarantees of the current cpus
      count.  The only guarantees is that the sum of all per-cpu counter is >=
      nr_pages.
      
      Fixes: 3ea67d06 ("memcg: add per cgroup writeback pages accounting")
      Reported-and-tested-by: default avatarFlavio Leitner <fbl@redhat.com>
      Signed-off-by: default avatarGreg Thelen <gthelen@google.com>
      Reviewed-by: default avatarSha Zhengju <handai.szj@taobao.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6920a1bd