27 Sep, 2016

1 commit

  • For many printks, we want to know which file system issued the message.

    This patch converts most pr_* calls to use the btrfs_* versions instead.
    In some cases, this means adding plumbing to allow call sites access to
    an fs_info pointer.

    fs/btrfs/check-integrity.c is left alone for another day.

    Signed-off-by: Jeff Mahoney
    Reviewed-by: David Sterba
    Signed-off-by: David Sterba

    Jeff Mahoney
     

08 Jun, 2016

2 commits

  • The bio REQ_OP and bi_rw rq_flag_bits are now always setup, so there is
    no need to pass around the rq_flag_bits bits too. btrfs users should
    should access the bio insead.

    Signed-off-by: Mike Christie
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Jens Axboe

    Mike Christie
     
  • We no longer pass in a bitmap of rq_flag_bits bits to __btrfs_map_block.
    It will always be a REQ_OP, or the btrfs specific REQ_GET_READ_MIRRORS,
    so this drops the bit tests.

    Signed-off-by: Mike Christie
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Jens Axboe

    Mike Christie
     

16 May, 2016

2 commits


06 May, 2016

1 commit

  • The struct 'map_lookup' uses type int for @stripe_len, while
    btrfs_chunk_stripe_len() can return a u64 value, and it may end up with
    @stripe_len being undefined value and it can lead to 'divide error' in
    __btrfs_map_block().

    This changes 'map_lookup' to use type u64 for stripe_len, also right now
    we only use BTRFS_STRIPE_LEN for stripe_len, so this adds a valid checker for
    BTRFS_STRIPE_LEN.

    Reported-by: Vegard Nossum
    Reported-by: Quentin Casasnovas
    Signed-off-by: Liu Bo
    Reviewed-by: David Sterba
    [ folded division fix to scrub_raid56_parity ]
    Signed-off-by: David Sterba

    Liu Bo
     

04 May, 2016

1 commit


28 Apr, 2016

5 commits

  • The BTRFS_BALANCE_* flags are used by struct btrfs_ioctl_balance_args.flags
    and btrfs_ioctl_balance_args.{data,meta,sys}.flags in the BTRFS_IOC_BALANCE
    ioctl.

    Signed-off-by: Jeff Mahoney
    Reviewed-by: Liu Bo
    Reviewed-by: Josef Bacik
    Signed-off-by: David Sterba

    Jeff Mahoney
     
  • For clarity how we are going to find the device, let's call it a device
    specifier, devspec for short. Also rename the arguments that are a
    leftover from previous function purpose.

    Reviewed-by: Anand Jain
    Signed-off-by: David Sterba

    David Sterba
     
  • Reviewed-by: Anand Jain
    Signed-off-by: David Sterba

    David Sterba
     
  • This introduces new ioctl BTRFS_IOC_RM_DEV_V2, which uses enhanced struct
    btrfs_ioctl_vol_args_v2 to carry devid as an user argument.

    The patch won't delete the old ioctl interface and so kernel remains
    backward compatible with user land progs.

    Test case/script:
    echo "0 $(blockdev --getsz /dev/sdf) linear /dev/sdf 0" | dmsetup create bad_disk
    mkfs.btrfs -f -d raid1 -m raid1 /dev/sdd /dev/sde /dev/mapper/bad_disk
    mount /dev/sdd /btrfs
    dmsetup suspend bad_disk
    echo "0 $(blockdev --getsz /dev/sdf) error /dev/sdf 0" | dmsetup load bad_disk
    dmsetup resume bad_disk
    echo "bad disk failed. now deleting/replacing"
    btrfs dev del 3 /btrfs
    echo $?
    btrfs fi show /btrfs
    umount /btrfs
    btrfs-show-super /dev/sdd | egrep num_device
    dmsetup remove bad_disk
    wipefs -a /dev/sdf

    Signed-off-by: Anand Jain
    Reported-by: Martin
    [ adjust messages, s/disk/device/ ]
    Signed-off-by: David Sterba

    Anand Jain
     
  • The patch renames btrfs_dev_replace_find_srcdev() to
    btrfs_find_device_by_user_input() and moves it to volumes.c, so that
    delete device can use it.

    Signed-off-by: Anand Jain
    Signed-off-by: David Sterba

    Anand Jain
     

