public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 4/6] btrfs-progs: fix-data-checksum: introduce interactive mode
Date: Fri, 30 May 2025 13:18:08 +0200	[thread overview]
Message-ID: <20250530111808.GT4037@twin.jikos.cz> (raw)
In-Reply-To: <c0f551f03f8d81e2a46e35a08339ef096b46984f.1747295965.git.wqu@suse.com>

On Thu, May 15, 2025 at 05:30:19PM +0930, Qu Wenruo wrote:
> --- a/cmds/rescue-fix-data-checksum.c
> +++ b/cmds/rescue-fix-data-checksum.c
> @@ -14,6 +14,7 @@
>   * Boston, MA 021110-1307, USA.
>   */
>  
> +#include <ctype.h>
>  #include "kerncompat.h"

The kerncompat.h needs to be first as there are workarounds for some
system includes. This has been unified everywhere else so please stick
to the ordering.

>  #include "kernel-shared/disk-io.h"
>  #include "kernel-shared/ctree.h"
> @@ -45,6 +46,21 @@ struct corrupted_block {
>  	unsigned long *error_mirror_bitmap;
>  };
>  
> +enum fix_data_checksum_action_value {
> +	ACTION_IGNORE,
> +	ACTION_LAST,
> +};
> +
> +static const struct fix_data_checksum_action {
> +	enum fix_data_checksum_action_value value;
> +	const char *string;
> +} actions[] = {
> +	[ACTION_IGNORE] = {
> +		.value = ACTION_IGNORE,
> +		.string = "ignore",
> +	},
> +};
> +
>  static int global_repair_mode;
>  LIST_HEAD(corrupted_blocks);
>  
> @@ -241,10 +257,49 @@ next:
>  	return ret;
>  }
>  
> @@ -277,6 +332,16 @@ static void report_corrupted_blocks(struct btrfs_fs_info *fs_info)
>  			error("failed to iterate involved files: %m");
>  			break;
>  		}
> +		switch (mode) {
> +		case BTRFS_FIX_DATA_CSUMS_INTERACTIVE:
> +			action = ask_action();
> +			UASSERT(action == ACTION_IGNORE);
> +			fallthrough;
> +		case BTRFS_FIX_DATA_CSUMS_READONLY:
> +			break;
> +		default:
> +			UASSERT(0);

I haven't fixed that but please don't do the ASSERT(0), we have
INTERNAL_ERROR for runtime errors or handle it and return with a hard
exit.

> +		}
>  	}
>  }

  reply	other threads:[~2025-05-30 11:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-15  8:00 [PATCH v2 0/6] btrfs-progs: introduce "btrfs rescue fix-data-checksum" Qu Wenruo
2025-05-15  8:00 ` [PATCH v2 1/6] " Qu Wenruo
2025-05-30 11:10   ` David Sterba
2025-05-15  8:00 ` [PATCH v2 2/6] btrfs-progs: fix a bug in btrfs_find_item() Qu Wenruo
2025-05-30 11:11   ` David Sterba
2025-05-15  8:00 ` [PATCH v2 3/6] btrfs-progs: fix-data-checksum: show affected files Qu Wenruo
2025-05-30 11:14   ` David Sterba
2025-05-15  8:00 ` [PATCH v2 4/6] btrfs-progs: fix-data-checksum: introduce interactive mode Qu Wenruo
2025-05-30 11:18   ` David Sterba [this message]
2025-05-15  8:00 ` [PATCH v2 5/6] btrfs-progs: fix-data-checksum: update csum items to fix csum mismatch Qu Wenruo
2025-05-30 11:19   ` David Sterba
2025-05-30 22:23     ` Qu Wenruo
2025-05-15  8:00 ` [PATCH v2 6/6] btrfs-progs: fix-data-checksum: introduce -m|--mirror option Qu Wenruo
2025-05-30 11:07 ` [PATCH v2 0/6] btrfs-progs: introduce "btrfs rescue fix-data-checksum" David Sterba
2025-05-31 16:58 ` Goffredo Baroncelli
2025-05-31 22:07   ` Qu Wenruo
2025-06-02 17:28     ` Goffredo Baroncelli
2025-06-02 22:55       ` Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250530111808.GT4037@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox