1. 07 1月, 2011 3 次提交
    • N
      fs: dcache reduce branches in lookup path · fb045adb
      Nick Piggin 提交于
      Reduce some branches and memory accesses in dcache lookup by adding dentry
      flags to indicate common d_ops are set, rather than having to check them.
      This saves a pointer memory access (dentry->d_op) in common path lookup
      situations, and saves another pointer load and branch in cases where we
      have d_op but not the particular operation.
      
      Patched with:
      
      git grep -E '[.>]([[:space:]])*d_op([[:space:]])*=' | xargs sed -e 's/\([^\t ]*\)->d_op = \(.*\);/d_set_d_op(\1, \2);/' -e 's/\([^\t ]*\)\.d_op = \(.*\);/d_set_d_op(\&\1, \2);/' -i
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      fb045adb
    • N
      fs: icache RCU free inodes · fa0d7e3d
      Nick Piggin 提交于
      RCU free the struct inode. This will allow:
      
      - Subsequent store-free path walking patch. The inode must be consulted for
        permissions when walking, so an RCU inode reference is a must.
      - sb_inode_list_lock to be moved inside i_lock because sb list walkers who want
        to take i_lock no longer need to take sb_inode_list_lock to walk the list in
        the first place. This will simplify and optimize locking.
      - Could remove some nested trylock loops in dcache code
      - Could potentially simplify things a bit in VM land. Do not need to take the
        page lock to follow page->mapping.
      
      The downsides of this is the performance cost of using RCU. In a simple
      creat/unlink microbenchmark, performance drops by about 10% due to inability to
      reuse cache-hot slab objects. As iterations increase and RCU freeing starts
      kicking over, this increases to about 20%.
      
      In cases where inode lifetimes are longer (ie. many inodes may be allocated
      during the average life span of a single inode), a lot of this cache reuse is
      not applicable, so the regression caused by this patch is smaller.
      
      The cache-hot regression could largely be avoided by using SLAB_DESTROY_BY_RCU,
      however this adds some complexity to list walking and store-free path walking,
      so I prefer to implement this at a later date, if it is shown to be a win in
      real situations. I haven't found a regression in any non-micro benchmark so I
      doubt it will be a problem.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      fa0d7e3d
    • N
      fs: change d_delete semantics · fe15ce44
      Nick Piggin 提交于
      Change d_delete from a dentry deletion notification to a dentry caching
      advise, more like ->drop_inode. Require it to be constant and idempotent,
      and not take d_lock. This is how all existing filesystems use the callback
      anyway.
      
      This makes fine grained dentry locking of dput and dentry lru scanning
      much simpler.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      fe15ce44
  2. 11 12月, 2010 2 次提交
  3. 10 12月, 2010 1 次提交
  4. 29 11月, 2010 1 次提交
  5. 28 11月, 2010 3 次提交
  6. 22 11月, 2010 6 次提交
    • J
      Btrfs: make btrfs_add_nondir take parent inode as an argument · a1b075d2
      Josef Bacik 提交于
      Everybody who calls btrfs_add_nondir just passes in the dentry of the new file
      and then dereference dentry->d_parent->d_inode, but everybody who calls
      btrfs_add_nondir() are already passed the parent's inode.  So instead of
      dereferencing dentry->d_parent, just make btrfs_add_nondir take the dir inode as
      an argument and pass that along so we don't have to worry about d_parent.
      Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      a1b075d2
    • J
      Btrfs: use dget_parent where we can UPDATED · 6a912213
      Josef Bacik 提交于
      There are lots of places where we do dentry->d_parent->d_inode without holding
      the dentry->d_lock.  This could cause problems with rename.  So instead we need
      to use dget_parent() and hold the reference to the parent as long as we are
      going to use it's inode and then dput it at the end.
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      Cc: raven@themaw.net
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      6a912213
    • J
      Btrfs: fix more ESTALE problems with NFS · 76195853
      Josef Bacik 提交于
      When creating new inodes we don't setup inode->i_generation.  So if we generate
      an fh with a newly created inode we save the generation of 0, but if we flush
      the inode to disk and have to read it back when getting the inode on the server
      we'll have the right i_generation, so gens wont match and we get ESTALE.  This
      patch properly sets inode->i_generation when we create the new inode and now I'm
      no longer getting ESTALE.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      76195853
    • L
      btrfs: Show device attr correctly for symlinks · f209561a
      Li Zefan 提交于
      Symlinks and files of other types show different device numbers, though
      they are on the same partition:
      
       $ touch tmp; ln -s tmp tmp2; stat tmp tmp2
         File: `tmp'
         Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
       Device: 15h/21d	Inode: 984027      Links: 1
       --- snip ---
         File: `tmp2' -> `tmp'
         Size: 3         	Blocks: 0          IO Block: 4096   symbolic link
       Device: 13h/19d	Inode: 984028      Links: 1
      Reported-by: NToke Høiland-Jørgensen <toke@toke.dk>
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      f209561a
    • M
      btrfs: fix panic caused by direct IO · e65e1535
      Miao Xie 提交于
      btrfs paniced when we write >64KB data by direct IO at one time.
      
      Reproduce steps:
       # mkfs.btrfs /dev/sda5 /dev/sda6
       # mount /dev/sda5 /mnt
       # dd if=/dev/zero of=/mnt/tmpfile bs=100K count=1 oflag=direct
      
      Then btrfs paniced:
      mapping failed logical 1103155200 bio len 69632 len 12288
      ------------[ cut here ]------------
      kernel BUG at fs/btrfs/volumes.c:3010!
      [SNIP]
      Pid: 1992, comm: btrfs-worker-0 Not tainted 2.6.37-rc1 #1 D2399/PRIMERGY
      RIP: 0010:[<ffffffffa03d1462>]  [<ffffffffa03d1462>] btrfs_map_bio+0x202/0x210 [btrfs]
      [SNIP]
      Call Trace:
       [<ffffffffa03ab3eb>] __btrfs_submit_bio_done+0x1b/0x20 [btrfs]
       [<ffffffffa03a35ff>] run_one_async_done+0x9f/0xb0 [btrfs]
       [<ffffffffa03d3d20>] run_ordered_completions+0x80/0xc0 [btrfs]
       [<ffffffffa03d45a4>] worker_loop+0x154/0x5f0 [btrfs]
       [<ffffffffa03d4450>] ? worker_loop+0x0/0x5f0 [btrfs]
       [<ffffffffa03d4450>] ? worker_loop+0x0/0x5f0 [btrfs]
       [<ffffffff81083216>] kthread+0x96/0xa0
       [<ffffffff8100cec4>] kernel_thread_helper+0x4/0x10
       [<ffffffff81083180>] ? kthread+0x0/0xa0
       [<ffffffff8100cec0>] ? kernel_thread_helper+0x0/0x10
      
      We fix this problem by splitting bios when we submit bios.
      Reported-by: NTsutomu Itoh <t-itoh@jp.fujitsu.com>
      Signed-off-by: NMiao Xie <miaox@cn.fujitsu.com>
      Tested-by: NTsutomu Itoh <t-itoh@jp.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      e65e1535
    • M
      btrfs: fix free dip and dip->csums twice · 0c56fa96
      Miao Xie 提交于
      bio_endio() will free dip and dip->csums, so dip and dip->csums twice will
      be freed twice. Fix it.
      Signed-off-by: NMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      0c56fa96
  7. 30 10月, 2010 3 次提交
  8. 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
  9. 26 10月, 2010 2 次提交
  10. 23 10月, 2010 1 次提交
    • J
      Btrfs: re-work delalloc flushing · 0019f10d
      Josef Bacik 提交于
      Currently we try and flush delalloc, but we only do that in a sort of weak way,
      which works fine in most cases but if we're under heavy pressure we need to be
      able to wait for flushing to happen.  Also instead of checking the bytes
      reserved in the block_rsv, check the space info since it is more accurate.  The
      sync option will be used in a future patch.
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      0019f10d
  11. 10 8月, 2010 5 次提交
    • A
      btrfs: remove junk sb_dirt change · 696ac96c
      Artem Bityutskiy 提交于
      BTRFS does not define a '->write_super()' method, so it should
      not mark its superblock as dirty. This looks like some left-over.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Acked-by: NChris Mason <chris.mason@oracle.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      696ac96c
    • A
      Make ->drop_inode() just return whether inode needs to be dropped · 45321ac5
      Al Viro 提交于
      ... and let iput_final() do the actual eviction or retention
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      45321ac5
    • A
      convert btrfs to ->evict_inode() · bd555975
      Al Viro 提交于
      NB: do we want btrfs_wait_ordered_range() on eviction of
      inodes with positive i_nlink on subvolume with zero root_refs?
      If not, btrfs_evict_inode() can be simplified by unconditionally
      bailing out in case of i_nlink > 0 in the very beginning...
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      bd555975
    • A
      simplify checks for I_CLEAR/I_FREEING · a4ffdde6
      Al Viro 提交于
      add I_CLEAR instead of replacing I_FREEING with it.  I_CLEAR is
      equivalent to I_FREEING for almost all code looking at either;
      it's there to keep track of having called clear_inode() exactly
      once per inode lifetime, at some point after having set I_FREEING.
      I_CLEAR and I_FREEING never get set at the same time with the
      current code, so we can switch to setting i_flags to I_FREEING | I_CLEAR
      instead of I_CLEAR without loss of information.  As the result of
      such change, checks become simpler and the amount of code that needs
      to know about I_CLEAR shrinks a lot.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      a4ffdde6
    • C
      remove inode_setattr · 1025774c
      Christoph Hellwig 提交于
      Replace inode_setattr with opencoded variants of it in all callers.  This
      moves the remaining call to vmtruncate into the filesystem methods where it
      can be replaced with the proper truncate sequence.
      
      In a few cases it was obvious that we would never end up calling vmtruncate
      so it was left out in the opencoded variant:
      
       spufs: explicitly checks for ATTR_SIZE earlier
       btrfs,hugetlbfs,logfs,dlmfs: explicitly clears ATTR_SIZE earlier
       ufs: contains an opencoded simple_seattr + truncate that sets the filesize just above
      
      In addition to that ncpfs called inode_setattr with handcrafted iattrs,
      which allowed to trim down the opencoded variant.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      1025774c
  12. 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
  13. 11 6月, 2010 2 次提交
  14. 27 5月, 2010 3 次提交
  15. 26 5月, 2010 3 次提交
    • C
      Btrfs: avoid ENOSPC errors in btrfs_dirty_inode · 94b60442
      Chris Mason 提交于
      btrfs_dirty_inode tries to sneak in without much waiting or
      space reservation, mostly for performance reasons.  This
      usually works well but can cause problems when there are
      many many writers.
      
      When btrfs_update_inode fails with ENOSPC, we fallback
      to a slower btrfs_start_transaction call that will reserve
      some space.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      94b60442
    • C
      Btrfs: move O_DIRECT space reservation to btrfs_direct_IO · 3f7c579c
      Chris Mason 提交于
      This moves the delalloc space reservation done for O_DIRECT
      into btrfs_direct_IO.  This way we don't leak reserved space
      if the generic O_DIRECT write code errors out before it
      calls into btrfs_direct_IO.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      3f7c579c
    • C
      Btrfs: rework O_DIRECT enospc handling · 4845e44f
      Chris Mason 提交于
      This changes O_DIRECT write code to mark extents as delalloc
      while it is processing them.  Yan Zheng has reworked the
      enospc accounting based on tracking delalloc extents and
      this makes it much easier to track enospc in the O_DIRECT code.
      
      There are a few space cases with the O_DIRECT code though,
      it only sets the EXTENT_DELALLOC bits, instead of doing
      EXTENT_DELALLOC | EXTENT_DIRTY | EXTENT_UPTODATE, because
      we don't want to mess with clearing the dirty and uptodate
      bits when things go wrong.  This is important because there
      are no pages in the page cache, so any extent state structs
      that we put in the tree won't get freed by releasepage.  We have
      to clear them ourselves as the DIO ends.
      
      With this commit, we reserve space at in btrfs_file_aio_write,
      and then as each btrfs_direct_IO call progresses it sets
      EXTENT_DELALLOC on the range.
      
      btrfs_get_blocks_direct is responsible for clearing the delalloc
      at the same time it drops the extent lock.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      4845e44f
  16. 25 5月, 2010 2 次提交
    • C
      Btrfs: use async helpers for DIO write checksumming · eaf25d93
      Chris Mason 提交于
      The async helper threads offload crc work onto all the
      CPUs, and make streaming writes much faster.  This
      changes the O_DIRECT write code to use them.  The only
      small complication was that we need to pass in the
      logical offset in the file for each bio, because we can't
      find it in the bio's pages.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      eaf25d93
    • J
      Btrfs: add basic DIO read/write support · 4b46fce2
      Josef Bacik 提交于
      This provides basic DIO support for reading and writing.  It does not do the
      work to recover from mismatching checksums, that will come later.  A few design
      changes have been made from Jim's code (sorry Jim!)
      
      1) Use the generic direct-io code.  Jim originally re-wrote all the generic DIO
      code in order to account for all of BTRFS's oddities, but thanks to that work it
      seems like the best bet is to just ignore compression and such and just opt to
      fallback on buffered IO.
      
      2) Fallback on buffered IO for compressed or inline extents.  Jim's code did
      it's own buffering to make dio with compressed extents work.  Now we just
      fallback onto normal buffered IO.
      
      3) Use ordered extents for the writes so that all of the
      
      lock_extent()
      lookup_ordered()
      
      type checks continue to work.
      
      4) Do the lock_extent() lookup_ordered() loop in readpage so we don't race with
      DIO writes.
      
      I've tested this with fsx and everything works great.  This patch depends on my
      dio and filemap.c patches to work.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      4b46fce2