]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/bcachefs_ioctl.h
Update bcachefs sources to 6a20aede29 bcachefs: Fix quotas + snapshots
[bcachefs-tools-debian] / libbcachefs / bcachefs_ioctl.h
index d668ede5491a05d8fbf6610f3b38c30a8d10c9a5..ad47a506a907651bf1ead3bfa0c29c3efb04cc05 100644 (file)
@@ -14,6 +14,9 @@
 #define BCH_FORCE_IF_DATA_DEGRADED     (1 << 2)
 #define BCH_FORCE_IF_METADATA_DEGRADED (1 << 3)
 
+#define BCH_FORCE_IF_LOST                      \
+       (BCH_FORCE_IF_DATA_LOST|                \
+        BCH_FORCE_IF_METADATA_LOST)
 #define BCH_FORCE_IF_DEGRADED                  \
        (BCH_FORCE_IF_DATA_DEGRADED|            \
         BCH_FORCE_IF_METADATA_DEGRADED)
@@ -68,10 +71,15 @@ struct bch_ioctl_incremental {
 #define BCH_IOCTL_DISK_OFFLINE _IOW(0xbc,      7,  struct bch_ioctl_disk)
 #define BCH_IOCTL_DISK_SET_STATE _IOW(0xbc,    8,  struct bch_ioctl_disk_set_state)
 #define BCH_IOCTL_DATA         _IOW(0xbc,      10, struct bch_ioctl_data)
-#define BCH_IOCTL_USAGE                _IOWR(0xbc,     11, struct bch_ioctl_usage)
+#define BCH_IOCTL_FS_USAGE     _IOWR(0xbc,     11, struct bch_ioctl_fs_usage)
+#define BCH_IOCTL_DEV_USAGE    _IOWR(0xbc,     11, struct bch_ioctl_dev_usage)
 #define BCH_IOCTL_READ_SUPER   _IOW(0xbc,      12, struct bch_ioctl_read_super)
 #define BCH_IOCTL_DISK_GET_IDX _IOW(0xbc,      13,  struct bch_ioctl_disk_get_idx)
 #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)
 
 /* ioctl below act on a particular file, not the filesystem as a whole: */
 
@@ -166,10 +174,11 @@ struct bch_ioctl_disk_set_state {
 };
 
 enum bch_data_ops {
-       BCH_DATA_OP_SCRUB       = 0,
-       BCH_DATA_OP_REREPLICATE = 1,
-       BCH_DATA_OP_MIGRATE     = 2,
-       BCH_DATA_OP_NR          = 3,
+       BCH_DATA_OP_SCRUB               = 0,
+       BCH_DATA_OP_REREPLICATE         = 1,
+       BCH_DATA_OP_MIGRATE             = 2,
+       BCH_DATA_OP_REWRITE_OLD_NODES   = 3,
+       BCH_DATA_OP_NR                  = 4,
 };
 
 /*
@@ -182,11 +191,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 {
@@ -197,7 +208,7 @@ struct bch_ioctl_data {
                __u64           pad[8];
        };
        };
-} __attribute__((packed, aligned(8)));
+} __packed __aligned(8);
 
 enum bch_data_event {
        BCH_DATA_EVENT_PROGRESS = 0,
@@ -213,7 +224,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;
@@ -222,48 +233,66 @@ struct bch_ioctl_data_event {
        struct bch_ioctl_data_progress p;
        __u64                   pad2[15];
        };
-} __attribute__((packed, aligned(8)));
+} __packed __aligned(8);
 
-struct bch_ioctl_dev_usage {
-       __u8                    state;
-       __u8                    alive;
-       __u8                    pad[6];
-       __u32                   dev;
+struct bch_replicas_usage {
+       __u64                   sectors;
+       struct bch_replicas_entry r;
+} __packed;
 
-       __u32                   bucket_size;
-       __u64                   nr_buckets;
-
-       __u64                   buckets[BCH_DATA_NR];
-       __u64                   sectors[BCH_DATA_NR];
-};
+static inline struct bch_replicas_usage *
+replicas_usage_next(struct bch_replicas_usage *u)
+{
+       return (void *) u + replicas_entry_bytes(&u->r) + 8;
+}
 
+/*
+ * BCH_IOCTL_FS_USAGE: query filesystem disk space usage
+ *
+ * Returns disk space usage broken out by data type, number of replicas, and
+ * by component device
+ *
+ * @replica_entries_bytes - size, in bytes, allocated for replica usage entries
+ *
+ * On success, @replica_entries_bytes will be changed to indicate the number of
+ * bytes actually used.
+ *
+ * Returns -ERANGE if @replica_entries_bytes was too small
+ */
 struct bch_ioctl_fs_usage {
        __u64                   capacity;
        __u64                   used;
        __u64                   online_reserved;
        __u64                   persistent_reserved[BCH_REPLICAS_MAX];
-       __u64                   sectors[BCH_DATA_NR][BCH_REPLICAS_MAX];
+
+       __u32                   replica_entries_bytes;
+       __u32                   pad;
+
+       struct bch_replicas_usage replicas[0];
 };
 
 /*
- * BCH_IOCTL_USAGE: query filesystem disk space usage
- *
- * Returns disk space usage broken out by data type, number of replicas, and
- * by component device
- *
- * @nr_devices - number of devices userspace allocated space for in @devs
+ * BCH_IOCTL_DEV_USAGE: query device disk space usage
  *
- * On success, @fs and @devs will be filled out appropriately and devs[i].alive
- * will indicate if a device was present in that slot
- *
- * Returns -ERANGE if @nr_devices was too small
+ * Returns disk space usage broken out by data type - both by buckets and
+ * sectors.
  */
-struct bch_ioctl_usage {
-       __u16                   nr_devices;
-       __u16                   pad[3];
+struct bch_ioctl_dev_usage {
+       __u64                   dev;
+       __u32                   flags;
+       __u8                    state;
+       __u8                    pad[7];
+
+       __u32                   bucket_size;
+       __u64                   nr_buckets;
+
+       __u64                   buckets_ec;
 
-       struct bch_ioctl_fs_usage fs;
-       struct bch_ioctl_dev_usage devs[0];
+       struct bch_ioctl_dev_usage_type {
+               __u64           buckets;
+               __u64           sectors;
+               __u64           fragmented;
+       }                       d[BCH_DATA_NR];
 };
 
 /*
@@ -311,4 +340,29 @@ struct bch_ioctl_disk_resize {
        __u64                   nbuckets;
 };
 
+/*
+ * BCH_IOCTL_DISK_RESIZE_JOURNAL: resize journal on a device
+ *
+ * @dev                - member to resize
+ * @nbuckets   - new number of buckets
+ */
+struct bch_ioctl_disk_resize_journal {
+       __u32                   flags;
+       __u32                   pad;
+       __u64                   dev;
+       __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)
+
 #endif /* _BCACHEFS_IOCTL_H */