Skip to content

Commit d399167

Browse files
Qu Wenruomasoncl
authored andcommitted
btrfs: Add datasum mount option.
Add datasum mount option to enable checksum with remount option. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
1 parent a258af7 commit d399167

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Documentation/filesystems/btrfs.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,10 @@ Options with (*) are default options and will not show in the mount options.
159159
Enable/disable data copy-on-write for newly created files.
160160
Nodatacow implies nodatasum, and disables all compression.
161161

162+
datasum(*)
162163
nodatasum
163-
Disable data checksumming for newly created files.
164+
Enable/disable data checksumming for newly created files.
165+
Datasum implies datacow.
164166

165167
notreelog
166168
Disable the tree logging used for fsync and O_SYNC writes.

fs/btrfs/super.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ enum {
325325
Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree,
326326
Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard,
327327
Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow,
328+
Opt_datasum,
328329
Opt_err,
329330
};
330331

@@ -334,6 +335,7 @@ static match_table_t tokens = {
334335
{Opt_subvolid, "subvolid=%s"},
335336
{Opt_device, "device=%s"},
336337
{Opt_nodatasum, "nodatasum"},
338+
{Opt_datasum, "datasum"},
337339
{Opt_nodatacow, "nodatacow"},
338340
{Opt_datacow, "datacow"},
339341
{Opt_nobarrier, "nobarrier"},
@@ -434,6 +436,14 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
434436
btrfs_info(root->fs_info, "setting nodatasum");
435437
btrfs_set_opt(info->mount_opt, NODATASUM);
436438
break;
439+
case Opt_datasum:
440+
if (btrfs_test_opt(root, NODATACOW))
441+
btrfs_info(root->fs_info, "setting datasum, datacow enabled");
442+
else
443+
btrfs_info(root->fs_info, "setting datasum");
444+
btrfs_clear_opt(info->mount_opt, NODATACOW);
445+
btrfs_clear_opt(info->mount_opt, NODATASUM);
446+
break;
437447
case Opt_nodatacow:
438448
if (!btrfs_test_opt(root, COMPRESS) ||
439449
!btrfs_test_opt(root, FORCE_COMPRESS)) {

0 commit comments

Comments
 (0)