06 Nov, 2011

1 commit


29 Sep, 2011

2 commits


27 May, 2011

1 commit

  • This will detect small random writes into files and
    queue the up for an auto defrag process. It isn't well suited to
    database workloads yet, but works for smaller files such as rpm, sqlite
    or bdb databases.

    Signed-off-by: Chris Mason

    Chris Mason
     

12 May, 2011

3 commits

  • setting the readonly flag prevents writes in case an error is detected

    Signed-off-by: Arne Jansen

    Arne Jansen
     
  • 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: Arne Jansen

    Jan Schmidt
     
  • 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: Arne Jansen

    Arne Jansen
     

17 Jan, 2011

1 commit


23 Dec, 2010

2 commits

  • This allows us to set a snapshot or a subvolume readonly or writable
    on the fly.

    Usage:

    Set BTRFS_SUBVOL_RDONLY of btrfs_ioctl_vol_arg_v2->flags, and then
    call ioctl(BTRFS_IOCTL_SUBVOL_SETFLAGS);

    Changelog for v3:

    - Change to pass __u64 as ioctl parameter.

    Changelog for v2:

    - Add _GETFLAGS ioctl.
    - Check if the passed fd is the root of a subvolume.
    - Change the name from _SNAP_SETFLAGS to _SUBVOL_SETFLAGS.

    Signed-off-by: Li Zefan

    Li Zefan
     
  • Usage:

    Set BTRFS_SUBVOL_RDONLY of btrfs_ioctl_vol_arg_v2->flags, and call
    ioctl(BTRFS_I0CTL_SNAP_CREATE_V2).

    Implementation:

    - Set readonly bit of btrfs_root_item->flags.
    - Add readonly checks in btrfs_permission (inode_permission),
    btrfs_setattr, btrfs_set/remove_xattr and some ioctls.

    Changelog for v3:

    - Eliminate btrfs_root->readonly, but check btrfs_root->root_item.flags.
    - Rename BTRFS_ROOT_SNAP_RDONLY to BTRFS_ROOT_SUBVOL_RDONLY.

    Signed-off-by: Li Zefan

    Li Zefan
     

22 Dec, 2010

1 commit


11 Dec, 2010

1 commit

  • If we had reserved some bytes in struct btrfs_ioctl_vol_args, we
    wouldn't have to create a new structure for async snapshot creation.

    Here we convert async snapshot ioctl to use a more generic ABI, as
    we'll add more ioctls for snapshots/subvolumes in the future, readonly
    snapshots for example.

    Signed-off-by: Li Zefan
    Signed-off-by: Chris Mason

    Li Zefan
     

30 Oct, 2010

2 commits

  • Create a snap without waiting for it to commit to disk. The ioctl is
    ordered such that subsequent operations will not be contained by the
    created snapshot, and the commit is initiated, but the ioctl does not
    wait for the snapshot to commit to disk.

    We return the specific transid to userspace so that an application can wait
    for this specific snapshot creation to commit via the WAIT_SYNC ioctl.

    Signed-off-by: Sage Weil
    Signed-off-by: Chris Mason

    Sage Weil
     
  • START_SYNC will start a sync/commit, but not wait for it to
    complete. Any modification started after the ioctl returns is
    guaranteed not to be included in the commit. If a non-NULL
    pointer is passed, the transaction id will be returned to
    userspace.

    WAIT_SYNC will wait for any in-progress commit to complete. If a
    transaction id is specified, the ioctl will block and then
    return (success) when the specified transaction has committed.
    If it has already committed when we call the ioctl, it returns
    immediately. If the specified transaction doesn't exist, it
    returns EINVAL.

    If no transaction id is specified, WAIT_SYNC will wait for the
    currently committing transaction to finish it's commit to disk.
    If there is no currently committing transaction, it returns
    success.

    These ioctls are useful for applications which want to impose an
    ordering on when fs modifications reach disk, but do not want to
    wait for the full (slow) commit process to do so.

    Picky callers can take the transid returned by START_SYNC and
    feed it to WAIT_SYNC, and be certain to wait only as long as
    necessary for the transaction _they_ started to reach disk.

    Sloppy callers can START_SYNC and WAIT_SYNC without a transid,
    and provided they didn't wait too long between the calls, they
    will get the same result. However, if a second commit starts
    before they call WAIT_SYNC, they may end up waiting longer for
    it to commit as well. Even so, a START_SYNC+WAIT_SYNC still
    guarantees that any operation completed before the START_SYNC
    reaches disk.

    Signed-off-by: Sage Weil
    Signed-off-by: Chris Mason

    Sage Weil
     

