All of lore.kernel.org
 help / color / mirror / Atom feed
From: g6094199@freenet.de
To: linux-btrfs@vger.kernel.org
Subject: Re: Re: [PATCH] btrfs-progs: add always option to restore's looping prompt
Date: Mon, 16 May 2016 02:12:16 +0200	[thread overview]
Message-ID: <4f8afda5-6a8e-937b-f38b-881ddf1c075d@chefmail.de> (raw)

He Guys,

i'm doing some restore right now. In fakt about 8TB.
I saw Justin sending the patch below in 2014 adding the "all" option when hitting the looping promt.
It would be nice to have this as command switch to, because if you have to recover the amount of data as i do atm, you probably get hundreds of looping promts
where you have to inactivly apply the "a" every time. This gets annoying after a while.
I also saw a similar request by Karl Richter some time ago (https://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg36458.html)


So please for all users that will have similar probs in the future the option *btrfs restore -a* (or similar).



regads
Sash





Hi Justin,

Thanks for the patch first, comment inlined below.
-------- Original Message --------
Subject: [PATCH] btrfs-progs: add always option to restore's looping prompt
From: Justin Maggard <jmaggard10 <at> gmail.com>
To: <linux-btrfs <at> vger.kernel.org>
Date: 2014年07月29日 08:03
> If you are using btrfs restore to try to recover a very large or
> fragmented file, you may encounter __lots__ of prompts requiring
> you to press 'y' to continue because we are looping a lot.
>
> Add the option to press 'a', to supress these prompts for the rest
> of the file.
> ---
>   cmds-restore.c | 17 +++++++++++------
>   1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/cmds-restore.c b/cmds-restore.c
> index 96b97e1..ae95d5a 100644
> --- a/cmds-restore.c
> +++ b/cmds-restore.c
>  <at>  <at>  -410,17 +410,19  <at>  <at>  static int ask_to_continue(const char *file)
>   	char *ret;
>   
>   	printf("We seem to be looping a lot on %s, do you want to keep going "
> -	       "on ? (y/N): ", file);
> +	       "on ? (y/N/a): ", file);
>   again:
>   	ret = fgets(buf, 2, stdin);
>   	if (*ret == '\n' || tolower(*ret) == 'n')
> -		return 1;
> +		return 0;
> +	if (tolower(*ret) == 'a')
> +		return 2;
>   	if (tolower(*ret) != 'y') {
>   		printf("Please enter either 'y' or 'n': ");
Since option 'a' is added, it would be better to change the prompt and 
add 'a' to it.
>   		goto again;
>   	}
>   
> -	return 0;
> +	return 1;
>   }
If add any comment or change the return value from immediate number to 
more meaningful defined number,
it would be much more easier to understand and expend.
Especially when the return value has difference meaning with original one.
>   
>   
>  <at>  <at>  -588,11 +590,14  <at>  <at>  static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key,
>   	}
>   
>   	while (1) {
> -		if (loops++ >= 1024) {
> +		if (loops >= 0 && loops++ >= 1024) {
>   			ret = ask_to_continue(file);
> -			if (ret)
> +			if (ret == 0)
>   				break;
> -			loops = 0;
> +			else if (ret == 1)
> +				loops = 0;
> +			else if (ret == 2)
> +				loops = -1;
>   		}
>   		if (path->slots[0] >= btrfs_header_nritems(leaf)) {
>   			do {
Also, just a suggestion and you can ignore it without any problem,
utils.c provide ask_to_continue() function to provide similar behavior, 
what about improve the one in utils.c
and reuse the ask_to_continue() function?

Thanks,
Qu
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


                 reply	other threads:[~2016-05-16  0:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4f8afda5-6a8e-937b-f38b-881ddf1c075d@chefmail.de \
    --to=g6094199@freenet.de \
    --cc=linux-btrfs@vger.kernel.org \
    /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 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.