1. 24 Jan, 2013 5 commits
    • Miao Xie's avatar
      Btrfs: Add ACCESS_ONCE() to transaction->abort accesses · 8d25a086
      Miao Xie authored
      We may access and update transaction->aborted on the different CPUs without
      lock, so we need ACCESS_ONCE() wrapper to prevent the compiler from creating
      unsolicited accesses and make sure we can get the right value.
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      8d25a086
    • Josef Bacik's avatar
      Btrfs: put csums on the right ordered extent · e58dd74b
      Josef Bacik authored
      I noticed a WARN_ON going off when adding csums because we were going over
      the amount of csum bytes that should have been allowed for an ordered
      extent.  This is a leftover from when we used to hold the csums privately
      for direct io, but now we use the normal ordered sum stuff so we need to
      make sure and check if we've moved on to another extent so that the csums
      are added to the right extent.  Without this we could end up with csums for
      bytenrs that don't have extents to cover them yet.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      e58dd74b
    • Liu Bo's avatar
      Btrfs: use right range to find checksum for compressed extents · 192000dd
      Liu Bo authored
      For compressed extents, the range of checksum is covered by disk length,
      and the disk length is different with ram length, so we need to use disk
      length instead to get us the right checksum.
      Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      192000dd
    • Josef Bacik's avatar
      Btrfs: fix panic when recovering tree log · b0175117
      Josef Bacik authored
      A user reported a BUG_ON(ret) that occured during tree log replay.  Ret was
      -EAGAIN, so what I think happened is that we removed an extent that covered
      a bitmap entry and an extent entry.  We remove the part from the bitmap and
      return -EAGAIN and then search for the next piece we want to remove, which
      happens to be an entire extent entry, so we just free the sucker and return.
      The problem is ret is still set to -EAGAIN so we trip the BUG_ON().  The
      user used btrfs-zero-log so I'm not 100% sure this is what happened so I've
      added a WARN_ON() to catch the other possibility.  Thanks,
      Reported-by: default avatarJan Steffens <jan.steffens@gmail.com>
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      b0175117
    • Josef Bacik's avatar
      Btrfs: do not allow logged extents to be merged or removed · 201a9038
      Josef Bacik authored
      We drop the extent map tree lock while we're logging extents, so somebody
      could come in and merge another extent into this one and screw up our
      logging, or they could even remove us from the list which would keep us from
      logging the extent or freeing our ref on it, so we need to make sure to not
      clear LOGGING until after the extent is logged, and then we can merge it to
      adjacent extents.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      201a9038
  2. 22 Jan, 2013 5 commits
  3. 20 Jan, 2013 5 commits
  4. 14 Jan, 2013 14 commits
  5. 19 Dec, 2012 1 commit
  6. 18 Dec, 2012 1 commit
  7. 17 Dec, 2012 9 commits
    • Liu Bo's avatar
      Btrfs: fix a bug of per-file nocow · 213490b3
      Liu Bo authored
      Users report a bug, the reproducer is:
      $ mkfs.btrfs /dev/loop0
      $ mount /dev/loop0 /mnt/btrfs/
      $ mkdir /mnt/btrfs/dir
      $ chattr +C /mnt/btrfs/dir/
      $ dd if=/dev/zero of=/mnt/btrfs/dir/foo bs=4K count=10;
      $ lsattr /mnt/btrfs/dir/foo
      ---------------C- /mnt/btrfs/dir/foo
      $ filefrag /mnt/btrfs/dir/foo
      /mnt/btrfs/dir/foo: 1 extent found    ---> an extent
      $ dd if=/dev/zero of=/mnt/btrfs/dir/foo bs=4K count=1 seek=5 conv=notrunc,nocreat; sync
      $ filefrag /mnt/btrfs/dir/foo
      /mnt/btrfs/dir/foo: 3 extents found   ---> with nocow, btrfs breaks the extent into three parts
      
      The new created file should not only inherit the NODATACOW flag, but also
      honor NODATASUM flag, because we must do COW on a file extent with checksum.
      Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      213490b3
    • Chris Mason's avatar
      Btrfs: fix hash overflow handling · 9c52057c
      Chris Mason authored
      The handling for directory crc hash overflows was fairly obscure,
      split_leaf returns EOVERFLOW when we try to extend the item and that is
      supposed to bubble up to userland.  For a while it did so, but along the
      way we added better handling of errors and forced the FS readonly if we
      hit IO errors during the directory insertion.
      
      Along the way, we started testing only for EEXIST and the EOVERFLOW case
      was dropped.  The end result is that we may force the FS readonly if we
      catch a directory hash bucket overflow.
      
      This fixes a few problem spots.  First I add tests for EOVERFLOW in the
      places where we can safely just return the error up the chain.
      
      btrfs_rename is harder though, because it tries to insert the new
      directory item only after it has already unlinked anything the rename
      was going to overwrite.  Rather than adding very complex logic, I added
      a helper to test for the hash overflow case early while it is still safe
      to bail out.
      
      Snapshot and subvolume creation had a similar problem, so they are using
      the new helper now too.
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      Reported-by: default avatarPascal Junod <pascal@junod.info>
      9c52057c
    • Josef Bacik's avatar
      Btrfs: don't take inode delalloc mutex if we're a free space inode · c64c2bd8
      Josef Bacik authored
      This confuses and angers lockdep even though it's ok.  We don't really need
      the lock for free space inodes since only the transaction committer will be
      reserving space.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      c64c2bd8
    • Josef Bacik's avatar
      Btrfs: fix autodefrag and umount lockup · 1135d6df
      Josef Bacik authored
      This happens because writeback_inodes_sb_nr_if_idle does down_read.  This
      doesn't work for us and it has not been fixed upstream yet, so do it
      ourselves and use that instead so we can stop having this stupid long
      standing lockup.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      1135d6df
    • Filipe Brandenburger's avatar
      Btrfs: fix permissions of empty files not affected by umask · 9185aa58
      Filipe Brandenburger authored
      When a new file is created with btrfs_create(), the inode will initially be
      created with permissions 0666 and later on in btrfs_init_acl() it will be
      adapted to mask out the umask bits. The problem is that this change won't make
      it into the btrfs_inode unless there's another change to the inode (e.g. writing
      content changing the size or touching the file changing the mtime.)
      
      This fix adds a call to btrfs_update_inode() to btrfs_create() to make sure that
      the change will not get lost if the in-memory inode is flushed before other
      changes are made to the file.
      Signed-off-by: default avatarFilipe Brandenburger <filbranden@google.com>
      Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      9185aa58
    • Liu Bo's avatar
      Btrfs: put raid properties into global table · 31e50229
      Liu Bo authored
      Raid properties can be shared among raid calculation code, we can put
      them into a global table to keep it simple.
      Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      31e50229
    • Stefan Behrens's avatar
      Btrfs: fix BUG() in scrub when first superblock reading gives EIO · 4ded4f63
      Stefan Behrens authored
      This fixes a very special case that can be reproduced by just
      disconnecting a disk at runtime, and without unmounting the
      filesystem first, start scrub on the filesystem with the
      disconnected disk. All read and write EIOs are handled
      correctly, only the first superblock is an exception and gives
      a BUG() in a subfunction. The BUG() is correct, it would crash
      later otherwise. The subfunction must not be called for
      superblocks and this is what the fix changes.
      Reported-by: default avatarJoeri Vanthienen <mail@joerivanthienen.be>
      Signed-off-by: default avatarStefan Behrens <sbehrens@giantdisaster.de>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      4ded4f63
    • Josef Bacik's avatar
      Btrfs: do not call file_update_time in aio_write · 6c760c07
      Josef Bacik authored
      This starts a transaction and dirties the inode everytime we call it, which
      is super expensive if you have a write heavy workload.  We will be updating
      the inode when the IO completes and we reserve the space for the inode
      update when we reserve space for the write, so there is no chance of loss of
      information or enospc issues.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      6c760c07
    • Josef Bacik's avatar
      Btrfs: only unlock and relock if we have to · 5124e00e
      Josef Bacik authored
      I noticed while doing fsync tests that we were always dropping the path and
      re-searching when we first cow the log root even though we've already gotten
      the write lock on the root.  That's because we don't take into account that
      there might not be a parent node, so fix the check to make sure there is
      actually a parent node before we undo all of this work for nothing.  Thanks,
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      5124e00e