1. 12 4月, 2011 1 次提交
    • J
      Btrfs: avoid taking the trans_mutex in btrfs_end_transaction · 13c5a93e
      Josef Bacik 提交于
      I've been working on making our O_DIRECT latency not suck and I noticed we were
      taking the trans_mutex in btrfs_end_transaction.  So to do this we convert
      num_writers and use_count to atomic_t's and just decrement them in
      btrfs_end_transaction.  Instead of deleting the transaction from the trans list
      in put_transaction we do that in btrfs_commit_transaction() since that's the
      only time it actually needs to be removed from the list.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      13c5a93e
  2. 05 4月, 2011 1 次提交
  3. 28 3月, 2011 6 次提交
    • M
      btrfs: fix possible deadlock by clearing __GFP_FS flag · 1561deda
      Miao Xie 提交于
      Using the GFP_HIGHUSER_MOVABLE flag to allocate the metadata's page may cause
      deadlock.
        Task1
        open()
          ...
          btrfs_search_slot()
            ...
            btrfs_cow_block()
      	...
      	alloc_page()
      	  wait for reclaiming
      					shrink_slab()
      					  ...
      					  shrink_icache_memory()
      					    ...
      					    btrfs_evict_inode()
      					      ...
      					      btrfs_search_slot()
      
      If the path is locked by task1, the deadlock happens.
      
      So the btree's page cache is different with the file's page cache, it can not
      allocate pages by GFP_HIGHUSER_MOVABLE flag, we must clear __GFP_FS flag in
      GFP_HIGHUSER_MOVABLE flag.
      Reported-by: NItaru Kitayama <kitayama@cl.bb4u.ne.jp>
      Signed-off-by: NMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      1561deda
    • L
      Btrfs: fix OOPS of empty filesystem after balance · c59021f8
      liubo 提交于
      btrfs will remove unused block groups after balance.
      When a empty filesystem is balanced, the block group with tag "DATA" may be
      dropped, and after umount and mount again, it will not find "DATA" space_info
      and lead to OOPS.
      So we initial the necessary space_infos(DATA, SYSTEM, METADATA) to avoid OOPS.
      Reported-by: NDaniel J Blueman <daniel.blueman@gmail.com>
      Signed-off-by: NLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      c59021f8
    • L
      Btrfs: adjust btrfs_discard_extent() return errors and trimmed bytes · 5378e607
      Li Dongyang 提交于
      Callers of btrfs_discard_extent() should check if we are mounted with -o discard,
      as we want to make fitrim to work even the fs is not mounted with -o discard.
      Also we should use REQ_DISCARD to map the free extent to get a full mapping,
      last we only return errors if
      1. the error is not a EOPNOTSUPP
      2. no device supports discard
      Signed-off-by: NLi Dongyang <lidongyang@novell.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      5378e607
    • L
      Btrfs: Per file/directory controls for COW and compression · 75e7cb7f
      Liu Bo 提交于
      Data compression and data cow are controlled across the entire FS by mount
      options right now.  ioctls are needed to set this on a per file or per
      directory basis.  This has been proposed previously, but VFS developers
      wanted us to use generic ioctls rather than btrfs-specific ones.
      
      According to Chris's comment, there should be just one true compression
      method(probably LZO) stored in the super.  However, before this, we would
      wait for that one method is stable enough to be adopted into the super.
      So I list it as a long term goal, and just store it in ram today.
      
      After applying this patch, we can use the generic "FS_IOC_SETFLAGS" ioctl to
      control file and directory's datacow and compression attribute.
      
      NOTE:
       - The compression type is selected by such rules:
         If we mount btrfs with compress options, ie, zlib/lzo, the type is it.
         Otherwise, we'll use the default compress type (zlib today).
      
      v1->v2:
      - rebase to the latest btrfs.
      v2->v3:
      - fix a problem, i.e. when a file is set NOCOW via mount option, then this NOCOW
        will be screwed by inheritance from parent directory.
      Signed-off-by: NLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      75e7cb7f
    • D
      btrfs: properly access unaligned checksum buffer · 7e75bf3f
      David Sterba 提交于
      On Fri, Mar 18, 2011 at 11:56:53AM -0400, Chris Mason wrote:
      > Thanks for fielding this one.  Does put_unaligned_le32 optimize away on
      > platforms with efficient access?  It would be great if we didn't need
      > the #ifdef.
      
      (quicktest: assembly output is same for put_unaligned_le32 and direct
      assignment on my x86_64)
      I was originally following examples in
      Documentation/unaligned-memory-access.txt. From other code it seems to me that
      the define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is intended for larger
      portions of code. Macros/wrappers for {put,get}_unaligned* are chosen via
      arch/<arch>/include/asm/unaligned.h accordingly, therefore it's safe to use
      put_unaligned_le32 without the ifdef.
      
      dave
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      7e75bf3f
    • T
      Btrfs: cleanup some BUG_ON() · db5b493a
      Tsutomu Itoh 提交于
      This patch changes some BUG_ON() to the error return.
      (but, most callers still use BUG_ON())
      Signed-off-by: NTsutomu Itoh <t-itoh@jp.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      db5b493a
  4. 18 3月, 2011 2 次提交
    • J
      Btrfs: check items for correctness as we search · a826d6dc
      Josef Bacik 提交于
      Currently if we have corrupted items things will blow up in spectacular ways.
      So as we read in blocks and they are leaves, check the entire leaf to make sure
      all of the items are correct and point to valid parts in the leaf for the item
      data the are responsible for.  If the item is corrupt we will kick back EIO and
      not read any of the copies since they are likely to not be correct either.  This
      will catch generic corruptions, it will be up to the individual callers of
      btrfs_search_slot to make sure their items are right.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      a826d6dc
    • J
      Btrfs: handle errors in btrfs_orphan_cleanup · 66b4ffd1
      Josef Bacik 提交于
      If we cannot truncate an inode for some reason we will never delete the orphan
      item associated with that inode, which means that we will loop forever in
      btrfs_orphan_cleanup.  Instead of doing this just return error so we fail to
      mount.  It sucks, but hey it's better than hanging.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      66b4ffd1
  5. 15 2月, 2011 1 次提交
    • C
      Btrfs: fix page->private races · eb14ab8e
      Chris Mason 提交于
      There is a race where btrfs_releasepage can drop the
      page->private contents just as alloc_extent_buffer is setting
      up pages for metadata.  Because of how the Btrfs page flags work,
      this results in us skipping the crc on the page during IO.
      
      This patch sovles the race by waiting until after the extent buffer
      is inserted into the radix tree before it sets page private.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      eb14ab8e
  6. 29 1月, 2011 1 次提交
    • T
      btrfs: fix return value check of btrfs_join_transaction() · 3612b495
      Tsutomu Itoh 提交于
      The error check of btrfs_join_transaction()/btrfs_join_transaction_nolock()
      is added, and the mistake of the error check in several places is
      corrected.
      
      For more stable Btrfs, I think that we should reduce BUG_ON().
      But, I think that long time is necessary for this.
      So, I propose this patch as a short-term solution.
      
      With this patch:
       - To more stable Btrfs, the part that should be corrected is clarified.
       - The panic isn't done by the NULL pointer reference etc. (even if
         BUG_ON() is increased temporarily)
       - The error code is returned in the place where the error can be easily
         returned.
      
      As a long-term plan:
       - BUG_ON() is reduced by using the forced-readonly framework, etc.
      Signed-off-by: NTsutomu Itoh <t-itoh@jp.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      3612b495
  7. 27 1月, 2011 1 次提交
  8. 18 1月, 2011 1 次提交
    • L
      Btrfs: forced readonly mounts on errors · acce952b
      liubo 提交于
      This patch comes from "Forced readonly mounts on errors" ideas.
      
      As we know, this is the first step in being more fault tolerant of disk
      corruptions instead of just using BUG() statements.
      
      The major content:
      - add a framework for generating errors that should result in filesystems
        going readonly.
      - keep FS state in disk super block.
      - make sure that all of resource will be freed and released at umount time.
      - make sure that fter FS is forced readonly on error, there will be no more
        disk change before FS is corrected. For this, we should stop write operation.
      
      After this patch is applied, the conversion from BUG() to such a framework can
      happen incrementally.
      Signed-off-by: NLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      acce952b
  9. 17 1月, 2011 3 次提交
  10. 22 12月, 2010 1 次提交
    • L
      btrfs: Add lzo compression support · a6fa6fae
      Li Zefan 提交于
      Lzo is a much faster compression algorithm than gzib, so would allow
      more users to enable transparent compression, and some users can
      choose from compression ratio and speed for different applications
      
      Usage:
      
       # mount -t btrfs -o compress[=<zlib,lzo>] dev /mnt
      or
       # mount -t btrfs -o compress-force[=<zlib,lzo>] dev /mnt
      
      "-o compress" without argument is still allowed for compatability.
      
      Compatibility:
      
      If we mount a filesystem with lzo compression, it will not be able be
      mounted in old kernels. One reason is, otherwise btrfs will directly
      dump compressed data, which sits in inline extent, to user.
      
      Performance:
      
      The test copied a linux source tarball (~400M) from an ext4 partition
      to the btrfs partition, and then extracted it.
      
      (time in second)
                 lzo        zlib        nocompress
      copy:      10.6       21.7        14.9
      extract:   70.1       94.4        66.6
      
      (data size in MB)
                 lzo        zlib        nocompress
      copy:      185.87     108.69      394.49
      extract:   193.80     132.36      381.21
      
      Changelog:
      
      v1 -> v2:
      - Select LZO_COMPRESS and LZO_DECOMPRESS in btrfs Kconfig.
      - Add incompability flag.
      - Fix error handling in compress code.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      a6fa6fae
  11. 14 12月, 2010 1 次提交
    • C
      Btrfs: EIO when we fail to read tree roots · 68433b73
      Chris Mason 提交于
      If we just get a plain IO error when we read tree roots, the code
      wasn't properly sending that error up the chain.  This allowed mounts to
      continue when they should failed, and allowed operations
      on partially setup root structs.  The end result was usually oopsen
      on spinlocks that hadn't been spun up correctly.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      68433b73
  12. 11 12月, 2010 1 次提交
  13. 29 11月, 2010 1 次提交
  14. 28 11月, 2010 1 次提交
    • J
      Btrfs: setup blank root and fs_info for mount time · 450ba0ea
      Josef Bacik 提交于
      There is a problem with how we use sget, it searches through the list of supers
      attached to the fs_type looking for a super with the same fs_devices as what
      we're trying to mount.  This depends on sb->s_fs_info being filled, but we don't
      fill that in until we get to btrfs_fill_super, so we could hit supers on the
      fs_type super list that have a null s_fs_info.  In order to fix that we need to
      go ahead and setup a blank root with a blank fs_info to hold fs_devices, that
      way our test will work out right and then we can set s_fs_info in
      btrfs_set_super, and then open_ctree will simply use our pre-allocated root and
      fs_info when setting everything up.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      450ba0ea
  15. 22 11月, 2010 1 次提交
    • C
      Btrfs: add migrate page for metadata inode · 784b4e29
      Chris Mason 提交于
      Migrate page will directly call the btrfs btree writepage function,
      which isn't actually allowed.
      
      Our writepage assumes that you have locked the extent_buffer and
      flagged the block as written.  Without doing these steps, we can
      corrupt metadata blocks.
      
      A later commit will remove the btree writepage function since
      it is really only safely used internally by btrfs.  We
      use writepages for everything else.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      784b4e29
  16. 30 10月, 2010 2 次提交
  17. 29 10月, 2010 2 次提交
    • J
      Btrfs: write out free space cache · 0cb59c99
      Josef Bacik 提交于
      This is a simple bit, just dump the free space cache out to our preallocated
      inode when we're writing out dirty block groups.  There are a bunch of changes
      in inode.c in order to account for special cases.  Mostly when we're doing the
      writeout we're holding trans_mutex, so we need to use the nolock transacation
      functions.  Also we can't do asynchronous completions since the async thread
      could be blocked on already completed IO waiting for the transaction lock.  This
      has been tested with xfstests and btrfs filesystem balance, as well as my ENOSPC
      tests.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      0cb59c99
    • J
      Btrfs: create special free space cache inode · 0af3d00b
      Josef Bacik 提交于
      In order to save free space cache, we need an inode to hold the data, and we
      need a special item to point at the right inode for the right block group.  So
      first, create a special item that will point to the right inode, and the number
      of extent entries we will have and the number of bitmaps we will have.  We
      truncate and pre-allocate space everytime to make sure it's uptodate.
      
      This feature will be turned on as soon as you mount with -o space_cache, however
      it is safe to boot into old kernels, they will just generate the cache the old
      fashion way.  When you boot back into a newer kernel we will notice that we
      modified and not the cache and automatically discard the cache.
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      0af3d00b
  18. 10 9月, 2010 1 次提交
  19. 08 8月, 2010 1 次提交
    • C
      block: unify flags for struct bio and struct request · 7b6d91da
      Christoph Hellwig 提交于
      Remove the current bio flags and reuse the request flags for the bio, too.
      This allows to more easily trace the type of I/O from the filesystem
      down to the block driver.  There were two flags in the bio that were
      missing in the requests:  BIO_RW_UNPLUG and BIO_RW_AHEAD.  Also I've
      renamed two request flags that had a superflous RW in them.
      
      Note that the flags are in bio.h despite having the REQ_ name - as
      blkdev.h includes bio.h that is the only way to go for now.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <jaxboe@fusionio.com>
      7b6d91da
  20. 12 6月, 2010 2 次提交
  21. 25 5月, 2010 7 次提交
  22. 26 4月, 2010 1 次提交
  23. 31 3月, 2010 1 次提交