* [PATCH 1/5] btrfs: nodatasum drop compress
@ 2014-09-18 8:25 Satoru Takeuchi
2014-09-18 8:28 ` [PATCH 2/5] btrfs: correct a message on setting nodatacow Satoru Takeuchi
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Satoru Takeuchi @ 2014-09-18 8:25 UTC (permalink / raw)
To: linux-btrfs@vger.kernel.org
From: Naohiro Aota <naota@elisp.net>
We can enable both compress option and nodatasum option at the same time
with the following command.
===
$ sudo mount -o remount,compress,nodatasum /
$ mount | grep btrfs
/dev/vda2 on / type btrfs (rw,relatime,seclabel,nodatasum,compress=zlib,space_cache)
===
This behavior collides with Documentation/filesystems/btrfs.txt:
===
...
If compression is enabled, nodatacow and nodatasum are disabled.
...
===
This patch drops the compress flags upon nodatasum flag.
Signed-off-by: Naohiro Aota <naota@elisp.net>
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
fs/btrfs/super.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c4124de..d1c5b6d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -440,8 +440,15 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
*/
break;
case Opt_nodatasum:
- btrfs_set_and_info(root, NODATASUM,
- "setting nodatasum");
+ if (!btrfs_test_opt(root, NODATASUM)) {
+ if (btrfs_test_opt(root, COMPRESS))
+ btrfs_info(root->fs_info, "setting nodatasum, compression disabled");
+ else
+ btrfs_info(root->fs_info, "setting nodatasum");
+ }
+ btrfs_clear_opt(info->mount_opt, COMPRESS);
+ btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
+ btrfs_set_opt(info->mount_opt, NODATASUM);
break;
case Opt_datasum:
if (btrfs_test_opt(root, NODATASUM)) {
-- 1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/5] btrfs: correct a message on setting nodatacow 2014-09-18 8:25 [PATCH 1/5] btrfs: nodatasum drop compress Satoru Takeuchi @ 2014-09-18 8:28 ` Satoru Takeuchi 2014-09-19 2:03 ` Qu Wenruo 2014-09-18 8:30 ` [PATCH 3/5] btrfs: notice nodatasum is also enabled with nodatacow Satoru Takeuchi ` (2 subsequent siblings) 3 siblings, 1 reply; 8+ messages in thread From: Satoru Takeuchi @ 2014-09-18 8:28 UTC (permalink / raw) To: linux-btrfs@vger.kernel.org From: Naohiro Aota <naota@elisp.net> If we set nodatacow mount option after compress-force option, we don't get compression disabling message. === $ sudo mount -o remount,compress-force,nodatacow /; dmesg|tail -n 3 [ 3845.719047] BTRFS info (device vda2): force zlib compression [ 3845.719052] BTRFS info (device vda2): setting nodatacow [ 3845.719055] BTRFS info (device vda2): disk space caching is enabled === Signed-off-by: Naohiro Aota <naota@elisp.net> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> --- fs/btrfs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d1c5b6d..d131098 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -462,8 +462,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) break; case Opt_nodatacow: if (!btrfs_test_opt(root, NODATACOW)) { - if (!btrfs_test_opt(root, COMPRESS) || - !btrfs_test_opt(root, FORCE_COMPRESS)) { + if (btrfs_test_opt(root, COMPRESS)) { btrfs_info(root->fs_info, "setting nodatacow, compression disabled"); } else { -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/5] btrfs: correct a message on setting nodatacow 2014-09-18 8:28 ` [PATCH 2/5] btrfs: correct a message on setting nodatacow Satoru Takeuchi @ 2014-09-19 2:03 ` Qu Wenruo 2014-09-19 6:45 ` Satoru Takeuchi 0 siblings, 1 reply; 8+ messages in thread From: Qu Wenruo @ 2014-09-19 2:03 UTC (permalink / raw) To: Satoru Takeuchi, linux-btrfs@vger.kernel.org -------- Original Message -------- Subject: [PATCH 2/5] btrfs: correct a message on setting nodatacow From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> To: linux-btrfs@vger.kernel.org <linux-btrfs@vger.kernel.org> Date: 2014年09月18日 16:28 > From: Naohiro Aota <naota@elisp.net> > > If we set nodatacow mount option after compress-force option, > we don't get compression disabling message. > > === > $ sudo mount -o remount,compress-force,nodatacow /; dmesg|tail -n 3 > [ 3845.719047] BTRFS info (device vda2): force zlib compression > [ 3845.719052] BTRFS info (device vda2): setting nodatacow > [ 3845.719055] BTRFS info (device vda2): disk space caching is enabled > === > > Signed-off-by: Naohiro Aota <naota@elisp.net> > Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> > --- > fs/btrfs/super.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c > index d1c5b6d..d131098 100644 > --- a/fs/btrfs/super.c > +++ b/fs/btrfs/super.c > @@ -462,8 +462,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) > break; > case Opt_nodatacow: > if (!btrfs_test_opt(root, NODATACOW)) { > - if (!btrfs_test_opt(root, COMPRESS) || > - !btrfs_test_opt(root, FORCE_COMPRESS)) { > + if (btrfs_test_opt(root, COMPRESS)) { > btrfs_info(root->fs_info, > "setting nodatacow, compression disabled"); > } else { > -- 1.8.3.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Although the patch makes the output ok, the core problem is missing conflict options check. compress-force mount options implies datacow and datasum, but following nodatasum will disable datasum and compress, in fact they are conflicting mount option... Even the current behavior(later mount option will override previous ones) provides great tolerance, IMO there should better be some conflicting check for mount options. For example, we first save all the mount options passed in into a temporary bitmaps to finds out the conflicting and only when they contains no conflicts, set the mount options to fs_info. (Maybe bitmap is not enough for this case, since we can't distinguish default value and value to be set?) What do you think about this idea ? Thanks, Qu ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/5] btrfs: correct a message on setting nodatacow 2014-09-19 2:03 ` Qu Wenruo @ 2014-09-19 6:45 ` Satoru Takeuchi 2014-09-19 7:01 ` Qu Wenruo 0 siblings, 1 reply; 8+ messages in thread From: Satoru Takeuchi @ 2014-09-19 6:45 UTC (permalink / raw) To: Qu Wenruo, linux-btrfs@vger.kernel.org Hi Qu, Thank you for your comment. (2014/09/19 11:03), Qu Wenruo wrote: > > -------- Original Message -------- > Subject: [PATCH 2/5] btrfs: correct a message on setting nodatacow > From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> > To: linux-btrfs@vger.kernel.org <linux-btrfs@vger.kernel.org> > Date: 2014年09月18日 16:28 >> From: Naohiro Aota <naota@elisp.net> >> >> If we set nodatacow mount option after compress-force option, >> we don't get compression disabling message. >> >> === >> $ sudo mount -o remount,compress-force,nodatacow /; dmesg|tail -n 3 >> [ 3845.719047] BTRFS info (device vda2): force zlib compression >> [ 3845.719052] BTRFS info (device vda2): setting nodatacow >> [ 3845.719055] BTRFS info (device vda2): disk space caching is enabled >> === >> >> Signed-off-by: Naohiro Aota <naota@elisp.net> >> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> >> --- >> fs/btrfs/super.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c >> index d1c5b6d..d131098 100644 >> --- a/fs/btrfs/super.c >> +++ b/fs/btrfs/super.c >> @@ -462,8 +462,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) >> break; >> case Opt_nodatacow: >> if (!btrfs_test_opt(root, NODATACOW)) { >> - if (!btrfs_test_opt(root, COMPRESS) || >> - !btrfs_test_opt(root, FORCE_COMPRESS)) { >> + if (btrfs_test_opt(root, COMPRESS)) { >> btrfs_info(root->fs_info, >> "setting nodatacow, compression disabled"); >> } else { >> -- 1.8.3.1 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > Although the patch makes the output ok, the core problem is missing conflict options check. > > compress-force mount options implies datacow and datasum, but following nodatasum will disable datasum and compress, in fact they are conflicting mount option... > > Even the current behavior(later mount option will override previous ones) provides great tolerance, > IMO there should better be some conflicting check for mount options. > > For example, we first save all the mount options passed in into a temporary bitmaps to finds out the conflicting > and only when they contains no conflicts, set the mount options to fs_info. > (Maybe bitmap is not enough for this case, since we can't distinguish default value and value to be set?) > > What do you think about this idea ? I'm against your idea for two reasons and it's better to stay in current behavior though it's a bit complex. First, the rule "last one wins" is not only a conventional rule, but also is what mount(8) says. https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/sys-utils/mount.8#n253 ====== The usual behavior is that the last option wins if there are conflicting ones. ====== Second, if we change the behavior, we would break existing systems. At worst case, users would fail to boot their system after updating kernel, because of the failure of mounting Btrfs at the init process. Thanks, Satoru > > Thanks, > Qu > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/5] btrfs: correct a message on setting nodatacow 2014-09-19 6:45 ` Satoru Takeuchi @ 2014-09-19 7:01 ` Qu Wenruo 0 siblings, 0 replies; 8+ messages in thread From: Qu Wenruo @ 2014-09-19 7:01 UTC (permalink / raw) To: Satoru Takeuchi, linux-btrfs@vger.kernel.org -------- Original Message -------- Subject: Re: [PATCH 2/5] btrfs: correct a message on setting nodatacow From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> To: Qu Wenruo <quwenruo@cn.fujitsu.com>, linux-btrfs@vger.kernel.org <linux-btrfs@vger.kernel.org> Date: 2014年09月19日 14:45 > Hi Qu, > > Thank you for your comment. > > (2014/09/19 11:03), Qu Wenruo wrote: >> >> -------- Original Message -------- >> Subject: [PATCH 2/5] btrfs: correct a message on setting nodatacow >> From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> >> To: linux-btrfs@vger.kernel.org <linux-btrfs@vger.kernel.org> >> Date: 2014年09月18日 16:28 >>> From: Naohiro Aota <naota@elisp.net> >>> >>> If we set nodatacow mount option after compress-force option, >>> we don't get compression disabling message. >>> >>> === >>> $ sudo mount -o remount,compress-force,nodatacow /; dmesg|tail -n 3 >>> [ 3845.719047] BTRFS info (device vda2): force zlib compression >>> [ 3845.719052] BTRFS info (device vda2): setting nodatacow >>> [ 3845.719055] BTRFS info (device vda2): disk space caching is enabled >>> === >>> >>> Signed-off-by: Naohiro Aota <naota@elisp.net> >>> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> >>> --- >>> fs/btrfs/super.c | 3 +-- >>> 1 file changed, 1 insertion(+), 2 deletions(-) >>> >>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c >>> index d1c5b6d..d131098 100644 >>> --- a/fs/btrfs/super.c >>> +++ b/fs/btrfs/super.c >>> @@ -462,8 +462,7 @@ int btrfs_parse_options(struct btrfs_root *root, >>> char *options) >>> break; >>> case Opt_nodatacow: >>> if (!btrfs_test_opt(root, NODATACOW)) { >>> - if (!btrfs_test_opt(root, COMPRESS) || >>> - !btrfs_test_opt(root, FORCE_COMPRESS)) { >>> + if (btrfs_test_opt(root, COMPRESS)) { >>> btrfs_info(root->fs_info, >>> "setting nodatacow, compression >>> disabled"); >>> } else { >>> -- 1.8.3.1 >>> >>> -- >>> To unsubscribe from this list: send the line "unsubscribe >>> linux-btrfs" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Although the patch makes the output ok, the core problem is missing >> conflict options check. >> >> compress-force mount options implies datacow and datasum, but >> following nodatasum will disable datasum and compress, in fact they >> are conflicting mount option... >> >> Even the current behavior(later mount option will override previous >> ones) provides great tolerance, >> IMO there should better be some conflicting check for mount options. >> >> For example, we first save all the mount options passed in into a >> temporary bitmaps to finds out the conflicting >> and only when they contains no conflicts, set the mount options to >> fs_info. >> (Maybe bitmap is not enough for this case, since we can't distinguish >> default value and value to be set?) >> >> What do you think about this idea ? > > I'm against your idea for two reasons and it's better to > stay in current behavior though it's a bit complex. > > First, the rule "last one wins" is not only a conventional rule, > but also is what mount(8) says. > > https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/sys-utils/mount.8#n253 > > > ====== > The usual behavior is that the last option wins if there are conflicting > ones. > ====== > > Second, if we change the behavior, we would break existing > systems. At worst case, users would fail to boot their system > after updating kernel, because of the failure of mounting > Btrfs at the init process. > > Thanks, > Satoru > It really makes sense. So I'm OK to keep things and it's true that the conflict check is somewhat overkilled. Thanks, Qu >> >> Thanks, >> Qu >> -- >> To unsubscribe from this list: send the line "unsubscribe >> linux-btrfs" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/5] btrfs: notice nodatasum is also enabled with nodatacow 2014-09-18 8:25 [PATCH 1/5] btrfs: nodatasum drop compress Satoru Takeuchi 2014-09-18 8:28 ` [PATCH 2/5] btrfs: correct a message on setting nodatacow Satoru Takeuchi @ 2014-09-18 8:30 ` Satoru Takeuchi 2014-09-18 8:32 ` [PATCH 4/5] btrfs: suppress a verbose message about enabling space cache on remounting Satoru Takeuchi 2014-09-18 8:43 ` [PATCH 5/5] btrfs: rework compression related options processing Satoru Takeuchi 3 siblings, 0 replies; 8+ messages in thread From: Satoru Takeuchi @ 2014-09-18 8:30 UTC (permalink / raw) To: linux-btrfs@vger.kernel.org From: Naohiro Aota <naota@elisp.net> Documentation/filesystems/btrfs.txt states the following: === ... Nodatacow implies nodatasum, and disables all compression. ... === However the current message only mentions nodatacow. It's better to also mention nodatasum. Signed-off-by: Naohiro Aota <naota@elisp.net> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> --- fs/btrfs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d131098..7ad4293 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -464,9 +464,9 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) if (!btrfs_test_opt(root, NODATACOW)) { if (btrfs_test_opt(root, COMPRESS)) { btrfs_info(root->fs_info, - "setting nodatacow, compression disabled"); + "setting nodatacow and nodatasum, compression disabled"); } else { - btrfs_info(root->fs_info, "setting nodatacow"); + btrfs_info(root->fs_info, "setting nodatacow and nodatasum"); } } btrfs_clear_opt(info->mount_opt, COMPRESS); -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] btrfs: suppress a verbose message about enabling space cache on remounting 2014-09-18 8:25 [PATCH 1/5] btrfs: nodatasum drop compress Satoru Takeuchi 2014-09-18 8:28 ` [PATCH 2/5] btrfs: correct a message on setting nodatacow Satoru Takeuchi 2014-09-18 8:30 ` [PATCH 3/5] btrfs: notice nodatasum is also enabled with nodatacow Satoru Takeuchi @ 2014-09-18 8:32 ` Satoru Takeuchi 2014-09-18 8:43 ` [PATCH 5/5] btrfs: rework compression related options processing Satoru Takeuchi 3 siblings, 0 replies; 8+ messages in thread From: Satoru Takeuchi @ 2014-09-18 8:32 UTC (permalink / raw) To: linux-btrfs@vger.kernel.org From: Naohiro Aota <naota@elisp.net> Remount operation always tells you it enabled space cache. I consider it's a bit verbose and is better not to show this message on remounting. Signed-off-by: Naohiro Aota <naota@elisp.net> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> --- fs/btrfs/super.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 7ad4293..03131c5 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -404,7 +404,8 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); if (cache_gen) - btrfs_set_opt(info->mount_opt, SPACE_CACHE); + btrfs_set_and_info(root, SPACE_CACHE, + "disk space caching is enabled"); if (!options) goto out; @@ -758,8 +759,6 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) } } out: - if (!ret && btrfs_test_opt(root, SPACE_CACHE)) - btrfs_info(root->fs_info, "disk space caching is enabled"); kfree(orig); return ret; } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] btrfs: rework compression related options processing 2014-09-18 8:25 [PATCH 1/5] btrfs: nodatasum drop compress Satoru Takeuchi ` (2 preceding siblings ...) 2014-09-18 8:32 ` [PATCH 4/5] btrfs: suppress a verbose message about enabling space cache on remounting Satoru Takeuchi @ 2014-09-18 8:43 ` Satoru Takeuchi 3 siblings, 0 replies; 8+ messages in thread From: Satoru Takeuchi @ 2014-09-18 8:43 UTC (permalink / raw) To: linux-btrfs@vger.kernel.org From: Naohiro Aota <naota@elisp.net> There are mutual exclusive mount options corresponding to compression options. If we set these options at once, we get improper messages and states, and a verbose message. * Improper states - We can't disable "compress forcing" with compress={zlib,lzo} mount option. ==== # mount -o remount,compress-force=zlib,compress=lzo [58852.210209] BTRFS info (device vda2): force zlib compression (We should see "use lzo compression" here) # mount | grep btrfs /dev/vda2 on / type btrfs (rw,relatime,seclabel,compress-force=lzo,space_cache) (We should also change "compress-force=lzo" to "compress=lzo") ==== * Improper messages - We don't see compression enabled message when we enables it after disabling it. ==== # mount -o remount,compress=no,compress=zlib; dmesg -c [ 4077.130625] BTRFS info (device vda2): btrfs: use no compression (We should see "use zlib compression" here) ==== - We don't see any message when we change compression type. ==== # mount -o remount,compress=zlib,compress=lzo (Since "BTRFS info" is at the beginning of this message, "btrfs: " is verbose and we don't need it.) ==== - We don't see datacow and/or datasum enabling message when we enable compression. ==== # mount -o remount,nodatacow,nodatasum,compress [58913.704536] BTRFS info (device vda2): setting nodatacow (We should see "use zlib compression, setting datacow and datasum" here) ==== ==== # mount -o remount,nodatasum,compress [58950.529392] BTRFS info (device vda2): setting nodatasum (We should see "use zlib compression, setting datasum" here) ==== * A verbose message - We see verbose "btrfs: " prefix on disabling compression. ==== # mount -o remount,compress=zlib,compress=no [58790.727788] BTRFS info (device vda2): btrfs: use no compression ("btrfs: " is verbose here. We don't need it, since we already state this is btrfs with "BTRFS info") ==== This commit solves all these problems. I separated the code in the following two parts: a) Parse the options. b) Set and clear flags of mount_opt and show proper messages. I've confirmed that this patch doesn't cause any regression by running the following script, which tests all combinations of corresponding mount options (compress, compress-force, datacow, and datasum). ===================== #!/bin/bash BTRFS_ROOT=/ states=( compress=zlib,datacow,datasum compress=lzo,datacow,datasum compress-force=zlib,datacow,datasum compress-force=lzo,datacow,datasum compress=no,nodatacow,nodatasum compress=no,datacow,nodatasum compress=no,datacow,datasum ) options=( compress compress=zlib compress=lzo compress=no compress=badopt compress-force compress-force=zlib compress-force=lzo compress-force=no compress-force=badopt nodatacow datacow nodatasum datasum ) for s in ${states[@]}; do for o in ${options[@]}; do # set initial state echo initial: mount -o remount,$s mount -o remount,$s ${BTRFS_ROOT} # mount with each option echo mount -o remount,$o dmesg -C mount -o remount,$o ${BTRFS_ROOT} echo dmesg: dmesg -t | perl -ne 'if(/^BTRFS info \(device .+?\): (.+)$/){print "\t$1\n"}' echo -n 'mount options: ' grep -v rootfs /proc/mounts | \ awk "{if(\$2==\"${BTRFS_ROOT}\"){print \$4}}" | \ perl -ne '@a=split(/,/); for(@a){print "$_ " if(/^compress(-force)?=|nodata(cow|sum)$/)}' echo echo done done ===================== Signed-off-by: Naohiro Aota <naota@elisp.net> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> --- fs/btrfs/super.c | 57 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 03131c5..83433e15 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -401,6 +401,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) char *compress_type; bool compress_force = false; bool compress = false; + unsigned long old_compress_type; cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); if (cache_gen) @@ -486,40 +487,62 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) case Opt_compress: case Opt_compress_type: compress = true; + old_compress_type = info->compress_type; if (token == Opt_compress || token == Opt_compress_force || strcmp(args[0].from, "zlib") == 0) { compress_type = "zlib"; info->compress_type = BTRFS_COMPRESS_ZLIB; - btrfs_set_opt(info->mount_opt, COMPRESS); - btrfs_clear_opt(info->mount_opt, NODATACOW); - btrfs_clear_opt(info->mount_opt, NODATASUM); } else if (strcmp(args[0].from, "lzo") == 0) { compress_type = "lzo"; info->compress_type = BTRFS_COMPRESS_LZO; - btrfs_set_opt(info->mount_opt, COMPRESS); - btrfs_clear_opt(info->mount_opt, NODATACOW); - btrfs_clear_opt(info->mount_opt, NODATASUM); btrfs_set_fs_incompat(info, COMPRESS_LZO); } else if (strncmp(args[0].from, "no", 2) == 0) { compress_type = "no"; - btrfs_clear_opt(info->mount_opt, COMPRESS); - btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); - compress_force = false; + compress = compress_force = false; } else { ret = -EINVAL; goto out; } - if (compress_force) { - btrfs_set_and_info(root, FORCE_COMPRESS, - "force %s compression", - compress_type); - } else if (compress) { - if (!btrfs_test_opt(root, COMPRESS)) + if (compress_force || compress) { + const char *method = "", *setting = ""; + + if ((info->compress_type != old_compress_type) || + (compress_force && + !btrfs_test_opt(root, FORCE_COMPRESS)) || + (!compress_force && + btrfs_test_opt(root, FORCE_COMPRESS)) || + (compress && !btrfs_test_opt(root, COMPRESS))) { + method = compress_force?"force":"use"; + } + + if (btrfs_test_opt(root, NODATACOW)) + setting = ", setting datacow and datasum"; + else if (btrfs_test_opt(root, NODATASUM)) + setting = ", setting datasum"; + + if (strcmp(method, "") != 0) { btrfs_info(root->fs_info, - "btrfs: use %s compression", - compress_type); + "%s %s compression%s", + method, compress_type, + setting); + } + if (compress_force) { + btrfs_set_opt(info->mount_opt, + FORCE_COMPRESS); + } else { + btrfs_clear_opt(info->mount_opt, + FORCE_COMPRESS); + } + btrfs_set_opt(info->mount_opt, COMPRESS); + btrfs_clear_opt(info->mount_opt, NODATACOW); + btrfs_clear_opt(info->mount_opt, NODATASUM); + } else { + btrfs_clear_and_info(root, COMPRESS, + "use no compression"); + btrfs_clear_opt(info->mount_opt, + FORCE_COMPRESS); } break; case Opt_ssd: -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-09-19 7:01 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-18 8:25 [PATCH 1/5] btrfs: nodatasum drop compress Satoru Takeuchi 2014-09-18 8:28 ` [PATCH 2/5] btrfs: correct a message on setting nodatacow Satoru Takeuchi 2014-09-19 2:03 ` Qu Wenruo 2014-09-19 6:45 ` Satoru Takeuchi 2014-09-19 7:01 ` Qu Wenruo 2014-09-18 8:30 ` [PATCH 3/5] btrfs: notice nodatasum is also enabled with nodatacow Satoru Takeuchi 2014-09-18 8:32 ` [PATCH 4/5] btrfs: suppress a verbose message about enabling space cache on remounting Satoru Takeuchi 2014-09-18 8:43 ` [PATCH 5/5] btrfs: rework compression related options processing Satoru Takeuchi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).