Skip to content

Commit ac1938f

Browse files
committed
btrfs-progs: docs: update ioctls
Add DEV_INFO, feature bit ioctls. [ci skip] Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 6a449a4 commit ac1938f

File tree

1 file changed

+166
-12
lines changed

1 file changed

+166
-12
lines changed

Documentation/btrfs-ioctl.rst

Lines changed: 166 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ LIST OF IOCTLS
150150
* - BTRFS_IOC_SCRUB_PROGRESS
151151
-
152152
-
153-
* - BTRFS_IOC_DEV_INFO
154-
-
155-
-
153+
* - :ref:`BTRFS_IOC_DEV_INFO<BTRFS_IOC_DEV_INFO>`
154+
- get information about a device (UUIDs, used size, total size)
155+
- :ref:`struct btrfs_ioctl_dev_info_args<struct_btrfs_ioctl_dev_info_args>`
156156
* - :ref:`BTRFS_IOC_FS_INFO<BTRFS_IOC_FS_INFO>`
157157
- get information about filesystem (device count, fsid, ...)
158158
- :ref:`struct btrfs_ioctl_fs_info_args<struct_btrfs_ioctl_fs_info_args>`
@@ -216,15 +216,15 @@ LIST OF IOCTLS
216216
* - BTRFS_IOC_FILE_EXTENT_SAME
217217
-
218218
-
219-
* - BTRFS_IOC_GET_FEATURES
220-
-
221-
-
222-
* - BTRFS_IOC_SET_FEATURES
223-
-
224-
-
225-
* - BTRFS_IOC_GET_SUPPORTED_FEATURES
226-
-
227-
-
219+
* - :ref:`BTRFS_IOC_GET_FEATURES<BTRFS_IOC_GET_FEATURES>`
220+
- get features set on the filesystem
221+
- :ref:`struct btrfs_ioctl_feature_flags<struct_btrfs_ioctl_feature_flags>`
222+
* - :ref:`BTRFS_IOC_SET_FEATURES<BTRFS_IOC_SET_FEATURES>`
223+
- set features on the filesystem
224+
- :ref:`struct btrfs_ioctl_feature_flags<struct_btrfs_ioctl_feature_flags>`
225+
* - :ref:`BTRFS_IOC_GET_SUPPORTED_FEATURES<BTRFS_IOC_GET_SUPPORTED_FEATURES>`
226+
- get available filesystem feature sets
227+
- :ref:`struct btrfs_ioctl_feature_flags[3]<struct_btrfs_ioctl_feature_flags>`
228228
* - BTRFS_IOC_RM_DEV_V2
229229
-
230230
-
@@ -292,6 +292,48 @@ DATA STRUCTURES AND DEFINITIONS
292292
};
293293
};
294294
295+
296+
.. _struct_btrfs_ioctl_feature_flags:
297+
298+
.. code-block:: c
299+
300+
#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
301+
/*
302+
* Older kernels (< 4.9) on big-endian systems produced broken free space tree
303+
* bitmaps, and btrfs-progs also used to corrupt the free space tree (versions
304+
* < 4.7.3). If this bit is clear, then the free space tree cannot be trusted.
305+
* btrfs-progs can also intentionally clear this bit to ask the kernel to
306+
* rebuild the free space tree, however this might not work on older kernels
307+
* that do not know about this bit. If not sure, clear the cache manually on
308+
* first mount when booting older kernel versions.
309+
*/
310+
#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1)
311+
#define BTRFS_FEATURE_COMPAT_RO_VERITY (1ULL << 2)
312+
#define BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE (1ULL << 3)
313+
314+
#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
315+
#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
316+
#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
317+
#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
318+
#define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD (1ULL << 4)
319+
#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
320+
#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
321+
#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
322+
#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8)
323+
#define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)
324+
#define BTRFS_FEATURE_INCOMPAT_METADATA_UUID (1ULL << 10)
325+
#define BTRFS_FEATURE_INCOMPAT_RAID1C34 (1ULL << 11)
326+
#define BTRFS_FEATURE_INCOMPAT_ZONED (1ULL << 12)
327+
#define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 (1ULL << 13)
328+
#define BTRFS_FEATURE_INCOMPAT_RAID_STRIPE_TREE (1ULL << 14)
329+
#define BTRFS_FEATURE_INCOMPAT_SIMPLE_QUOTA (1ULL << 16)
330+
331+
struct btrfs_ioctl_feature_flags {
332+
__u64 compat_flags;
333+
__u64 compat_ro_flags;
334+
__u64 incompat_flags;
335+
};
336+
295337
.. _struct_btrfs_ioctl_get_subvol_info_args:
296338

