1. 27 5月, 2011 5 次提交
  2. 24 5月, 2011 19 次提交
  3. 23 5月, 2011 1 次提交
    • L
      Btrfs: do not flush csum items of unchanged file data during treelog · 8e531cdf
      liubo 提交于
      The current code relogs the entire inode every time during fsync log,
      and it is much better suited to small files rather than large ones.
      
      During my performance test, the fsync performace of large files sucks,
      and we can ascribe this to the tremendous amount of csum infos of the
      large ones, cause we have to flush all of these csum infos into log trees
      even when there are only _one_ change in the whole file data.  Apparently,
      to optimize fsync, we need to create a filter to skip the unnecessary csum
      ones, that is, the corresponding file data remains unchanged before this fsync.
      
      Here I have some test results to show, I use sysbench to do "random write + fsync".
      
      ===
      sysbench --test=fileio --num-threads=1 --file-num=2 --file-block-size=4K --file-total-size=8G --file-test-mode=rndwr --file-io-mode=sync --file-extra-flags=  [prepare, run]
      ===
      
      Sysbench args:
        - Number of threads: 1
        - Extra file open flags: 0
        - 2 files, 4Gb each
        - Block size 4Kb
        - Number of random requests for random IO: 10000
        - Read/Write ratio for combined random IO test: 1.50
        - Periodic FSYNC enabled, calling fsync() each 100 requests.
        - Calling fsync() at the end of test, Enabled.
        - Using synchronous I/O mode
        - Doing random write test
      
      Sysbench results:
      ===
         Operations performed:  0 Read, 10000 Write, 200 Other = 10200 Total
         Read 0b  Written 39.062Mb  Total transferred 39.062Mb
      ===
      a) without patch:  (*SPEED* : 451.01Kb/sec)
         112.75 Requests/sec executed
      
      b) with patch:     (*SPEED* : 4.7533Mb/sec)
         1216.84 Requests/sec executed
      
      PS: I've made a _sub transid_ stuff patch, but it does not perform as effectively as this patch,
      and I'm wanderring where the problem is and trying to improve it more.
      Signed-off-by: NLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      8e531cdf
  4. 22 5月, 2011 1 次提交
  5. 21 5月, 2011 1 次提交
    • M
      btrfs: implement delayed inode items operation · 16cdcec7
      Miao Xie 提交于
      Changelog V5 -> V6:
      - Fix oom when the memory load is high, by storing the delayed nodes into the
        root's radix tree, and letting btrfs inodes go.
      
      Changelog V4 -> V5:
      - Fix the race on adding the delayed node to the inode, which is spotted by
        Chris Mason.
      - Merge Chris Mason's incremental patch into this patch.
      - Fix deadlock between readdir() and memory fault, which is reported by
        Itaru Kitayama.
      
      Changelog V3 -> V4:
      - Fix nested lock, which is reported by Itaru Kitayama, by updating space cache
        inode in time.
      
      Changelog V2 -> V3:
      - Fix the race between the delayed worker and the task which does delayed items
        balance, which is reported by Tsutomu Itoh.
      - Modify the patch address David Sterba's comment.
      - Fix the bug of the cpu recursion spinlock, reported by Chris Mason
      
      Changelog V1 -> V2:
      - break up the global rb-tree, use a list to manage the delayed nodes,
        which is created for every directory and file, and used to manage the
        delayed directory name index items and the delayed inode item.
      - introduce a worker to deal with the delayed nodes.
      
      Compare with Ext3/4, the performance of file creation and deletion on btrfs
      is very poor. the reason is that btrfs must do a lot of b+ tree insertions,
      such as inode item, directory name item, directory name index and so on.
      
      If we can do some delayed b+ tree insertion or deletion, we can improve the
      performance, so we made this patch which implemented delayed directory name
      index insertion/deletion and delayed inode update.
      
      Implementation:
      - introduce a delayed root object into the filesystem, that use two lists to
        manage the delayed nodes which are created for every file/directory.
        One is used to manage all the delayed nodes that have delayed items. And the
        other is used to manage the delayed nodes which is waiting to be dealt with
        by the work thread.
      - Every delayed node has two rb-tree, one is used to manage the directory name
        index which is going to be inserted into b+ tree, and the other is used to
        manage the directory name index which is going to be deleted from b+ tree.
      - introduce a worker to deal with the delayed operation. This worker is used
        to deal with the works of the delayed directory name index items insertion
        and deletion and the delayed inode update.
        When the delayed items is beyond the lower limit, we create works for some
        delayed nodes and insert them into the work queue of the worker, and then
        go back.
        When the delayed items is beyond the upper bound, we create works for all
        the delayed nodes that haven't been dealt with, and insert them into the work
        queue of the worker, and then wait for that the untreated items is below some
        threshold value.
      - When we want to insert a directory name index into b+ tree, we just add the
        information into the delayed inserting rb-tree.
        And then we check the number of the delayed items and do delayed items
        balance. (The balance policy is above.)
      - When we want to delete a directory name index from the b+ tree, we search it
        in the inserting rb-tree at first. If we look it up, just drop it. If not,
        add the key of it into the delayed deleting rb-tree.
        Similar to the delayed inserting rb-tree, we also check the number of the
        delayed items and do delayed items balance.
        (The same to inserting manipulation)
      - When we want to update the metadata of some inode, we cached the data of the
        inode into the delayed node. the worker will flush it into the b+ tree after
        dealing with the delayed insertion and deletion.
      - We will move the delayed node to the tail of the list after we access the
        delayed node, By this way, we can cache more delayed items and merge more
        inode updates.
      - If we want to commit transaction, we will deal with all the delayed node.
      - the delayed node will be freed when we free the btrfs inode.
      - Before we log the inode items, we commit all the directory name index items
        and the delayed inode update.
      
      I did a quick test by the benchmark tool[1] and found we can improve the
      performance of file creation by ~15%, and file deletion by ~20%.
      
      Before applying this patch:
      Create files:
              Total files: 50000
              Total time: 1.096108
              Average time: 0.000022
      Delete files:
              Total files: 50000
              Total time: 1.510403
              Average time: 0.000030
      
      After applying this patch:
      Create files:
              Total files: 50000
              Total time: 0.932899
              Average time: 0.000019
      Delete files:
              Total files: 50000
              Total time: 1.215732
              Average time: 0.000024
      
      [1] http://marc.info/?l=linux-btrfs&m=128212635122920&q=p3
      
      Many thanks for Kitayama-san's help!
      Signed-off-by: NMiao Xie <miaox@cn.fujitsu.com>
      Reviewed-by: NDavid Sterba <dave@jikos.cz>
      Tested-by: NTsutomu Itoh <t-itoh@jp.fujitsu.com>
      Tested-by: NItaru Kitayama <kitayama@cl.bb4u.ne.jp>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      16cdcec7
  6. 15 5月, 2011 5 次提交
  7. 13 5月, 2011 5 次提交
    • A
      btrfs: quasi-round-robin for chunk allocation · 73c5de00
      Arne Jansen 提交于
      In a multi device setup, the chunk allocator currently always allocates
      chunks on the devices in the same order. This leads to a very uneven
      distribution, especially with RAID1 or RAID10 and an uneven number of
      devices.
      This patch always sorts the devices before allocating, and allocates the
      stripes on the devices with the most available space, as long as there
      is enough space available. In a low space situation, it first tries to
      maximize striping.
      The patch also simplifies the allocator and reduces the checks for
      corner cases.
      The simplification is done by several means. First, it defines the
      properties of each RAID type upfront. These properties are used afterwards
      instead of differentiating cases in several places.
      Second, the old allocator defined a minimum stripe size for each block
      group type, tried to find a large enough chunk, and if this fails just
      allocates a smaller one. This is now done in one step. The largest possible
      chunk (up to max_chunk_size) is searched and allocated.
      Because we now have only one pass, the allocation of the map (struct
      map_lookup) is moved down to the point where the number of stripes is
      already known. This way we avoid reallocation of the map.
      We still avoid allocating stripes that are not a multiple of STRIPE_SIZE.
      73c5de00
    • A
      btrfs: heed alloc_start · a9c9bf68
      Arne Jansen 提交于
      currently alloc_start is disregarded if the requested
      chunk size is bigger than (device size - alloc_start),
      but smaller than the device size.
      The only situation where I see this could have made sense
      was when a chunk equal the size of the device has been
      requested. This was possible as the allocator failed to
      take alloc_start into account when calculating the request
      chunk size. As this gets fixed by this patch, the workaround
      is not necessary anymore.
      a9c9bf68
    • A
      btrfs: move btrfs_cmp_device_free_bytes to super.c · bcd53741
      Arne Jansen 提交于
      this function won't be used here anymore, so move it super.c where it is
      used for df-calculation
      bcd53741
    • D
      btrfs: use unsigned type for single bit bitfield · 4ea02885
      David Sterba 提交于
      Signed-off-by: NDavid Sterba <dsterba@suse.cz>
      4ea02885
    • D
      btrfs: use printk_ratelimited instead of printk_ratelimit · 7a36ddec
      David Sterba 提交于
      As per printk_ratelimit comment, it should not be used.
      Signed-off-by: NDavid Sterba <dsterba@suse.cz>
      7a36ddec
  8. 12 5月, 2011 3 次提交
    • A
      btrfs: add readonly flag · 8628764e
      Arne Jansen 提交于
      setting the readonly flag prevents writes in case an error is detected
      Signed-off-by: NArne Jansen <sensille@gmx.net>
      8628764e
    • I
      btrfs scrub: make fixups sync · 96e36920
      Ilya Dryomov 提交于
      btrfs scrub - make fixups sync, don't reuse fixup bios
      
      Fixups are already sync for csum failures, this patch makes them sync
      for EIO case as well.
      
      Fixups are now sharing pages with the parent sbio - instead of
      allocating a separate page to do a fixup we grab the page from the sbio
      buffer.
      
      Fixup bios are no longer reused.
      
      struct fixup is no longer needed, instead pass [sbio pointer, index].
      
      Originally this was added to look at the possibility of sharing the code
      between drive swap and scrub, but it actually fixes a serious bug in
      scrub code where errors that could be corrected were ignored and
      reported as uncorrectable.
      
      btrfs scrub - restore bios properly after media errors
      
      The current code reallocates a bio after a media error.  This is a
      temporary measure introduced in v3 after a serious problem related to
      bio reuse was found in v2 of scrub patchset.
      
      Basically we did not reset bv_offset and bv_len fields of the bio_vec
      structure.  They are changed in case I/O error happens, for example, at
      offset 512 or 1024 into the page.  Also bi_flags field wasn't properly
      setup before reusing the bio.
      Signed-off-by: NArne Jansen <sensille@gmx.net>
      96e36920
    • J
      btrfs: new ioctls for scrub · 475f6387
      Jan Schmidt 提交于
      adds ioctls necessary to start and cancel scrubs, to get current
      progress and to get info about devices to be scrubbed.
      Note that the scrub is done per-device and that the ioctl only
      returns after the scrub for this devices is finished or has been
      canceled.
      Signed-off-by: NArne Jansen <sensille@gmx.net>
      475f6387