1. 13 12月, 2012 4 次提交
    • S
      Btrfs: pass fs_info to btrfs_map_block() instead of mapping_tree · 3ec706c8
      Stefan Behrens 提交于
      This is required for the device replace procedure in a later step.
      Two calling functions also had to be changed to have the fs_info
      pointer: repair_io_failure() and scrub_setup_recheck_block().
      Signed-off-by: NStefan Behrens <sbehrens@giantdisaster.de>
      Signed-off-by: NChris Mason <chris.mason@fusionio.com>
      3ec706c8
    • S
      Btrfs: Pass fs_info to btrfs_num_copies() instead of mapping_tree · 5d964051
      Stefan Behrens 提交于
      This is required for the device replace procedure in a later step.
      Signed-off-by: NStefan Behrens <sbehrens@giantdisaster.de>
      Signed-off-by: NChris Mason <chris.mason@fusionio.com>
      5d964051
    • S
      Btrfs: add two more find_device() methods · 7ba15b7d
      Stefan Behrens 提交于
      The new function btrfs_find_device_missing_or_by_path() will be
      used for the device replace procedure. This function itself calls
      the second new function btrfs_find_device_by_path().
      Unfortunately, it is not possible to currently make the rest of the
      code use these functions as well, since all functions that look
      similar at first view are all a little bit different in what they
      are doing. But in the future, new code could benefit from these
      two new functions, and currently, device replace uses them.
      Signed-off-by: NStefan Behrens <sbehrens@giantdisaster.de>
      Signed-off-by: NChris Mason <chris.mason@fusionio.com>
      7ba15b7d
    • S
      Btrfs: rename the scrub context structure · d9d181c1
      Stefan Behrens 提交于
      The device replace procedure makes use of the scrub code. The scrub
      code is the most efficient code to read the allocated data of a disk,
      i.e. it reads sequentially in order to avoid disk head movements, it
      skips unallocated blocks, it uses read ahead mechanisms, and it
      contains all the code to detect and repair defects.
      This commit is a first preparation step to adapt the scrub code to
      be shareable for the device replace procedure.
      The block device will be removed from the scrub context state
      structure in a later step. It used to be the source block device.
      The scrub code as it is used for the device replace procedure reads
      the source data from whereever it is optimal. The source device might
      even be gone (disconnected, for instance due to a hardware failure).
      Or the drive can be so faulty so that the device replace procedure
      tries to avoid access to the faulty source drive as much as possible,
      and only if all other mirrors are damaged, as a last resort, the
      source disk is accessed.
      The modified scrub code operates as if it would handle the source
      drive and thereby generates an exact copy of the source disk on the
      target disk, even if the source disk is not present at all. Therefore
      the block device pointer to the source disk is removed in a later
      patch, and therefore the context structure is renamed (this is the
      goal of the current patch) to reflect that no source block device
      scope is there anymore.
      
      Summary:
      This first preparation step consists of a textual substitution of the
      term "dev" to the term "ctx" whereever the scrub context is used.
      Signed-off-by: NStefan Behrens <sbehrens@giantdisaster.de>
      Signed-off-by: NChris Mason <chris.mason@fusionio.com>
      d9d181c1
  2. 29 8月, 2012 1 次提交
  3. 24 7月, 2012 2 次提交
  4. 03 7月, 2012 2 次提交
  5. 15 6月, 2012 1 次提交
    • J
      Btrfs: use rcu to protect device->name · 606686ee
      Josef Bacik 提交于
      Al pointed out that we can just toss out the old name on a device and add a
      new one arbitrarily, so anybody who uses device->name in printk could
      possibly use free'd memory.  Instead of adding locking around all of this he
      suggested doing it with RCU, so I've introduced a struct rcu_string that
      does just that and have gone through and protected all accesses to
      device->name that aren't under the uuid_mutex with rcu_read_lock().  This
      protects us and I will use it for dealing with removing the device that we
      used to mount the file system in a later patch.  Thanks,
      Reviewed-by: NDavid Sterba <dsterba@suse.cz>
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      606686ee
  6. 30 5月, 2012 3 次提交
  7. 22 3月, 2012 1 次提交
  8. 17 1月, 2012 13 次提交
  9. 11 1月, 2012 1 次提交
  10. 20 11月, 2011 1 次提交
    • C
      Btrfs: fix barrier flushes · 387125fc
      Chris Mason 提交于
      When btrfs is writing the super blocks, it send barrier flushes to make
      sure writeback caching drives get all the metadata on disk in the
      right order.
      
      But, we have two bugs in the way these are sent down.  When doing
      full commits (not via the tree log), we are sending the barrier down
      before the last super when it should be going down before the first.
      
      In multi-device setups, we should be waiting for the barriers to
      complete on all devices before writing any of the supers.
      
      Both of these bugs can cause corruptions on power failures.  We fix it
      with some new code to send down empty barriers to all devices before
      writing the first super.
      
      Alexandre Oliva found the multi-device bug.  Arne Jansen did the async
      barrier loop.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      Reported-by: NAlexandre Oliva <oliva@lsd.ic.unicamp.br>
      387125fc
  11. 02 10月, 2011 1 次提交
  12. 29 9月, 2011 1 次提交
  13. 17 8月, 2011 1 次提交
    • J
      Btrfs: detect wether a device supports discard · d5e2003c
      Josef Bacik 提交于
      We have a problem where if a user specifies discard but doesn't actually support
      it we will return EOPNOTSUPP from btrfs_discard_extent.  This is a problem
      because this gets called (in a fashion) from the tree log recovery code, which
      has a nice little BUG_ON(ret) after it, which causes us to fail the tree log
      replay.  So instead detect wether our devices support discard when we're adding
      them and then don't issue discards if we know that the device doesn't support
      it.  And just for good measure set ret = 0 in btrfs_issue_discard just in case
      we still get EOPNOTSUPP so we don't screw anybody up like this again.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      d5e2003c
  14. 24 5月, 2011 1 次提交
  15. 13 5月, 2011 2 次提交
    • 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: 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
  16. 12 5月, 2011 1 次提交
    • A
      btrfs: scrub · a2de733c
      Arne Jansen 提交于
      This adds an initial implementation for scrub. It works quite
      straightforward. The usermode issues an ioctl for each device in the
      fs. For each device, it enumerates the allocated device chunks. For
      each chunk, the contained extents are enumerated and the data checksums
      fetched. The extents are read sequentially and the checksums verified.
      If an error occurs (checksum or EIO), a good copy is searched for. If
      one is found, the bad copy will be rewritten.
      All enumerations happen from the commit roots. During a transaction
      commit, the scrubs get paused and afterwards continue from the new
      roots.
      
      This commit is based on the series originally posted to linux-btrfs
      with some improvements that resulted from comments from David Sterba,
      Ilya Dryomov and Jan Schmidt.
      Signed-off-by: NArne Jansen <sensille@gmx.net>
      a2de733c
  17. 06 5月, 2011 1 次提交
  18. 04 5月, 2011 1 次提交
  19. 28 3月, 2011 2 次提交
    • L
      Btrfs: make btrfs_map_block() return entire free extent for each device of RAID0/1/10/DUP · fce3bb9a
      Li Dongyang 提交于
      btrfs_map_block() will only return a single stripe length, but we want the
      full extent be mapped to each disk when we are trimming the extent,
      so we add length to btrfs_bio_stripe and fill it if we are mapping for REQ_DISCARD.
      Signed-off-by: NLi Dongyang <lidongyang@novell.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      fce3bb9a
    • L
      Btrfs: add initial tracepoint support for btrfs · 1abe9b8a
      liubo 提交于
      Tracepoints can provide insight into why btrfs hits bugs and be greatly
      helpful for debugging, e.g
                    dd-7822  [000]  2121.641088: btrfs_inode_request: root = 5(FS_TREE), gen = 4, ino = 256, blocks = 8, disk_i_size = 0, last_trans = 8, logged_trans = 0
                    dd-7822  [000]  2121.641100: btrfs_inode_new: root = 5(FS_TREE), gen = 8, ino = 257, blocks = 0, disk_i_size = 0, last_trans = 0, logged_trans = 0
       btrfs-transacti-7804  [001]  2146.935420: btrfs_cow_block: root = 2(EXTENT_TREE), refs = 2, orig_buf = 29368320 (orig_level = 0), cow_buf = 29388800 (cow_level = 0)
       btrfs-transacti-7804  [001]  2146.935473: btrfs_cow_block: root = 1(ROOT_TREE), refs = 2, orig_buf = 29364224 (orig_level = 0), cow_buf = 29392896 (cow_level = 0)
       btrfs-transacti-7804  [001]  2146.972221: btrfs_transaction_commit: root = 1(ROOT_TREE), gen = 8
         flush-btrfs-2-7821  [001]  2155.824210: btrfs_chunk_alloc: root = 3(CHUNK_TREE), offset = 1103101952, size = 1073741824, num_stripes = 1, sub_stripes = 0, type = DATA
         flush-btrfs-2-7821  [001]  2155.824241: btrfs_cow_block: root = 2(EXTENT_TREE), refs = 2, orig_buf = 29388800 (orig_level = 0), cow_buf = 29396992 (cow_level = 0)
         flush-btrfs-2-7821  [001]  2155.824255: btrfs_cow_block: root = 4(DEV_TREE), refs = 2, orig_buf = 29372416 (orig_level = 0), cow_buf = 29401088 (cow_level = 0)
         flush-btrfs-2-7821  [000]  2155.824329: btrfs_cow_block: root = 3(CHUNK_TREE), refs = 2, orig_buf = 20971520 (orig_level = 0), cow_buf = 20975616 (cow_level = 0)
       btrfs-endio-wri-7800  [001]  2155.898019: btrfs_cow_block: root = 5(FS_TREE), refs = 2, orig_buf = 29384704 (orig_level = 0), cow_buf = 29405184 (cow_level = 0)
       btrfs-endio-wri-7800  [001]  2155.898043: btrfs_cow_block: root = 7(CSUM_TREE), refs = 2, orig_buf = 29376512 (orig_level = 0), cow_buf = 29409280 (cow_level = 0)
      
      Here is what I have added:
      
      1) ordere_extent:
              btrfs_ordered_extent_add
              btrfs_ordered_extent_remove
              btrfs_ordered_extent_start
              btrfs_ordered_extent_put
      
      These provide critical information to understand how ordered_extents are
      updated.
      
      2) extent_map:
              btrfs_get_extent
      
      extent_map is used in both read and write cases, and it is useful for tracking
      how btrfs specific IO is running.
      
      3) writepage:
              __extent_writepage
              btrfs_writepage_end_io_hook
      
      Pages are cirtical resourses and produce a lot of corner cases during writeback,
      so it is valuable to know how page is written to disk.
      
      4) inode:
              btrfs_inode_new
              btrfs_inode_request
              btrfs_inode_evict
      
      These can show where and when a inode is created, when a inode is evicted.
      
      5) sync:
              btrfs_sync_file
              btrfs_sync_fs
      
      These show sync arguments.
      
      6) transaction:
              btrfs_transaction_commit
      
      In transaction based filesystem, it will be useful to know the generation and
      who does commit.
      
      7) back reference and cow:
      	btrfs_delayed_tree_ref
      	btrfs_delayed_data_ref
      	btrfs_delayed_ref_head
      	btrfs_cow_block
      
      Btrfs natively supports back references, these tracepoints are helpful on
      understanding btrfs's COW mechanism.
      
      8) chunk:
      	btrfs_chunk_alloc
      	btrfs_chunk_free
      
      Chunk is a link between physical offset and logical offset, and stands for space
      infomation in btrfs, and these are helpful on tracing space things.
      
      9) reserved_extent:
      	btrfs_reserved_extent_alloc
      	btrfs_reserved_extent_free
      
      These can show how btrfs uses its space.
      Signed-off-by: NLiu Bo <liubo2009@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      1abe9b8a