History

Btrfs: catch invalid free space trees

There are two separate issues that can lead to corrupted free space trees. 1. The free space tree bitmaps had an endianness issue on big-endian systems which is fixed by an earlier patch in this series. 2. btrfs-progs before v4.7.3 modified filesystems without updating the free space tree. To catch both of these issues at once, we need to force the free space tree to be rebuilt. To do so, add a FREE_SPACE_TREE_VALID compat_ro bit. If the bit isn't set, we know that it was either produced by a broken big-endian kernel or may have been corrupted by btrfs-progs. This also provides us with a way to add rudimentary read-write support for the free space tree to btrfs-progs: it can just clear this bit and have the kernel rebuild the free space tree.

Omar Sandoval committed 10 years ago

Commit 6675df31 parent f8d468a4 files · +24 −2Browse files

Showing the changes to include/uapi/linux (1 of 4 files). Show all

Unified · Split

include/uapi/linux/btrfs.h+11−1
@@ -239,7 +239,17 @@ struct btrfs_ioctl_fs_info_args { · 238 unmodified lines
239 * Used by:239 * Used by:
240 * struct btrfs_ioctl_feature_flags240 * struct btrfs_ioctl_feature_flags
241 */241 */
242#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)242#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
243/*
244 * Older kernels (< 4.9) on big-endian systems produced broken free space tree
245 * bitmaps, and btrfs-progs also used to corrupt the free space tree (versions
246 * < 4.7.3). If this bit is clear, then the free space tree cannot be trusted.
247 * btrfs-progs can also intentionally clear this bit to ask the kernel to
248 * rebuild the free space tree, however this might not work on older kernels
249 * that do not know about this bit. If not sure, clear the cache manually on
250 * first mount when booting older kernel versions.
251 */
252#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1)
243 253
244#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)254#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
245#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)255#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t