11 Jan, 2016

1 commit


07 Jan, 2016

1 commit

  • We use many constants to represent size and offset value. And to make
    code readable we use '256 * 1024 * 1024' instead of '268435456' to
    represent '256MB'. However we can make far more readable with 'SZ_256MB'
    which is defined in the 'linux/sizes.h'.

    So this patch replaces 'xxx * 1024 * 1024' kind of expression with
    single 'SZ_xxxMB' if 'xxx' is a power of 2 then 'xxx * SZ_1M' if 'xxx' is
    not a power of 2. And I haven't touched to '4096' & '8192' because it's
    more intuitive than 'SZ_4KB' & 'SZ_8KB'.

    Signed-off-by: Byongho Lee
    Signed-off-by: David Sterba

    Byongho Lee
     

24 Dec, 2015

1 commit


03 Dec, 2015

1 commit


25 Nov, 2015

1 commit

  • I've accidentally picked an already used number for the enhanced usage
    filter represented by BTRFS_BALANCE_ARGS_USAGE_RANGE, clashing with
    BTRFS_BALANCE_ARGS_CONVERT. Introduced during the development phase,
    no backward compatibility issues.

    Reported-by: Holger Hoffstätte
    Reported-by: Dan Carpenter
    Fixes: bc3094673f22 ("btrfs: extend balance filter usage to take minimum and maximum")
    Signed-off-by: David Sterba
    Signed-off-by: Chris Mason

    David Sterba
     

27 Oct, 2015

5 commits

  • Enable the extended 'limit' syntax (a range), the new 'stripes' and
    extended 'usage' syntax (a range) filters in the filters mask. The patch
    comes separate and not within the series that introduced the new filters
    because the patch adding the mask was merged in a late rc. The
    integration branch was based on an older rc and could not merge the
    patch due to the missing changes.

    Prerequisities:
    * btrfs: check unsupported filters in balance arguments
    * btrfs: extend balance filter limit to take minimum and maximum
    * btrfs: add balance filter for stripes
    * btrfs: extend balance filter usage to take minimum and maximum

    Signed-off-by: David Sterba
    Signed-off-by: Chris Mason

    David Sterba
     
  • Similar to the 'limit' filter, we can enhance the 'usage' filter to
    accept a range. The change is backward compatible, the range is applied
    only in connection with the BTRFS_BALANCE_ARGS_USAGE_RANGE flag.

    We don't have a usecase yet, the current syntax has been sufficient. The
    enhancement should provide parity with other range-like filters.

    Signed-off-by: David Sterba
    Signed-off-by: Chris Mason

    David Sterba
     
  • Balance block groups which have the given number of stripes, defined by
    a range min..max. This is useful to selectively rebalance only chunks
    that do not span enough devices, applies to RAID0/10/5/6.

    Signed-off-by: Gabríel Arthúr Pétursson
    [ renamed bargs members, added to the UAPI, wrote the changelog ]
    Signed-off-by: David Sterba

    Signed-off-by: Chris Mason

    Gabríel Arthúr Pétursson
     
  • The 'limit' filter is underdesigned, it should have been a range for
    [min,max], with some relaxed semantics when one of the bounds is
    missing. Besides that, using a full u64 for a single value is a waste of
    bytes.

    Let's fix both by extending the use of the u64 bytes for the [min,max]
    range. This can be done in a backward compatible way, the range will be
    interpreted only if the appropriate flag is set
    (BTRFS_BALANCE_ARGS_LIMIT_RANGE).

    Signed-off-by: David Sterba
    Signed-off-by: Chris Mason

    David Sterba
     
  • We don't verify that all the balance filter arguments supplemented by
    the flags are actually known to the kernel. Thus we let it silently pass
    and do nothing.

    At the moment this means only the 'limit' filter, but we're going to add
    a few more soon so it's better to have that fixed. Also in older stable
    kernels so that it works with newer userspace tools.

    Cc: stable@vger.kernel.org # 3.16+
    Signed-off-by: David Sterba
    Signed-off-by: Chris Mason

    David Sterba
     

22 Oct, 2015

3 commits


02 Oct, 2015

1 commit


01 Oct, 2015

