2007-06-12 17:07:21 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Oracle. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public
|
|
|
|
* License v2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 021110-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-04-10 17:27:04 +04:00
|
|
|
#ifndef __IOCTL_
|
|
|
|
#define __IOCTL_
|
|
|
|
#include <linux/ioctl.h>
|
|
|
|
|
|
|
|
#define BTRFS_IOCTL_MAGIC 0x94
|
|
|
|
#define BTRFS_VOL_NAME_MAX 255
|
2008-03-24 22:02:07 +03:00
|
|
|
|
2009-01-16 19:59:08 +03:00
|
|
|
/* this should be 4k */
|
2010-10-29 23:41:32 +04:00
|
|
|
#define BTRFS_PATH_NAME_MAX 4087
|
2007-04-10 17:27:04 +04:00
|
|
|
struct btrfs_ioctl_vol_args {
|
2008-11-18 05:02:50 +03:00
|
|
|
__s64 fd;
|
2008-03-24 22:02:07 +03:00
|
|
|
char name[BTRFS_PATH_NAME_MAX + 1];
|
2007-04-10 17:27:04 +04:00
|
|
|
};
|
|
|
|
|
2010-12-10 09:41:56 +03:00
|
|
|
#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
|
2010-12-20 11:04:08 +03:00
|
|
|
#define BTRFS_SUBVOL_RDONLY (1ULL << 1)
|
2010-12-10 09:41:56 +03:00
|
|
|
|
|
|
|
#define BTRFS_SUBVOL_NAME_MAX 4039
|
|
|
|
struct btrfs_ioctl_vol_args_v2 {
|
2010-10-29 23:41:32 +04:00
|
|
|
__s64 fd;
|
|
|
|
__u64 transid;
|
2010-12-10 09:41:56 +03:00
|
|
|
__u64 flags;
|
|
|
|
__u64 unused[4];
|
|
|
|
char name[BTRFS_SUBVOL_NAME_MAX + 1];
|
2010-10-29 23:41:32 +04:00
|
|
|
};
|
|
|
|
|
2010-02-28 23:39:26 +03:00
|
|
|
#define BTRFS_INO_LOOKUP_PATH_MAX 4080
|
|
|
|
struct btrfs_ioctl_ino_lookup_args {
|
|
|
|
__u64 treeid;
|
|
|
|
__u64 objectid;
|
|
|
|
char name[BTRFS_INO_LOOKUP_PATH_MAX];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct btrfs_ioctl_search_key {
|
|
|
|
/* which root are we searching. 0 is the tree of tree roots */
|
|
|
|
__u64 tree_id;
|
|
|
|
|
|
|
|
/* keys returned will be >= min and <= max */
|
|
|
|
__u64 min_objectid;
|
|
|
|
__u64 max_objectid;
|
|
|
|
|
|
|
|
/* keys returned will be >= min and <= max */
|
|
|
|
__u64 min_offset;
|
|
|
|
__u64 max_offset;
|
|
|
|
|
|
|
|
/* max and min transids to search for */
|
|
|
|
__u64 min_transid;
|
|
|
|
__u64 max_transid;
|
|
|
|
|
|
|
|
/* keys returned will be >= min and <= max */
|
|
|
|
__u32 min_type;
|
|
|
|
__u32 max_type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* how many items did userland ask for, and how many are we
|
|
|
|
* returning
|
|
|
|
*/
|
|
|
|
__u32 nr_items;
|
|
|
|
|
|
|
|
/* align to 64 bits */
|
|
|
|
__u32 unused;
|
|
|
|
|
|
|
|
/* some extra for later */
|
|
|
|
__u64 unused1;
|
|
|
|
__u64 unused2;
|
|
|
|
__u64 unused3;
|
|
|
|
__u64 unused4;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct btrfs_ioctl_search_header {
|
|
|
|
__u64 transid;
|
|
|
|
__u64 objectid;
|
|
|
|
__u64 offset;
|
|
|
|
__u32 type;
|
|
|
|
__u32 len;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
|
|
|
|
/*
|
|
|
|
* the buf is an array of search headers where
|
|
|
|
* each header is followed by the actual item
|
|
|
|
* the type field is expanded to 32 bits for alignment
|
|
|
|
*/
|
|
|
|
struct btrfs_ioctl_search_args {
|
|
|
|
struct btrfs_ioctl_search_key key;
|
|
|
|
char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
|
|
|
|
};
|
|
|
|
|
2009-01-16 19:59:08 +03:00
|
|
|
struct btrfs_ioctl_clone_range_args {
|
|
|
|
__s64 src_fd;
|
|
|
|
__u64 src_offset, src_length;
|
|
|
|
__u64 dest_offset;
|
|
|
|
};
|
|
|
|
|
2010-03-11 17:42:04 +03:00
|
|
|
/* flags for the defrag range ioctl */
|
|
|
|
#define BTRFS_DEFRAG_RANGE_COMPRESS 1
|
|
|
|
#define BTRFS_DEFRAG_RANGE_START_IO 2
|
|
|
|
|
|
|
|
struct btrfs_ioctl_defrag_range_args {
|
|
|
|
/* start of the defrag operation */
|
|
|
|
__u64 start;
|
|
|
|
|
|
|
|
/* number of bytes to defrag, use (u64)-1 to say all */
|
|
|
|
__u64 len;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* flags for the operation, which can include turning
|
|
|
|
* on compression for this one defrag
|
|
|
|
*/
|
|
|
|
__u64 flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* any extent bigger than this will be considered
|
|
|
|
* already defragged. Use 0 to take the kernel default
|
|
|
|
* Use 1 to say every single extent must be rewritten
|
|
|
|
*/
|
|
|
|
__u32 extent_thresh;
|
|
|
|
|
2010-10-25 11:12:50 +04:00
|
|
|
/*
|
|
|
|
* which compression method to use if turning on compression
|
|
|
|
* for this defrag operation. If unspecified, zlib will
|
|
|
|
* be used
|
|
|
|
*/
|
|
|
|
__u32 compress_type;
|
|
|
|
|
2010-03-11 17:42:04 +03:00
|
|
|
/* spare for later */
|
2010-10-25 11:12:50 +04:00
|
|
|
__u32 unused[4];
|
2010-03-11 17:42:04 +03:00
|
|
|
};
|
|
|
|
|
2010-01-13 21:19:06 +03:00
|
|
|
struct btrfs_ioctl_space_info {
|
2010-03-16 03:02:26 +03:00
|
|
|
__u64 flags;
|
|
|
|
__u64 total_bytes;
|
|
|
|
__u64 used_bytes;
|
2010-01-13 21:19:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct btrfs_ioctl_space_args {
|
2010-03-16 03:02:26 +03:00
|
|
|
__u64 space_slots;
|
|
|
|
__u64 total_spaces;
|
2010-01-13 21:19:06 +03:00
|
|
|
struct btrfs_ioctl_space_info spaces[0];
|
|
|
|
};
|
2010-03-11 17:42:04 +03:00
|
|
|
|
2007-04-10 17:27:04 +04:00
|
|
|
#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
|
|
|
|
struct btrfs_ioctl_vol_args)
|
2007-08-08 00:15:09 +04:00
|
|
|
#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
|
2007-04-12 18:43:05 +04:00
|
|
|
struct btrfs_ioctl_vol_args)
|
2007-12-22 00:27:24 +03:00
|
|
|
#define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
|
|
|
|
struct btrfs_ioctl_vol_args)
|
2008-03-24 22:02:07 +03:00
|
|
|
#define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
|
|
|
|
struct btrfs_ioctl_vol_args)
|
2008-06-10 18:07:39 +04:00
|
|
|
/* trans start and trans end are dangerous, and only for
|
|
|
|
* use by applications that know how to avoid the
|
|
|
|
* resulting deadlocks
|
|
|
|
*/
|
|
|
|
#define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
|
|
|
|
#define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
|
|
|
|
#define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
|
|
|
|
|
2008-05-02 22:43:14 +04:00
|
|
|
#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
|
2008-04-28 23:29:42 +04:00
|
|
|
#define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
|
|
|
|
struct btrfs_ioctl_vol_args)
|
|
|
|
#define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
|
|
|
|
struct btrfs_ioctl_vol_args)
|
|
|
|
#define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
|
|
|
|
struct btrfs_ioctl_vol_args)
|
2008-11-12 22:32:25 +03:00
|
|
|
|
|
|
|
#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
|
|
|
|
struct btrfs_ioctl_clone_range_args)
|
|
|
|
|
2008-11-18 05:02:50 +03:00
|
|
|
#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
|
|
|
|
struct btrfs_ioctl_vol_args)
|
2009-09-22 00:00:26 +04:00
|
|
|
#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
|
|
|
|
struct btrfs_ioctl_vol_args)
|
2010-03-11 17:42:04 +03:00
|
|
|
#define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
|
|
|
|
struct btrfs_ioctl_defrag_range_args)
|
2010-02-28 23:39:26 +03:00
|
|
|
#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
|
|
|
|
struct btrfs_ioctl_search_args)
|
|
|
|
#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
|
|
|
|
struct btrfs_ioctl_ino_lookup_args)
|
2009-12-12 00:11:29 +03:00
|
|
|
#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
|
2010-01-13 21:19:06 +03:00
|
|
|
#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
|
|
|
|
struct btrfs_ioctl_space_args)
|
Btrfs: add START_SYNC, WAIT_SYNC ioctls
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 <sage@newdream.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-10-29 23:41:32 +04:00
|
|
|
#define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
|
|
|
|
#define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
|
2010-12-10 09:41:56 +03:00
|
|
|
#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
|
|
|
|
struct btrfs_ioctl_vol_args_v2)
|
2010-12-20 11:30:25 +03:00
|
|
|
#define BTRFS_IOC_SUBVOL_GETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 25, __u64)
|
|
|
|
#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
|
2007-04-10 17:27:04 +04:00
|
|
|
#endif
|