]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/bcachefs_ioctl.h
Move c_src dirs back to toplevel
[bcachefs-tools-debian] / libbcachefs / bcachefs_ioctl.h
index f1cb5d40512996c67e115d51c5bda15e83c4db39..4b8fba754b1c13f069bb6d1a199d94e591a62668 100644 (file)
@@ -78,6 +78,14 @@ struct bch_ioctl_incremental {
 #define BCH_IOCTL_DISK_RESIZE  _IOW(0xbc,      14,  struct bch_ioctl_disk_resize)
 #define BCH_IOCTL_DISK_RESIZE_JOURNAL _IOW(0xbc,15,  struct bch_ioctl_disk_resize_journal)
 
+#define BCH_IOCTL_SUBVOLUME_CREATE _IOW(0xbc,  16,  struct bch_ioctl_subvolume)
+#define BCH_IOCTL_SUBVOLUME_DESTROY _IOW(0xbc, 17,  struct bch_ioctl_subvolume)
+
+#define BCH_IOCTL_DEV_USAGE_V2 _IOWR(0xbc,     18, struct bch_ioctl_dev_usage_v2)
+
+#define BCH_IOCTL_FSCK_OFFLINE _IOW(0xbc,      19,  struct bch_ioctl_fsck_offline)
+#define BCH_IOCTL_FSCK_ONLINE  _IOW(0xbc,      20,  struct bch_ioctl_fsck_online)
+
 /* ioctl below act on a particular file, not the filesystem as a whole: */
 
 #define BCHFS_IOC_REINHERIT_ATTRS      _IOR(0xbc, 64, const char __user *)
@@ -90,7 +98,7 @@ struct bch_ioctl_incremental {
  * this UUID.
  */
 struct bch_ioctl_query_uuid {
-       uuid_le                 uuid;
+       __uuid_t                uuid;
 };
 
 #if 0
@@ -170,11 +178,18 @@ struct bch_ioctl_disk_set_state {
        __u64                   dev;
 };
 
+#define BCH_DATA_OPS()                 \
+       x(scrub,                0)      \
+       x(rereplicate,          1)      \
+       x(migrate,              2)      \
+       x(rewrite_old_nodes,    3)      \
+       x(drop_extra_replicas,  4)
+
 enum bch_data_ops {
-       BCH_DATA_OP_SCRUB       = 0,
-       BCH_DATA_OP_REREPLICATE = 1,
-       BCH_DATA_OP_MIGRATE     = 2,
-       BCH_DATA_OP_NR          = 3,
+#define x(t, n) BCH_DATA_OP_##t = n,
+       BCH_DATA_OPS()
+#undef x
+       BCH_DATA_OP_NR
 };
 
 /*
@@ -187,11 +202,13 @@ enum bch_data_ops {
  * job. The file descriptor is O_CLOEXEC.
  */
 struct bch_ioctl_data {
-       __u32                   op;
+       __u16                   op;
+       __u8                    start_btree;
+       __u8                    end_btree;
        __u32                   flags;
 
-       struct bpos             start;
-       struct bpos             end;
+       struct bpos             start_pos;
+       struct bpos             end_pos;
 
        union {
        struct {
@@ -202,7 +219,7 @@ struct bch_ioctl_data {
                __u64           pad[8];
        };
        };
-} __attribute__((packed, aligned(8)));
+} __packed __aligned(8);
 
 enum bch_data_event {
        BCH_DATA_EVENT_PROGRESS = 0,
@@ -218,7 +235,7 @@ struct bch_ioctl_data_progress {
 
        __u64                   sectors_done;
        __u64                   sectors_total;
-} __attribute__((packed, aligned(8)));
+} __packed __aligned(8);
 
 struct bch_ioctl_data_event {
        __u8                    type;
@@ -227,12 +244,12 @@ struct bch_ioctl_data_event {
        struct bch_ioctl_data_progress p;
        __u64                   pad2[15];
        };
-} __attribute__((packed, aligned(8)));
+} __packed __aligned(8);
 
 struct bch_replicas_usage {
        __u64                   sectors;
-       struct bch_replicas_entry r;
-} __attribute__((packed));
+       struct bch_replicas_entry_v1 r;
+} __packed;
 
 static inline struct bch_replicas_usage *
 replicas_usage_next(struct bch_replicas_usage *u)
@@ -262,7 +279,7 @@ struct bch_ioctl_fs_usage {
        __u32                   replica_entries_bytes;
        __u32                   pad;
 
-       struct bch_replicas_usage replicas[0];
+       struct bch_replicas_usage replicas[];
 };
 
 /*
@@ -279,13 +296,27 @@ struct bch_ioctl_dev_usage {
 
        __u32                   bucket_size;
        __u64                   nr_buckets;
-       __u64                   available_buckets;
 
-       __u64                   buckets[BCH_DATA_NR];
-       __u64                   sectors[BCH_DATA_NR];
+       __u64                   buckets_ec;
+
+       struct bch_ioctl_dev_usage_type {
+               __u64           buckets;
+               __u64           sectors;
+               __u64           fragmented;
+       }                       d[10];
+};
+
+struct bch_ioctl_dev_usage_v2 {
+       __u64                   dev;
+       __u32                   flags;
+       __u8                    state;
+       __u8                    nr_data_types;
+       __u8                    pad[6];
+
+       __u32                   bucket_size;
+       __u64                   nr_buckets;
 
-       __u64                   ec_buckets;
-       __u64                   ec_sectors;
+       struct bch_ioctl_dev_usage_type d[];
 };
 
 /*
@@ -346,4 +377,36 @@ struct bch_ioctl_disk_resize_journal {
        __u64                   nbuckets;
 };
 
+struct bch_ioctl_subvolume {
+       __u32                   flags;
+       __u32                   dirfd;
+       __u16                   mode;
+       __u16                   pad[3];
+       __u64                   dst_ptr;
+       __u64                   src_ptr;
+};
+
+#define BCH_SUBVOL_SNAPSHOT_CREATE     (1U << 0)
+#define BCH_SUBVOL_SNAPSHOT_RO         (1U << 1)
+
+/*
+ * BCH_IOCTL_FSCK_OFFLINE: run fsck from the 'bcachefs fsck' userspace command,
+ * but with the kernel's implementation of fsck:
+ */
+struct bch_ioctl_fsck_offline {
+       __u64                   flags;
+       __u64                   opts;           /* string */
+       __u64                   nr_devs;
+       __u64                   devs[] __counted_by(nr_devs);
+};
+
+/*
+ * BCH_IOCTL_FSCK_ONLINE: run fsck from the 'bcachefs fsck' userspace command,
+ * but with the kernel's implementation of fsck:
+ */
+struct bch_ioctl_fsck_online {
+       __u64                   flags;
+       __u64                   opts;           /* string */
+};
+
 #endif /* _BCACHEFS_IOCTL_H */