1 commit

  • This patch updates and renames btrfs_scratch_superblocks, (which is used
    by the replace device thread), with those fixes from the scratch
    superblock code section of btrfs_rm_device(). The fixes are:
    Scratch all copies of superblock
    Notify kobject that superblock has been changed
    Update time on the device

    So that btrfs_rm_device() can use the function
    btrfs_scratch_superblocks() instead of its own scratch code. And further
    replace deivce code which similarly releases device back to the system,
    will have the fixes from the btrfs device delete.

    Signed-off-by: Anand Jain
    [renamed to btrfs_scratch_superblock]
    Signed-off-by: David Sterba

    Anand Jain
     

29 Sep, 2015

1 commit


09 Aug, 2015

1 commit


29 Jul, 2015

1 commit

  • Since we now clean up block groups automatically as they become
    empty, iterating over block groups is no longer sufficient to discard
    unused space.

    This patch iterates over the unused chunk space and discards any regions
    that are unallocated, regardless of whether they were ever used. This is
    a change for btrfs but is consistent with other file systems.

    We do this in a transactionless manner since the discard process can take
    a substantial amount of time and a transaction would need to be started
    before the acquisition of the device list lock. That would mean a
    transaction would be held open across /all/ of the discards collectively.
    In order to prevent other threads from allocating or freeing chunks, we
    hold the chunks lock across the search and discard calls. We release it
    between searches to allow the file system to perform more-or-less
    normally. Since the running transaction can commit and disappear while
    we're using the transaction pointer, we take a reference to it and
    release it after the search. This is safe since it would happen normally
    at the end of the transaction commit after any locks are released anyway.
    We also take the commit_root_sem to protect against a transaction starting
    and committing while we're running.

    Signed-off-by: Jeff Mahoney
    Reviewed-by: Filipe Manana
    Tested-by: Filipe Manana
    Signed-off-by: Chris Mason

    Jeff Mahoney
     

01 Jul, 2015

