[07/13] btrfs-progs: lowmem: delete unaligned bytes extent data under repair
diff mbox series

Message ID 20181023094147.7906-8-suy.fnst@cn.fujitsu.com
State New
Headers show
Series
  • btrfs-progs: fixes of file extent in original and lowmem check
Related show

Commit Message

Su Yue Oct. 23, 2018, 9:41 a.m. UTC
If found a extent data item has unaligned part, lowmem repair
just deletes it.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 check/mode-lowmem.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Qu Wenruo Oct. 24, 2018, 12:16 a.m. UTC | #1
On 2018/10/23 下午5:41, Su Yue wrote:
> If found a extent data item has unaligned part, lowmem repair
> just deletes it.

Fair enough solution.

Much better than the unpredictable original mode solution.

> 
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>  check/mode-lowmem.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
> index 3c9ecff7e498..5381096fa8b2 100644
> --- a/check/mode-lowmem.c
> +++ b/check/mode-lowmem.c
> @@ -2972,6 +2972,7 @@ out:
>  }
>  
>  /*
> + * If @err contains BYTES_UNALIGNED then delete the extent data item.
>   * If @err contains BACKREF_MISSING then add extent of the
>   * file_extent_data_item.
>   *
> @@ -3023,6 +3024,13 @@ static int repair_extent_data_item(struct btrfs_root *root,
>  	else
>  		parent = 0;
>  
> +	if (err & BYTES_UNALIGNED) {
> +		ret = delete_item(root, pathp);
> +		if (!ret)
> +			err = 0;
> +		goto out;
> +	}
> +
>  	/* now repair only adds backref */
>  	if ((err & BACKREF_MISSING) == 0)
>  		return err;
>

Patch
diff mbox series

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 3c9ecff7e498..5381096fa8b2 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -2972,6 +2972,7 @@  out:
 }
 
 /*
+ * If @err contains BYTES_UNALIGNED then delete the extent data item.
  * If @err contains BACKREF_MISSING then add extent of the
  * file_extent_data_item.
  *
@@ -3023,6 +3024,13 @@  static int repair_extent_data_item(struct btrfs_root *root,
 	else
 		parent = 0;
 
+	if (err & BYTES_UNALIGNED) {
+		ret = delete_item(root, pathp);
+		if (!ret)
+			err = 0;
+		goto out;
+	}
+
 	/* now repair only adds backref */
 	if ((err & BACKREF_MISSING) == 0)
 		return err;