summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/scrub.c
diff options
context:
space:
mode:
authorMiao Xie2014-09-03 15:35:33 +0200
committerChris Mason2014-09-17 22:38:33 +0200
commit935e5cc935bcbf9b3d0dd59fed7dbc0f2ebca6bc (patch)
tree2489d657687317839ab01cd1c617356851839726 /fs/btrfs/scrub.c
parentBtrfs: fix unprotected assignment of the target device (diff)
downloadkernel-qcow2-linux-935e5cc935bcbf9b3d0dd59fed7dbc0f2ebca6bc.tar.gz
kernel-qcow2-linux-935e5cc935bcbf9b3d0dd59fed7dbc0f2ebca6bc.tar.xz
kernel-qcow2-linux-935e5cc935bcbf9b3d0dd59fed7dbc0f2ebca6bc.zip
Btrfs: fix wrong disk size when writing super blocks
total_size will be changed when resizing a device, and disk_total_size will be changed if resizing is successful. Meanwhile, the on-disk super blocks of the previous transaction might not be updated. Considering the consistency of the metadata in the previous transaction, We should use the size in the previous transaction to check if the super block is beyond the boundary of the device. Fix it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/scrub.c')
-rw-r--r--fs/btrfs/scrub.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 72c8981e7c0a..9d80e37044db 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2840,7 +2840,8 @@ static noinline_for_stack int scrub_supers(struct scrub_ctx *sctx,
for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
bytenr = btrfs_sb_offset(i);
- if (bytenr + BTRFS_SUPER_INFO_SIZE > scrub_dev->total_bytes)
+ if (bytenr + BTRFS_SUPER_INFO_SIZE >
+ scrub_dev->commit_total_bytes)
break;
ret = scrub_pages(sctx, bytenr, BTRFS_SUPER_INFO_SIZE, bytenr,