aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-12-17 20:14:01 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:58 -0400
commitbe20aa9dbadc8c06283784ee12bbc0d97dea3418 (patch)
tree52bd8b7e21b36d10dbb48f8b163eea992c9cfd4a /fs/btrfs/super.c
parentb6cda9bcb4df7544c67fc3548a53bc1607d59f46 (diff)
Btrfs: Add mount option to turn off data cow
A number of workloads do not require copy on write data or checksumming. mount -o nodatasum to disable checksums and -o nodatacow to disable both copy on write and checksumming. In nodatacow mode, copy on write is still performed when a given extent is under snapshot. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index ad4f280ec777..2116728d1f98 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -61,12 +61,13 @@ static void btrfs_put_super (struct super_block * sb)
61} 61}
62 62
63enum { 63enum {
64 Opt_subvol, Opt_nodatasum, Opt_err, 64 Opt_subvol, Opt_nodatasum, Opt_nodatacow, Opt_err,
65}; 65};
66 66
67static match_table_t tokens = { 67static match_table_t tokens = {
68 {Opt_subvol, "subvol=%s"}, 68 {Opt_subvol, "subvol=%s"},
69 {Opt_nodatasum, "nodatasum"}, 69 {Opt_nodatasum, "nodatasum"},
70 {Opt_nodatacow, "nodatacow"},
70 {Opt_err, NULL} 71 {Opt_err, NULL}
71}; 72};
72 73
@@ -78,12 +79,20 @@ static int parse_options (char * options,
78 struct btrfs_fs_info *info = NULL; 79 struct btrfs_fs_info *info = NULL;
79 substring_t args[MAX_OPT_ARGS]; 80 substring_t args[MAX_OPT_ARGS];
80 81
81 if (root)
82 info = root->fs_info;
83
84 if (!options) 82 if (!options)
85 return 1; 83 return 1;
86 84
85 /*
86 * strsep changes the string, duplicate it because parse_options
87 * gets called twice
88 */
89 options = kstrdup(options, GFP_NOFS);
90 if (!options)
91 return -ENOMEM;
92
93 if (root)
94 info = root->fs_info;
95
87 while ((p = strsep (&options, ",")) != NULL) { 96 while ((p = strsep (&options, ",")) != NULL) {
88 int token; 97 int token;
89 if (!*p) 98 if (!*p)
@@ -92,17 +101,28 @@ static int parse_options (char * options,
92 token = match_token(p, tokens, args); 101 token = match_token(p, tokens, args);
93 switch (token) { 102 switch (token) {
94 case Opt_subvol: 103 case Opt_subvol:
95 if (subvol_name) 104 if (subvol_name) {
96 *subvol_name = match_strdup(&args[0]); 105 *subvol_name = match_strdup(&args[0]);
106 }
97 break; 107 break;
98 case Opt_nodatasum: 108 case Opt_nodatasum:
99 if (root) 109 if (info) {
110 printk("btrfs: setting nodatacsum\n");
100 btrfs_set_opt(info->mount_opt, NODATASUM); 111 btrfs_set_opt(info->mount_opt, NODATASUM);
112 }
113 break;
114 case Opt_nodatacow:
115 if (info) {
116 printk("btrfs: setting nodatacow\n");
117 btrfs_set_opt(info->mount_opt, NODATACOW);
118 btrfs_set_opt(info->mount_opt, NODATASUM);
119 }
101 break; 120 break;
102 default: 121 default:
103 return 0; 122 break;
104 } 123 }
105 } 124 }
125 kfree(options);
106 return 1; 126 return 1;
107} 127}
108 128