1 commit

  • Pull btrfs updates from Chris Mason:
    "Outside of our usual batch of fixes, this integrates the subvolume
    quota updates that Qu Wenruo from Fujitsu has been working on for a
    few releases now. He gets an extra gold star for making btrfs smaller
    this time, and fixing a number of quota corners in the process.

    Dave Sterba tested and integrated Anand Jain's sysfs improvements.
    Outside of exporting a symbol (ack'd by Greg) these are all internal
    to btrfs and it's mostly cleanups and fixes. Anand also attached some
    of our sysfs objects to our internal device management structs instead
    of an object off the super block. It will make device management
    easier overall and it's a better fit for how the sysfs files are used.
    None of the existing sysfs files are moved around.

    Thanks for all the fixes everyone"

    * 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (87 commits)
    btrfs: delayed-ref: double free in btrfs_add_delayed_tree_ref()
    Btrfs: Check if kobject is initialized before put
    lib: export symbol kobject_move()
    Btrfs: sysfs: add support to show replacing target in the sysfs
    Btrfs: free the stale device
    Btrfs: use received_uuid of parent during send
    Btrfs: fix use-after-free in btrfs_replay_log
    btrfs: wait for delayed iputs on no space
    btrfs: qgroup: Make snapshot accounting work with new extent-oriented qgroup.
    btrfs: qgroup: Add the ability to skip given qgroup for old/new_roots.
    btrfs: ulist: Add ulist_del() function.
    btrfs: qgroup: Cleanup the old ref_node-oriented mechanism.
    btrfs: qgroup: Switch self test to extent-oriented qgroup mechanism.
    btrfs: qgroup: Switch to new extent-oriented qgroup mechanism.
    btrfs: qgroup: Switch rescan to new mechanism.
    btrfs: qgroup: Add new qgroup calculation function btrfs_qgroup_account_extents().
    btrfs: backref: Add special time_seq == (u64)-1 case for btrfs_find_all_roots().
    btrfs: qgroup: Add new function to record old_roots.
    btrfs: qgroup: Record possible quota-related extent for qgroup.
    btrfs: qgroup: Add function qgroup_update_counters().
    ...

    Linus Torvalds
     

27 May, 2015

3 commits

  • adds fs_info pointer with struct btrfs_fs_devices.

    Signed-off-by: Anand Jain
    Signed-off-by: David Sterba

    Anand Jain
     
  • Signed-off-by: Anand Jain
    Signed-off-by: David Sterba

    Anand Jain
     
  • This patch will provide a framework and help to create attributes
    from the structure btrfs_fs_devices which are available even before
    fs_info is created. So by moving the parent kobject super_kobj from
    fs_info to btrfs_fs_devices, it will help to create attributes
    from the btrfs_fs_devices as well.

    Patches on top of this patch now will be able to create the
    sys/fs/btrfs/fsid kobject and attributes from btrfs_fs_devices
    when devices are scanned and registered to the kernel.

    Just to note, this does not change any of the existing btrfs sysfs
    external kobject names and its attributes and not even the life
    cycle of them. Changes are internal only. And to ensure the same,
    this path has been tested with various device operations and,
    checking and comparing the sysfs kobjects and attributes with
    sysfs kobject and attributes with out this patch, and they remain
    same.

    Signed-off-by: Anand Jain
    Signed-off-by: David Sterba

    Anand Jain
     

22 May, 2015

1 commit

  • Commit c4cf5261 ("bio: skip atomic inc/dec of ->bi_remaining for
    non-chains") regressed all existing callers that followed this pattern:
    1) saving a bio's original bi_end_io
    2) wiring up an intermediate bi_end_io
    3) restoring the original bi_end_io from intermediate bi_end_io
    4) calling bio_endio() to execute the restored original bi_end_io

    The regression was due to BIO_CHAIN only ever getting set if
    bio_inc_remaining() is called. For the above pattern it isn't set until
    step 3 above (step 2 would've needed to establish BIO_CHAIN). As such
    the first bio_endio(), in step 2 above, never decremented __bi_remaining
    before calling the intermediate bi_end_io -- leaving __bi_remaining with
    the value 1 instead of 0. When bio_inc_remaining() occurred during step
    3 it brought it to a value of 2. When the second bio_endio() was
    called, in step 4 above, it should've called the original bi_end_io but
    it didn't because there was an extra reference that wasn't dropped (due
    to atomic operations being optimized away since BIO_CHAIN wasn't set
    upfront).

    Fix this issue by removing the __bi_remaining management complexity for
    all callers that use the above pattern -- bio_chain() is the only
    interface that _needs_ to be concerned with __bi_remaining. For the
    above pattern callers just expect the bi_end_io they set to get called!
    Remove bio_endio_nodec() and also remove all bio_inc_remaining() calls
    that aren't associated with the bio_chain() interface.

    Also, the bio_inc_remaining() interface has been moved local to bio.c.

    Fixes: c4cf5261 ("bio: skip atomic inc/dec of ->bi_remaining for non-chains")
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jan Kara
    Signed-off-by: Mike Snitzer
    Signed-off-by: Jens Axboe

    Mike Snitzer
     

17 Feb, 2015

1 commit


22 Jan, 2015

3 commits

  • Corrent code use many kinds of "clever" way to determine operation
    target's raid type, as:
    raid_map != NULL
    or
    raid_map[MAX_NR] == RAID[56]_Q_STRIPE

    To make code easy to maintenance, this patch put raid type into
    bbio, and we can always get raid type from bbio with a "stupid"
    way.

    Signed-off-by: Zhao Lei
    Signed-off-by: Miao Xie
    Signed-off-by: Chris Mason

    Zhao Lei
     
  • 1: ref_count is simple than current RBIO_HOLD_BBIO_MAP_BIT flag
    to keep btrfs_bio's memory in raid56 recovery implement.
    2: free function for bbio will make code clean and flexible, plus
    forced data type checking in compile.

    Changelog v1->v2:
    Rename following by David Sterba's suggestion:
    put_btrfs_bio() -> btrfs_put_bio()
    get_btrfs_bio() -> btrfs_get_bio()
    bbio->ref_count -> bbio->refs

    Signed-off-by: Zhao Lei
    Signed-off-by: Miao Xie
    Signed-off-by: Chris Mason

    Zhao Lei
     
  • It can make code more simple and clear, we need not care about
    free bbio and raid_map together.

    Signed-off-by: Miao Xie
    Signed-off-by: Zhao Lei
    Signed-off-by: Chris Mason

    Zhao Lei
     

03 Dec, 2014

1 commit