btrfs-progs: add educational warning for flipping RO to RW on recevied subvolumes
Subsystems (2)
cover btrfs-progs: add educational warning for flipping RO to RW on recevied subvolumes
Since we're going to change how kernel handles received subvolume RO->RW flipping, it is going to cause kernel behavior change for some incremental send users.
Add extra educational warning to both "btrfs prop set" command and man page of "btrfs prop".
Qu Wenruo (2):
btrfs-progs: do extra warning when setting ro false on received
subvolume
btrfs-progs: doc: add extra note on flipping read-only on received
subvolumes
Documentation/btrfs-property.asciidoc | 6 ++++++ props.c | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+)
Signature · 1 line
2.33.0
PATCH 1/2 btrfs-progs: do extra warning when setting ro false on received subvolume
When flipping received subvolume from RO to RW, any new write to the subvolume could cause later incremental receive to fail or corrupt data.
Thus we're trying to clear received UUID when doing such RO->RW flip, to prevent data corruption.
But unfortunately the old (and wrong) behavior has been there for a while, and changing the kernel behavior will make existing users confused.
Thus here we enhance subvolume read-only prop to do extra warning on users to educate them about both the new behavior and the problems of old behaviors.
--- props.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
props.c +21 -0
@@ -39,6 +39,15 @@#define ENOATTR ENODATA#endif +static void do_warn_about_rorw_flip (const char *path) +{ +warning ("Flipping subvolume %s from RO to RW will cause either:" , path); +warning ("- No more incremental receive based on this subvolume" ); +warning (" Newer kernels will remove the recevied UUID to prevent corruption" ); +warning ("- Data corruption or receive corruption doing incremental receive" ); +warning (" Older kernels can't detect the modification, and cause corruption or receive failure" ); +} + static int prop_read_only(enum prop_object_type type, const char *object, const char *name,
@@ -48,6 +57,9 @@ static int prop_read_only(enum prop_object_type type,bool read_only;if (value) { +struct btrfs_util_subvolume_info subvol; +u8 empty_uuid[BTRFS_UUID_SIZE ] = {0 }; +if (!strcmp (value,"true" )) { read_only = true; }else if (!strcmp (value,"false" )) {
@@ -57,6 +69,15 @@ static int prop_read_only(enum prop_object_type type,return -EINVAL ; } + err =btrfs_util_subvolume_info (object,0 , &subvol); +if (err) { +warning ("unable to get subvolume info for path %s" , + object); + }else if (!read_only &&memcmp (empty_uuid, subvol.received_uuid, +BTRFS_UUID_SIZE )){ +do_warn_about_rorw_flip (object); + } + err =btrfs_util_set_subvolume_read_only (object, read_only);if (err) {error_btrfs_util (err);
Signature · 1 line
2.33.0
PATCH 2/2 btrfs-progs: doc: add extra note on flipping read-only on received subvolumes
In reply to Qu Wenruo--- Documentation/btrfs-property.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/btrfs-property.asciidoc +6 -0
@@ -42,6 +42,12 @@ the following: ro:::: read-only flag of subvolume: true or false ++ +NOTE: For recevied subvolumes, flipping from read-only to read-write will +either remove the recevied UUID and prevent future incremental receive +(on newer kernels), or cause future data corruption and recevie failure +(on older kernels). + label:::: label of the filesystem. For an unmounted filesystem, provide a path to a block device as object. For a mounted filesystem, specify a mount point.
Signature · 1 line
2.33.0
Re: [PATCH 2/2] btrfs-progs: doc: add extra note on flipping read-only on received subvolumes
Quoted 10 lines · Qu Wenruo
Signed-off-by Qu Wenruo <[email protected]>--- Documentation/btrfs-property.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/btrfs-property.asciidoc +0
-0
Documentation/btrfs-property.asciidoc the following: · line 49
Quoted 8 lines
Documentation/btrfs-property.asciidoc +5
-0@@ -42,6 +42,12 @@ the following: ro:::: read-only flag of subvolume: true or false ++ +NOTE: For recevied subvolumes, flipping from read-only to read-write will +either remove the recevied UUID and prevent future incremental receive +(on newer kernels), or cause future data corruption and recevie failure +(on older kernels).
Hang on a minute, flipping RO->RW won't cause corruption by itself. So flipping will just break incremental sends which is completely fine.
Quoted 5 lines
Documentation/btrfs-property.asciidoc +1
-0+ label:::: label of the filesystem. For an unmounted filesystem, provide a path to a block device as object. For a mounted filesystem, specify a mount point.
Re: [PATCH 1/2] btrfs-progs: do extra warning when setting ro false on received subvolume
In reply to Qu WenruoQuoted 24 lines · Qu Wenruo
When flipping received subvolume from RO to RW, any new write to the subvolume could cause later incremental receive to fail or corrupt data.
Thus we're trying to clear received UUID when doing such
RO->RWflip, to prevent data corruption.But unfortunately the old (and wrong) behavior has been there for a while, and changing the kernel behavior will make existing users confused.
Thus here we enhance subvolume read-only prop to do extra warning on users to educate them about both the new behavior and the problems of old behaviors.
Signed-off-by Qu Wenruo <[email protected]>--- props.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)props.c +0
-0
props.c line 48
Quoted 10 lines
props.c +7
-0@@ -39,6 +39,15 @@#define ENOATTR ENODATA#endif +static void do_warn_about_rorw_flip (const char *path) +{ +warning ("Flipping subvolume %s from RO to RW will cause either:" , path); +warning ("- No more incremental receive based on this subvolume" ); +warning (" Newer kernels will remove the recevied UUID to prevent corruption" ); +warning ("- Data corruption or receive corruption doing incremental receive" ); +warning (" Older kernels can't detect the modification, and cause corruption or receive failure" );
This is a bad format for a warning, let's keep it simple - just state that flipping ro->rw would break incremental send and that's that.
Quoted 32 lines
props.c +14
-0+} + static int prop_read_only(enum prop_object_type type, const char *object, const char *name,@@ -48,6 +57,9 @@ static int prop_read_only(enum prop_object_type type,bool read_only;if (value) { +struct btrfs_util_subvolume_info subvol; +u8 empty_uuid[BTRFS_UUID_SIZE ] = {0 }; +if (!strcmp (value,"true" )) { read_only = true; }else if (!strcmp (value,"false" )) {@@ -57,6 +69,15 @@ static int prop_read_only(enum prop_object_type type,return -EINVAL ; } + err =btrfs_util_subvolume_info (object,0 , &subvol); +if (err) { +warning ("unable to get subvolume info for path %s" , + object); + }else if (!read_only &&memcmp (empty_uuid, subvol.received_uuid, +BTRFS_UUID_SIZE )){ +do_warn_about_rorw_flip (object); + } + err =btrfs_util_set_subvolume_read_only (object, read_only);if (err) {error_btrfs_util (err);
Re: [PATCH 1/2] btrfs-progs: do extra warning when setting ro false on received subvolume
Quoted 30 lines · Nikolay Borisov
Quoted 27 lines · Qu Wenruo
When flipping received subvolume from RO to RW, any new write to the subvolume could cause later incremental receive to fail or corrupt data.
Thus we're trying to clear received UUID when doing such
RO->RWflip, to prevent data corruption.But unfortunately the old (and wrong) behavior has been there for a while, and changing the kernel behavior will make existing users confused.
Thus here we enhance subvolume read-only prop to do extra warning on users to educate them about both the new behavior and the problems of old behaviors.
Signed-off-by Qu Wenruo <[email protected]>--- props.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)props.c +0
-0@@ -39,6 +39,15 @@#define ENOATTR ENODATA#endif
Quoted 10 lines
props.c line 48
Quoted 7 lines
props.c +7
-0+static void do_warn_about_rorw_flip (const char *path) +{ +warning ("Flipping subvolume %s from RO to RW will cause either:" , path); +warning ("- No more incremental receive based on this subvolume" ); +warning (" Newer kernels will remove the recevied UUID to prevent corruption" ); +warning ("- Data corruption or receive corruption doing incremental receive" ); +warning (" Older kernels can't detect the modification, and cause corruption or receive failure" );This is a bad format for a warning, let's keep it simple - just state that flipping
ro->rwwould break incremental send and that's that.
But won't this on older kernels cause more confusion?
The old kernels will still allow incremental send using that flipped subvolume without problem, just corrupting the data..
(Well, that's definitely "broken", but still a different behavior)
Thanks,
Qu
Quoted 34 lines
Quoted 33 lines
props.c +14
-0+} + static int prop_read_only(enum prop_object_type type, const char *object, const char *name,@@ -48,6 +57,9 @@ static int prop_read_only(enum prop_object_type type,bool read_only;if (value) { +struct btrfs_util_subvolume_info subvol; +u8 empty_uuid[BTRFS_UUID_SIZE ] = {0 }; +if (!strcmp (value,"true" )) { read_only = true; }else if (!strcmp (value,"false" )) {@@ -57,6 +69,15 @@ static int prop_read_only(enum prop_object_type type,return -EINVAL ; } + err =btrfs_util_subvolume_info (object,0 , &subvol); +if (err) { +warning ("unable to get subvolume info for path %s" , + object); + }else if (!read_only &&memcmp (empty_uuid, subvol.received_uuid, +BTRFS_UUID_SIZE )){ +do_warn_about_rorw_flip (object); + } + err =btrfs_util_set_subvolume_read_only (object, read_only);if (err) {error_btrfs_util (err);
Re: [PATCH 2/2] btrfs-progs: doc: add extra note on flipping read-only on received subvolumes
In reply to Nikolay BorisovQuoted 14 lines · Nikolay Borisov
Quoted 11 lines · Qu Wenruo
Signed-off-by Qu Wenruo <[email protected]>--- Documentation/btrfs-property.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/btrfs-property.asciidoc +0
-0@@ -42,6 +42,12 @@ the following:
Quoted 9 lines
Documentation/btrfs-property.asciidoc the following: · line 49
Quoted 7 lines
Documentation/btrfs-property.asciidoc +5
-0ro:::: read-only flag of subvolume: true or false ++ +NOTE: For recevied subvolumes, flipping from read-only to read-write will +either remove the recevied UUID and prevent future incremental receive +(on newer kernels), or cause future data corruption and recevie failure +(on older kernels).Hang on a minute, flipping
RO->RWwon't cause corruption by itself.
It looks like the "future" part is not clear enough.
Quoted 2 lines
So
flipping will just break incremental sends which is completely fine.
The "breaking" part is more straightforward for newer kernel, but not older kernels (it's definitely breaking, but not that directly observable)
Thanks,
Qu
Quoted 7 lines
Quoted 6 lines
Documentation/btrfs-property.asciidoc +1
-0+ label:::: label of the filesystem. For an unmounted filesystem, provide a path to a block device as object. For a mounted filesystem, specify a mount point.
Re: [PATCH 1/2] btrfs-progs: do extra warning when setting ro false on received subvolume
In reply to Qu WenruoQuoted 47 lines · Qu Wenruo
Quoted 35 lines · Nikolay Borisov
Quoted 32 lines · Qu Wenruo
When flipping received subvolume from RO to RW, any new write to the subvolume could cause later incremental receive to fail or corrupt data.
Thus we're trying to clear received UUID when doing such
RO->RWflip, to prevent data corruption.But unfortunately the old (and wrong) behavior has been there for a while, and changing the kernel behavior will make existing users confused.
Thus here we enhance subvolume read-only prop to do extra warning on users to educate them about both the new behavior and the problems of old behaviors.
Signed-off-by Qu Wenruo <[email protected]>---
props.c| 21 +++++++++++++++++++++1 file changed, 21 insertions(+)props.c +4
-0@@ -39,6 +39,15 @@ #define ENOATTR ENODATA #endif +static void do_warn_about_rorw_flip(const char *path) +{ + warning("Flipping subvolume %s from RO to RW will cause either:", path); + warning("- No more incremental receive based on this subvolume"); + warning(" Newer kernels will remove the recevied UUID toQuoted 8 lines
Quoted 5 lines
props.c +2
-0prevent corruption"); + warning("- Data corruption or receive corruption doing incremental receive"); + warning(" Older kernels can't detect the modification, andcause corruption or receive failure");
This is a bad format for a warning, let's keep it simple - just state that flipping
ro->rwwould break incremental send and that's that.
Quoted 6 lines
But won't this on older kernels cause more confusion?
The old kernels will still allow incremental send using that flipped subvolume without problem, just corrupting the data..
(Well, that's definitely "broken", but still a different behavior)
Exactly. I agree with Nikolay - keep the warning simple. Let the man page explain in more detail.
Re: [PATCH 2/2] btrfs-progs: doc: add extra note on flipping read-only on received subvolumes
In reply to Nikolay BorisovQuoted 14 lines · Nikolay Borisov
Quoted 11 lines · Qu Wenruo
Signed-off-by Qu Wenruo <[email protected]>--- Documentation/btrfs-property.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/btrfs-property.asciidoc +0
-0@@ -42,6 +42,12 @@ the following:
Quoted 10 lines
Documentation/btrfs-property.asciidoc the following: · line 49
Quoted 7 lines
Documentation/btrfs-property.asciidoc +5
-0ro:::: read-only flag of subvolume: true or false ++ +NOTE: For recevied subvolumes, flipping from read-only to read-write will +either remove the recevied UUID and prevent future incremental receive +(on newer kernels), or cause future data corruption and recevie failure +(on older kernels).Hang on a minute, flipping
RO->RWwon't cause corruption by itself. So flipping will just break incremental sends which is completely fine.
I'm still not decided if it's 'completely fine' to break incremental send so easily.
Re: [PATCH 2/2] btrfs-progs: doc: add extra note on flipping read-only on received subvolumes
In reply to Qu WenruoQuoted 28 lines · Qu Wenruo
Quoted 8 lines · Nikolay Borisov
Quoted 5 lines · Qu Wenruo
Signed-off-by Qu Wenruo <[email protected]>---
Documentation/btrfs-property.asciidoc| 6 ++++++1 file changed, 6 insertions(+)Quoted 16 lines
Quoted 11 lines
Documentation/btrfs-property.asciidoc +0
-0@@ -42,6 +42,12 @@ the following:ro::::
read-only flag of subvolume: true or false
++
+NOTE: For recevied subvolumes, flipping from read-only to read-write willDocumentation/btrfs-property.asciidoc the following: · line 49
Quoted 3 lines
Documentation/btrfs-property.asciidoc +3
-0+either remove the recevied UUID and prevent future incremental receive +(on newer kernels), or cause future data corruption and recevie failure +(on older kernels).Hang on a minute, flipping
RO->RWwon't cause corruption by itself.
Quoted 7 lines
It looks like the "future" part is not clear enough.
Quoted 2 lines
So
flipping will just break incremental sends which is completely fine.The "breaking" part is more straightforward for newer kernel, but not older kernels (it's definitely breaking, but not that directly observable)
How about...
NOTE: Changing a subvolume which has been received using btrfs receive to be writable could silently corrupt future btrfs receive operations using the subvolume. Recent kernels automatically remove the 'received UUID' on the subvolume when the read-only flag is set to false in order to protect against this corruption. This will mean that subsequent btrfs receive commands which refer to this subvolume will fail. With earlier kernels, similar btrfs receive commands could cause silent corruption.
Quoted 13 lines
Thanks,
QuQuoted 8 lines
Quoted 7 lines
+
label::::
label of the filesystem. For an unmounted filesystem, provide a path to a block
device as object. For a mounted filesystem, specify a mount point.
Re: [PATCH 2/2] btrfs-progs: doc: add extra note on flipping read-only on received subvolumes
In reply to David SterbaQuoted 26 lines · David Sterba
Quoted 14 lines · Nikolay Borisov
Quoted 11 lines · Qu Wenruo
Signed-off-by Qu Wenruo <[email protected]>--- Documentation/btrfs-property.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/btrfs-property.asciidoc +0
-0@@ -42,6 +42,12 @@ the following:Quoted 10 lines
Documentation/btrfs-property.asciidoc the following: · line 49
Quoted 7 lines
Documentation/btrfs-property.asciidoc +5
-0ro:::: read-only flag of subvolume: true or false ++ +NOTE: For recevied subvolumes, flipping from read-only to read-write will +either remove the recevied UUID and prevent future incremental receive +(on newer kernels), or cause future data corruption and recevie failure +(on older kernels).Hang on a minute, flipping
RO->RWwon't cause corruption by itself. So flipping will just break incremental sends which is completely fine.
Quoted 3 lines
I'm still not decided if it's 'completely fine' to break incremental send so easily.
Then even we just keep the existing behavior, we still need some educational warning here.
In that keep-recevied-uuid case, here we just need to warn the users about that, later incremental receive may fail and the recevied data may not be correct, and call it a day (without any kernel modification).
In that case, it's all users' fault and except the corrupted data and receive failure, everything else should be fine.
Kernel won't crash, users get their "expected" corrupted data, and we won't need to bother the kernel behavior change.
But I don't think that would be any better than a sudden behavior change...
Thanks,
Qu
Re: [PATCH 2/2] btrfs-progs: doc: add extra note on flipping read-only on received subvolumes
Quoted 43 lines · Qu Wenruo
Quoted 29 lines · David Sterba
Quoted 15 lines · Nikolay Borisov
Quoted 12 lines · Qu Wenruo
Signed-off-by Qu Wenruo <[email protected]>---
Documentation/btrfs-property.asciidoc| 6 ++++++1 file changed, 6 insertions(+)Documentation/btrfs-property.asciidoc +0
-0@@ -42,6 +42,12 @@ the following:Quoted 12 lines
Quoted 9 lines
ro::::
read-only flag of subvolume: true or false
++
+NOTE: For recevied subvolumes, flipping from read-only to read-write willDocumentation/btrfs-property.asciidoc +2
-0+either remove the recevied UUID and prevent future incremental receive +(on newer kernels), or cause future data corruption and receviefailure
+(on older kernels).Hang on a minute, flipping
RO->RWwon't cause corruption by itself. So flipping will just break incremental sends which is completely fine.Quoted 3 lines
I'm still not decided if it's 'completely fine' to break incremental send so easily.
Then even we just keep the existing behavior, we still need some educational warning here.
In that keep-recevied-uuid case, here we just need to warn the users about that, later incremental receive may fail and the recevied data may not be correct, and call it a day (without any kernel modification).
Quoted 7 lines
In that case, it's all users' fault and except the corrupted data and receive failure, everything else should be fine.
Kernel won't crash, users get their "expected" corrupted data, and we won't need to bother the kernel behavior change.
But I don't think that would be any better than a sudden behavior change...
I wholeheartedly disagree. If we do a behavior change then users must just adjust which really means they have to make 1 full send. If we keep the current behavior we are bound to be getting reports of corrupted data/failed receive of subvolumes. And in the end this would end up being a huge time sink for the person who ends up investigating this...
Quoted 4 lines
Thanks,
Qu