All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: Fix restoring image from multi devices fs into single device
@ 2017-05-17  1:41 fdmanana
  2017-05-19  0:11 ` Liu Bo
  0 siblings, 1 reply; 3+ messages in thread
From: fdmanana @ 2017-05-17  1:41 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

We correctly build an image from a multiple devices filesystem but when
restoring the image into a single device we were missing updating the
number of devices in the superblock to the value 1 (we already took care
of setting the number of stripes to 1 for each chunk item and setting
the device id for each chunk item to match the device id from the super
block).

This missing update of the number of devices makes it impossible to mount
the restored filesystem on recent kernels, more specifically since the
linux kernel commit 99e3ecfcb9f4ca35192d20a5bea158b81f600062
("Btrfs: add more validation checks for superblock"), that produce the
following message in the dmesg/syslog:

[21097.542047] BTRFS error (device sdi): super_num_devices 2 mismatch with num_devices 1 found here
[21097.543972] BTRFS error (device sdi): failed to read chunk tree: -22
[21097.720360] BTRFS error (device sdi): open_ctree failed

So fix this by updating the number of devices to 1 in the superblock.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 image/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/image/main.c b/image/main.c
index f1c28de1..1eca414b 100644
--- a/image/main.c
+++ b/image/main.c
@@ -1500,6 +1500,7 @@ static int update_super(struct mdrestore_struct *mdres, u8 *buffer)
 	flags |= BTRFS_SUPER_FLAG_METADUMP_V2;
 	btrfs_set_super_flags(super, flags);
 	btrfs_set_super_sys_array_size(super, new_array_size);
+	btrfs_set_super_num_devices(super, 1);
 	csum_block(buffer, BTRFS_SUPER_INFO_SIZE);
 
 	return 0;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] btrfs-progs: Fix restoring image from multi devices fs into single device
  2017-05-17  1:41 [PATCH 1/2] btrfs-progs: Fix restoring image from multi devices fs into single device fdmanana
@ 2017-05-19  0:11 ` Liu Bo
  2017-05-29 16:48   ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Liu Bo @ 2017-05-19  0:11 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Wed, May 17, 2017 at 02:41:21AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> We correctly build an image from a multiple devices filesystem but when
> restoring the image into a single device we were missing updating the
> number of devices in the superblock to the value 1 (we already took care
> of setting the number of stripes to 1 for each chunk item and setting
> the device id for each chunk item to match the device id from the super
> block).
> 
> This missing update of the number of devices makes it impossible to mount
> the restored filesystem on recent kernels, more specifically since the
> linux kernel commit 99e3ecfcb9f4ca35192d20a5bea158b81f600062
> ("Btrfs: add more validation checks for superblock"), that produce the
> following message in the dmesg/syslog:
> 
> [21097.542047] BTRFS error (device sdi): super_num_devices 2 mismatch with num_devices 1 found here
> [21097.543972] BTRFS error (device sdi): failed to read chunk tree: -22
> [21097.720360] BTRFS error (device sdi): open_ctree failed
> 
> So fix this by updating the number of devices to 1 in the superblock.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Looks good.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] btrfs-progs: Fix restoring image from multi devices fs into single device
  2017-05-19  0:11 ` Liu Bo
@ 2017-05-29 16:48   ` David Sterba
  0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2017-05-29 16:48 UTC (permalink / raw)
  To: Liu Bo; +Cc: fdmanana, linux-btrfs

On Thu, May 18, 2017 at 05:11:35PM -0700, Liu Bo wrote:
> On Wed, May 17, 2017 at 02:41:21AM +0100, fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> > 
> > We correctly build an image from a multiple devices filesystem but when
> > restoring the image into a single device we were missing updating the
> > number of devices in the superblock to the value 1 (we already took care
> > of setting the number of stripes to 1 for each chunk item and setting
> > the device id for each chunk item to match the device id from the super
> > block).
> > 
> > This missing update of the number of devices makes it impossible to mount
> > the restored filesystem on recent kernels, more specifically since the
> > linux kernel commit 99e3ecfcb9f4ca35192d20a5bea158b81f600062
> > ("Btrfs: add more validation checks for superblock"), that produce the
> > following message in the dmesg/syslog:
> > 
> > [21097.542047] BTRFS error (device sdi): super_num_devices 2 mismatch with num_devices 1 found here
> > [21097.543972] BTRFS error (device sdi): failed to read chunk tree: -22
> > [21097.720360] BTRFS error (device sdi): open_ctree failed
> > 
> > So fix this by updating the number of devices to 1 in the superblock.
> > 
> > Signed-off-by: Filipe Manana <fdmanana@suse.com>
> 
> Looks good.
> 
> Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-29 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17  1:41 [PATCH 1/2] btrfs-progs: Fix restoring image from multi devices fs into single device fdmanana
2017-05-19  0:11 ` Liu Bo
2017-05-29 16:48   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.