17 Mar, 2010

1 commit


15 Mar, 2010

4 commits

  • df is a very loaded question in btrfs. This gives us a way to get the per-space
    usage information so we can tell exactly what is in use where. This will help
    us figure out ENOSPC problems, and help users better understand where their disk
    space is going.

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

    Josef Bacik
     
  • The btrfs defrag ioctl was limited to doing the entire file. This
    commit adds a new interface that can defrag a specific range inside
    the file.

    It can also force compression on the file, allowing you to selectively
    compress individual files after they were created, even when mount -o
    compress isn't turned on.

    Signed-off-by: Chris Mason

    Chris Mason
     
  • This patch needs to go along with my previous patch. This lets us set the
    default dir item's location to whatever root we want to use as our default
    mounting subvol. With this we don't have to use mount -o subvol=
    anymore to mount a different subvol, we can just set the new one and it will
    just magically work. I've done some moderate testing with this, mostly just
    switching the default mount around, mounting subvols and the default mount at
    the same time and such, everything seems to work. Thanks,

    Older kernels would generally be able to still mount the filesystem with the
    default subvolume set, but it would result in a different volume being mounted,
    which could be an even more unpleasant suprise for users. So if you set your
    default subvolume, you can't go back to older kernels. Thanks,

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

    Josef Bacik
     
  • The search ioctl is a generic tool for doing btree searches from
    userland applications. The first user of the search ioctl is a
    subvolume listing feature, but we'll also use it to find new
    files in a subvolume.

    The search ioctl allows you to specify min and max keys to search for,
    along with min and max transid. It returns the items along with a
    header that includes the item key.

    Signed-off-by: Chris Mason

    Chris Mason
     

22 Sep, 2009

1 commit


17 Jan, 2009

1 commit

  • The structure used to send device in btrfs ioctl calls was not
    properly aligned, and so 32 bit ioctls would not work properly on
    64 bit kernels.

    We could fix this with compat ioctls, but we're just one byte away
    and it doesn't make sense at this stage to carry about the compat ioctls
    forever at this stage in the project.

    This patch brings the ioctl arg up to an evenly aligned 4k.

    Signed-off-by: Chris Mason

    Chris Mason
     

18 Nov, 2008

1 commit

  • Before, all snapshots and subvolumes lived in a single flat directory. This
    was awkward and confusing because the single flat directory was only writable
    with the ioctls.

    This commit changes the ioctls to create subvols and snapshots at any
    point in the directory tree. This requires making separate ioctls for
    snapshot and subvol creation instead of a combining them into one.

    The subvol ioctl does:

    btrfsctl -S subvol_name parent_dir

    After the ioctl is done subvol_name lives inside parent_dir.

    The snapshot ioctl does:

    btrfsctl -s path_for_snapshot root_to_snapshot

    path_for_snapshot can be an absolute or relative path. btrfsctl breaks it up
    into directory and basename components.

    root_to_snapshot can be any file or directory in the FS. The snapshot
    is taken of the entire root where that file lives.

    Signed-off-by: Chris Mason

    Chris Mason
     

13 Nov, 2008

1 commit

  • This patch adds an additional CLONE_RANGE ioctl to clone an arbitrary
    (block-aligned) file range to another file. The original CLONE ioctl
    becomes a special case of cloning the entire file range. The logic is a
    bit more complex now since ranges may be cloned to different offsets, and
    because we may only be cloning the beginning or end of a particular extent
    or checksum item.

    An additional sanity check ensures the source and destination files aren't
    the same (which would previously deadlock), although eventually this could
    be extended to allow the duplication of file data at a different offset
    within the same file.

    Any extents within the destination range in the target file are dropped.

    We currently do not cope with the case where a compressed inline extent
    needs to be split. This will probably require decompressing the extent
    into a temporary address_space, and inserting just the cloned portion as a
    new compressed inline extent. For now, just return -EINVAL in this case.
    Note that this never comes up in the more common case of cloning an entire
    file.

    Signed-off-by: Chris Mason

    Sage Weil
     

25 Sep, 2008

5 commits


08 Aug, 2007

1 commit


12 Jun, 2007

1 commit


12 Apr, 2007

1 commit


10 Apr, 2007

1 commit