04 Oct, 2016

1 commit

  • There are two separate issues that can lead to corrupted free space
    trees.

    1. The free space tree bitmaps had an endianness issue on big-endian
    systems which is fixed by an earlier patch in this series.
    2. btrfs-progs before v4.7.3 modified filesystems without updating the
    free space tree.

    To catch both of these issues at once, we need to force the free space
    tree to be rebuilt. To do so, add a FREE_SPACE_TREE_VALID compat_ro bit.
    If the bit isn't set, we know that it was either produced by a broken
    big-endian kernel or may have been corrupted by btrfs-progs.

    This also provides us with a way to add rudimentary read-write support
    for the free space tree to btrfs-progs: it can just clear this bit and
    have the kernel rebuild the free space tree.

    Cc: stable@vger.kernel.org # 4.5+
    Tested-by: Holger Hoffstätte
    Tested-by: Chandan Rajendra
    Signed-off-by: Omar Sandoval
    Signed-off-by: David Sterba

    Omar Sandoval
     

26 Jul, 2016

1 commit

  • BTRFS_IOC_LOGICAL_INO takes a btrfs_ioctl_logical_ino_args as argument,
    not a btrfs_ioctl_ino_path_args. The lines were probably copy/pasted
    when the code was written.

    Since btrfs_ioctl_logical_ino_args and btrfs_ioctl_ino_path_args have
    the same size, the actual IOCTL definition here does not change.

    But, it makes the code less confusing for the reader.

    Signed-off-by: Hans van Kranenburg
    Signed-off-by: David Sterba

    Hans van Kranenburg
     

30 May, 2016

1 commit


16 May, 2016

1 commit


28 Apr, 2016

8 commits


27 Oct, 2015

3 commits

  • 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
     

03 Feb, 2015

1 commit


21 Nov, 2014

1 commit

  • device replace could fail due to another running scrub process or any
    other errors btrfs_scrub_dev() may hit, but this failure doesn't get
    returned to userspace.

    The following steps could reproduce this issue

    mkfs -t btrfs -f /dev/sdb1 /dev/sdb2
    mount /dev/sdb1 /mnt/btrfs
    while true; do btrfs scrub start -B /mnt/btrfs >/dev/null 2>&1; done &
    btrfs replace start -Bf /dev/sdb2 /dev/sdb3 /mnt/btrfs
    # if this replace succeeded, do the following and repeat until
    # you see this log in dmesg
    # BTRFS: btrfs_scrub_dev(/dev/sdb2, 2, /dev/sdb3) failed -115
    #btrfs replace start -Bf /dev/sdb3 /dev/sdb2 /mnt/btrfs

    # once you see the error log in dmesg, check return value of
    # replace
    echo $?

    Introduce a new dev replace result

    BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS

    to catch -EINPROGRESS explicitly and return other errors directly to
    userspace.

    Signed-off-by: Eryu Guan
    Signed-off-by: Chris Mason

    Eryu Guan
     

29 Jun, 2014

1 commit

  • Creating sprout will change the fsid of the mounted root.
    do the same on the sysfs as well.

    reproducer:
    mount /dev/sdb /btrfs (seed disk)
    btrfs dev add /dev/sdc /btrfs
    mount -o rw,remount /btrfs
    btrfs dev del /dev/sdb /btrfs
    mount /dev/sdb /btrfs

    Error:
    kobject_add_internal failed for fe350492-dc28-4051-a601-e017b17e6145 with -EEXIST, don't try to register things with the same name in the same directory.

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

    Anand Jain
     

14 Jun, 2014

1 commit

  • This new ioctl call allows the user to supply a buffer of varying size in which
    a tree search can store its results. This is much more flexible if you want to
    receive items which are larger than the current fixed buffer of 3992 bytes or
    if you want to fetch more items at once. Items larger than this buffer are for
    example some of the type EXTENT_CSUM.

    Signed-off-by: Gerhard Heift
    Signed-off-by: Chris Mason
    Acked-by: David Sterba

    Gerhard Heift
     