297339
.. code-block:: c
@@ -385,6 +427,29 @@ DATA STRUCTURES AND DEFINITIONS
385427
__u64 rsv_excl;
386428
};
387429
430+
.. _struct_btrfs_ioctl_dev_info_args:
431+
432+
.. code-block:: c
433+
434+
struct btrfs_ioctl_dev_info_args {
435+
__u64 devid; /* in/out */
436+
__u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
437+
__u64 bytes_used; /* out */
438+
__u64 total_bytes; /* out */
439+
/*
440+
* Optional, out.
441+
*
442+
* Showing the fsid of the device, allowing user space to check if this
443+
* device is a seeding one.
444+
*
445+
* Introduced in v6.3, thus user space still needs to check if kernel
446+
* changed this value. Older kernel will not touch the values here.
447+
*/
448+
__u8 fsid[BTRFS_UUID_SIZE];
449+
__u64 unused[377]; /* pad to 4k */
450+
__u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
451+
};
452+
388453
.. _struct_btrfs_ioctl_fs_info_args:
389454

390455
.. code-block:: c
@@ -850,6 +915,23 @@ Required permissions: CAP_SYS_ADMIN
850915
* - ioctl args
851916
- char buffer[:ref:`BTRFS_LABEL_SIZE<constants-table>`]
852917

918+
.. _BTRFS_IOC_DEV_INFO:
919+
920+
BTRFS_IOC_DEV_INFO
921+
~~~~~~~~~~~~~~~~~~
922+
923+
Read some basic information about a device, requested by the *devid* or *device UUID*.
924+
925+
.. list-table::
926+
:header-rows: 1
927+
928+
* - Field
929+
- Description
930+
* - ioctl fd
931+
- file descriptor of any file/directory in the filesystem
932+
* - ioctl args
933+
- :ref:`struct btrfs_ioctl_dev_info_args<struct_btrfs_ioctl_dev_info_args>`
934+
853935
.. _BTRFS_IOC_FS_INFO:
854936

855937
BTRFS_IOC_FS_INFO
@@ -870,6 +952,78 @@ depending on the flags set.
870952
* - ioctl args
871953
- :ref:`struct btrfs_ioctl_fs_info_args<struct_btrfs_ioctl_fs_info_args>`
872954

955+
.. _BTRFS_IOC_GET_FEATURES:
956+
957+
BTRFS_IOC_GET_FEATURES
958+
~~~~~~~~~~~~~~~~~~~~~~
959+
960+
Get the actually set feature bits on the filesystem (the bits are stored in the
961+
super block). There are three sets related to backward compatibility:
962+
963+
- incompat: not backward compatible, mount on older kernel will fail.
964+
- compat_ro: backward compatible for read-only mount.
965+
- compat: backward compatible with read-write support, only marked as as individual feature.
966+
967+
.. list-table::
968+
:header-rows: 1
969+
970+
* - Field
971+
- Description
972+
* - ioctl fd
973+
- file descriptor of the subvolume to examine
974+
* - ioctl args
975+
- :ref:`struct btrfs_ioctl_feature_flags<struct_btrfs_ioctl_feature_flags>`
976+
977+
If a bit is set then there may be some data structures on the filesystem of the
978+
related feature, but not necessarily.
979+
980+
Some of the features are turned on automatically when used,
981+
e.g. compression or when a balance filter converts to yet unused block group
982+
profile. In some cases the feature can be turned on or off by :doc:`btrfstune`.
983+
984+
.. _BTRFS_IOC_SET_FEATURES:
985+
986+
BTRFS_IOC_SET_FEATURES
987+
~~~~~~~~~~~~~~~~~~~~~~
988+
989+
Set a feature bit on the filesystem if possible. Some features may require
990+
extensive changes, new data structures or conversion (like free-space-tree).
991+
Bits representing possible existence of data structures related to the feature
992+
can be set without actually creating anything, e.g. ZSTD compressed extents.
993+
994+
.. list-table::
995+
:header-rows: 1
996+
997+
* - Field
998+
- Description
999+
* - ioctl fd
1000+
- file descriptor of the subvolume to examine
1001+
* - ioctl args
1002+
- :ref:`struct btrfs_ioctl_feature_flags<struct_btrfs_ioctl_feature_flags>`
1003+
1004+
.. _BTRFS_IOC_GET_SUPPORTED_FEATURES:
1005+
1006+
BTRFS_IOC_GET_SUPPORTED_FEATURES
1007+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1008+
1009+
Get feature sets supported by the kernel module, in three groups:
1010+
1011+
- supported: (index 0) all supported compat/compat_ro/incompat features
1012+
- safe to set: (index 1) features that can be enabled on a mounted filesystem
1013+
- safe to clear: (index 2) features that can be disabled on a mounted filesystem
1014+
1015+
The features are also listed in :file:`/sys/fs/btrfs/features`.
1016+
1017+
.. list-table::
1018+
:header-rows: 1
1019+
1020+
* - Field
1021+
- Description
1022+
* - ioctl fd
1023+
- file descriptor of the subvolume to examine
1024+
* - ioctl args
1025+
- :ref:`struct btrfs_ioctl_feature_flags[3]<struct_btrfs_ioctl_feature_flags>`
1026+
8731027
.. _BTRFS_IOC_GET_SUBVOL_INFO:
8741028

8751029
BTRFS_IOC_GET_SUBVOL_INFO

0 commit comments

Comments
 (0)