Skip to content

btrfs-progs: check that device byte values in superblock match those in chunk root #991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4676c5a
btrfs-progs: mkfs: add --inode-flags option
adam900710 May 21, 2025
e3823c6
btrfs-progs: tests: new test case for mkfs.btrfs --inode-flags
adam900710 May 21, 2025
deb9200
btrfs-progs: zoned: create a data block-group for relocation
morbidrsa May 30, 2025
45a237b
btrfs-progs: print csum values on superblock mismatch
maharmstone May 14, 2025
c534971
btrfs-progs: docs: fix kernel version to set defrag compress level
ozraru Apr 29, 2025
24b64c1
btrfs-progs: convert: add feature dependency checks for bgt
adam900710 May 24, 2025
62fd046
btrfs-progs: convert: replace the bytenrs check with a UASSERT()
adam900710 May 24, 2025
e27f4a5
btrfs-progs: convert: simplify insert_temp_root_item()
adam900710 May 24, 2025
9657aff
btrfs-progs: convert: simplify insert_temp_dev_item() and insert_temp…
adam900710 May 24, 2025
3a8d004
btrfs-progs: convert: simplify insert_temp_dev_extent()
adam900710 May 24, 2025
fb030a7
btrfs-progs: convert: simplify insert_temp_extent_item() and insert_t…
adam900710 May 24, 2025
a26657d
btrfs-progs: convert: merge setup_temp_fs_tree() and setup_temp_csum_…
adam900710 May 24, 2025
15f0b6a
btrfs-progs: convert: implement the block group tree support properly
adam900710 May 24, 2025
9a29f0c
btrfs-progs: tests: tests: add a test case for convert with bgt feature
adam900710 May 24, 2025
932205b
btrfs-progs: docs: add 6.15 kernel development statistics
kdave Mar 20, 2025
96d5e91
btrfs-progs: docs: update 6.15 contribution graphs
kdave Mar 20, 2025
1164c01
btrfs-progs: check that device byte values in superblock match those …
maharmstone May 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/Contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Statistics for 6.x series
"6.12", "20", "111881", "163548", "148", "+1868 -1804"
"6.13", "25", "112756", "164722", "156", "+2780 -1579"
"6.14", "20", "114592", "167178", "147", "+3847 -1391"
"6.15", "25", "114616", "167485", "190", "+2346 -2039"


Legend:
Expand Down
2 changes: 1 addition & 1 deletion Documentation/btrfs-filesystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ defragment [options] <file>|<dir> [<file>|<dir>...]
compression. See also section *EXAMPLES*.

-L|--level <level>
Since kernel 6.14 the compresison can also take the level parameter which will be used
Since kernel 6.15 the compresison can also take the level parameter which will be used
only for the defragmentation and overrides the eventual mount option compression level.
Valid levels depend on the compression algorithms: *zlib*
1..9, *lzo* does not have any levels, *zstd* the standard levels 1..15 and also the
Expand Down
35 changes: 35 additions & 0 deletions Documentation/mkfs.btrfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,41 @@ OPTIONS
:file:`hardlink1` and :file:`hardlink2` because :file:`hardlink3` will
be inside a new subvolume.

--inode-flags <flags>:<path>
Specify that *path* to have inode *flags*, other than the default one (which
implies data COW and data checksum). The option *--rootdir* must also be
specified. This option can be specified multiple times.

The supported flag(s) are:

* *nodatacow*: disable data COW, implies *nodatasum* for regular files.
* *nodatasum*: disable data checksum only.

*flags* can be separated by comma (*,*).

Children inodes will inherit the flags from their parent inodes, like the
following case:

.. code-block:: none

rootdir/
|- file1
|- file2
|- dir/
|- file3

In that case, if *--inode-flags nodatacow:dir* is specified, both
:file:`dir` and :file:`file3` will have the *nodatacow* flag.

And this option also works with *--subvol* option, but the inode flag of
each subvolume is independent and will not inherit from the parent directory.
(The same as the kernel behavior.)

.. note::
Both *--inode-flags* and *--subvol* options are memory hungry,
will consume at least 8KiB for each option. Please keep the
usage of both options to minimum.

--shrink
Shrink the filesystem to its minimal size, only works with *--rootdir* option.

Expand Down
291 changes: 146 additions & 145 deletions Documentation/plot-contribs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
314 changes: 157 additions & 157 deletions Documentation/plot-patches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
564 changes: 283 additions & 281 deletions Documentation/plot-sloc-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions check/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8593,6 +8593,7 @@ static int check_device_used(struct device_record *dev_rec,
if (opt_check_repair) {
ret = repair_dev_item_bytes_used(gfs_info,
dev_rec->devid, total_byte);
dev_rec->byte_used = total_byte;
}
return ret;
} else {
Expand Down Expand Up @@ -8650,6 +8651,30 @@ static bool is_super_size_valid(void)
return true;
}

static int check_super_dev_item(struct device_record *dev_rec)
{
struct btrfs_dev_item *super_di = &gfs_info->super_copy->dev_item;
int ret = 0;

if (btrfs_stack_device_total_bytes(super_di) != dev_rec->total_byte) {
fprintf(stderr,
"device %llu's total_bytes was %llu in tree but %llu in superblock\n",
dev_rec->devid, dev_rec->total_byte,
btrfs_stack_device_total_bytes(super_di));
ret = 1;
}

if (btrfs_stack_device_bytes_used(super_di) != dev_rec->byte_used) {
fprintf(stderr,
"device %llu's bytes_used was %llu in tree but %llu in superblock\n",
dev_rec->devid, dev_rec->byte_used,
btrfs_stack_device_bytes_used(super_di));
ret = 1;
}

return ret;
}

/* check btrfs_dev_item -> btrfs_dev_extent */
static int check_devices(struct rb_root *dev_cache,
struct device_extent_tree *dev_extent_cache)
Expand All @@ -8671,6 +8696,13 @@ static int check_devices(struct rb_root *dev_cache,
gfs_info->sectorsize);
if (dev_rec->bad_block_dev_size && !ret)
ret = 1;

if (dev_rec->devid == gfs_info->super_copy->dev_item.devid) {
err = check_super_dev_item(dev_rec);
if (err)
ret = err;
}

dev_node = rb_next(dev_node);
}
list_for_each_entry(dext_rec, &dev_extent_cache->no_device_orphans,
Expand Down
Loading
Loading