10 Jun, 2014

2 commits

  • Provide the basic information about filesystem through the ioctl:
    * b-tree node size (same as leaf size)
    * sector size
    * expected alignment of CLONE_RANGE and EXTENT_SAME ioctl arguments

    Backward compatibility: if the values are 0, kernel does not provide
    this information, the applications should ignore them.

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

    David Sterba
     
  • This started as debugging helper, to watch the effects of converting
    between raid levels on multiple devices, but could be useful standalone.

    In my case the usage filter was not finegrained enough and led to
    converting too many chunks at once. Another example use is in connection
    with drange+devid or vrange filters that allow to work with a specific
    chunk or even with a chunk on a given device.

    The limit filter applies last, the value of 0 means no limiting.

    CC: Ilya Dryomov
    CC: Hugo Mills
    Signed-off-by: David Sterba
    Signed-off-by: Chris Mason

    David Sterba
     

15 Feb, 2014

1 commit


29 Jan, 2014

2 commits

  • btrfs filesystem df output will show the size of the metadata space
    and how much of it is used, and the user assumes that the difference
    is all usable space. Since that's not actually the case due to the
    global metadata reservation, we should provide the full picture to the
    user.

    This patch adds an ioctl that exports the size of the global metadata
    reservation so that btrfs filesystem df can report it.

    Signed-off-by: Jeff Mahoney
    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Jeff Mahoney
     
  • There are some feature bits that require no offline setup and can
    be enabled online. I've only reviewed extended irefs, but there will
    probably be more.

    We introduce three new ioctls:
    - BTRFS_IOC_GET_SUPPORTED_FEATURES: query the kernel for supported features.
    - BTRFS_IOC_GET_FEATURES: query the kernel for enabled features on a per-fs
    basis, as well as querying for which features are changeable with mounted.
    - BTRFS_IOC_SET_FEATURES: change features on a per-fs basis.

    We introduce two new masks per feature set (_SAFE_SET and _SAFE_CLEAR) that
    allow us to define which features are safe to change at runtime.

    The failure modes for BTRFS_IOC_SET_FEATURES are as follows:
    - Enabling a completely unsupported feature: warns and returns -ENOTSUPP
    - Enabling a feature that can only be done offline: warns and returns -EPERM

    Signed-off-by: Jeff Mahoney
    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Jeff Mahoney
     

01 Sep, 2013

2 commits

  • Signed-off-by: Mike Frysinger
    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Mike Frysinger
     
  • This patch adds an ioctl, BTRFS_IOC_FILE_EXTENT_SAME which will try to
    de-duplicate a list of extents across a range of files.

    Internally, the ioctl re-uses code from the clone ioctl. This avoids
    rewriting a large chunk of extent handling code.

    Userspace passes in an array of file, offset pairs along with a length
    argument. The ioctl will then (for each dedupe) do a byte-by-byte comparison
    of the user data before deduping the extent. Status and number of bytes
    deduped are returned for each operation.

    Signed-off-by: Mark Fasheh
    Reviewed-by: Zach Brown
    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Mark Fasheh
     

14 Jun, 2013

2 commits

  • when user runs command btrfs dev del the raid requisite error if any
    goes to the /var/log/messages, its not good idea to clutter messages
    with these user (knowledge) errors, further user don't have to review
    the system messages to know problem with the cli it should be dropped
    to the user as part of the cli return.

    to bring this feature created a set of the ERROR defined
    BTRFS_ERROR_DEV* error codes and created their error string.

    I expect this enum to be added with other error which we might
    want to communicate to the user land

    v3:
    moved the code with in the file no logical change

    v1->v2:
    introduce error codes for the device mgmt usage

    v1:
    adds a parameter in the ioctl arg struct to carry the error string

    Signed-off-by: Anand Jain
    Signed-off-by: Josef Bacik

    Anand Jain
     
  • btrfs_qgroup_wait_for_completion waits until the currently running qgroup
    operation completes. It returns immediately when no rescan process is in
    progress. This is useful to automate things around the rescan process (e.g.
    testing).

    Signed-off-by: Jan Schmidt
    Signed-off-by: Josef Bacik

    Jan Schmidt
     

