Skip to content

btrfs-progs: new --inode-flags option #987

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 11 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions Documentation/btrfs-rescue.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@ fix-device-size <device>

WARNING: CPU: 3 PID: 439 at fs/btrfs/ctree.h:1559 btrfs_update_device+0x1c5/0x1d0 [btrfs]

fix-data-checksum <device>
fix data checksum mismatch

There is a long existing problem that if a user space program is doing
direct IO and modifies the buffer before the write back finished, it
can lead to data checksum mismatches.

This problem is known but not fixed until upstream release v6.15
(backported to older kernels). So it's possible to hit false data
checksum mismatch for any long running btrfs.

In that case this program can be utilized to repair such problem.

``Options``

-r|--readonly
readonly mode, only scan and report for data checksum mismatch,
do no repair

-i|--interactive
interactive mode, ask for how to repair, ignore the error by default

-m|--mirror <num>
use specified mirror to update the checksum item for all corrupted blocks.

The value must be >= 1, and if the corrupted block has less mirrors than
the value, the mirror number will be `num % (num_mirrors + 1)`.

.. _man-rescue-clear-ino-cache:

clear-ino-cache <device>
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 minimal.

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

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ cmds_objects = cmds/subvolume.o cmds/subvolume-list.o \
cmds/inspect.o cmds/balance.o cmds/send.o cmds/receive.o \
cmds/quota.o cmds/qgroup.o cmds/replace.o check/main.o \
cmds/restore.o cmds/rescue.o cmds/rescue-chunk-recover.o \
cmds/rescue-super-recover.o \
cmds/rescue-super-recover.o cmds/rescue-fix-data-checksum.o \
cmds/property.o cmds/filesystem-usage.o cmds/inspect-dump-tree.o \
cmds/inspect-dump-super.o cmds/inspect-tree-stats.o cmds/filesystem-du.o \
cmds/reflink.o \
Expand Down
9 changes: 4 additions & 5 deletions cmds/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,11 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
ret = ioctl(fdmnt, BTRFS_IOC_DEV_REPLACE, &start_args);
if (do_not_background) {
if (ret < 0) {
error("ioctl(DEV_REPLACE_START) failed on \"%s\": %m", path);
if (start_args.result != BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT)
pr_stderr(LOG_DEFAULT, ", %s\n",
replace_dev_result2string(start_args.result));
if (start_args.result == BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT)
error("ioctl(DEV_REPLACE_START) failed on \"%s\": %m", path);
else
pr_stderr(LOG_DEFAULT, "\n");
error("ioctl(DEV_REPLACE_START) failed on \"%s\": %m, %s",
path, replace_dev_result2string(start_args.result));

if (errno == EOPNOTSUPP)
warning("device replace of RAID5/6 not supported with this kernel");
Expand Down
Loading