07 May, 2013

2 commits

  • If qgroup tracking is out of sync, a rescan operation can be started. It
    iterates the complete extent tree and recalculates all qgroup tracking data.
    This is an expensive operation and should not be used unless required.

    A filesystem under rescan can still be umounted. The rescan continues on the
    next mount. Status information is provided with a separate ioctl while a
    rescan operation is in progress.

    Signed-off-by: Jan Schmidt
    Signed-off-by: Josef Bacik

    Jan Schmidt
     
  • Two new flags are added to allow omitting the stream header and the
    end command for btrfs send streams. This is used in cases where you
    send multiple snapshots back-to-back in one stream.

    This used to be encoded like this (with 2 snapshots in this example):
    + + +
    + + + EOF

    The new format (if the two new flags are used) is this one:
    + +
    +

    Note that the currently existing receivers treat only as
    an indication that a new is following. This means,
    you can just skip the sequence without
    loosing compatibility. As long as an EOF is following, the currently
    existing receivers handle the new format (if the two new flags are
    used) exactly as the old one.

    So what is the benefit of this change? The goal is to be able to use
    a single stream (one TCP connection) to multiplex a request/response
    handshake plus Btrfs send streams, all in the same stream. In this
    case you cannot evaluate an EOF condition as an end of the Btrfs send
    stream. You need something else, and the is just perfect
    for this purpose.

    The summary is:
    The format change is driven by the need to send several Btrfs send
    streams over a single TCP connections, with the ability for a repeated
    request/response handshake in the middle. And this format change does
    not break any existing tool, it is completely compatible.

    You could compare the old behaviour of the Btrfs send stream to the
    one of ftp where you need a seperate request/response channel and
    newly opened data transfer channels for each file, while the new
    behaviour is more like http using a single stream for everything.

    Signed-off-by: Stefan Behrens
    Signed-off-by: Josef Bacik

    Stefan Behrens
     

21 Feb, 2013

3 commits

  • With this new ioctl(2) BTRFS_IOC_SET_FSLABEL, we can set/change the label of a mounted file system.

    Signed-off-by: Jie Liu
    Signed-off-by: Anand Jain
    Reviewed-by: Miao Xie
    Reviewed-by: Goffredo Baroncelli
    Reviewed-by: David Sterba
    Reviewed-by: Goffredo Baroncelli
    Signed-off-by: Josef Bacik

    jeff.liu
     
  • Add a new ioctl(2) BTRFS_IOC_GET_FSLABLE, so that we can get the label upon a mounted filesystem.

    Signed-off-by: Jie Liu
    Signed-off-by: Anand Jain
    Cc: Miao Xie
    Cc: Goffredo Baroncelli
    Cc: David Sterba
    Signed-off-by: Josef Bacik

    jeff.liu
     
  • This patch adds the flag, BTRFS_SEND_FLAG_NO_FILE_DATA to the btrfs send
    ioctl code. When this flag is set, the btrfs send code will never write file
    data into the stream (thus also avoiding expensive reads of that data in the
    first place). BTRFS_SEND_C_UPDATE_EXTENT commands will be sent (instead of
    BTRFS_SEND_C_WRITE) with an offset, length pair indicating the extent in
    question.

    This patch does not affect the operation of BTRFS_SEND_C_CLONE commands -
    they will continue to be sent when a search finds an appropriate extent to
    clone from.

    Signed-off-by: Mark Fasheh
    Signed-off-by: Josef Bacik

    Mark Fasheh
     

20 Feb, 2013

1 commit