linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: dsterba@suse.com,
	Marcos Paulo de Souza <marcos.souza.org@gmail.com>,
	linux-btrfs@vger.kernel.org, mpdesouza@suse.com
Subject: Re: [PATCH btrfs-progs 0/2] balance: check balance errors on background
Date: Fri, 15 Nov 2019 13:18:47 +0100	[thread overview]
Message-ID: <20191115121847.GS3001@twin.jikos.cz> (raw)
In-Reply-To: <87bc3923-8cda-4bcf-a3e7-fa6204c71d5e@oracle.com>

On Thu, Oct 31, 2019 at 06:00:35PM +0800, Anand Jain wrote:
> On 10/31/19 7:36 AM, Marcos Paulo de Souza wrote:
> > From: Marcos Paulo de Souza <mpdesouza@suse.com>
> > 
> > The first patch removes the close/open operation of stderr, so we can receive
> > errors of balance when starting in the background.
> > 
> > The second patch waits up to three seconds after started the balance process, to
> > check is some problem happened to the balance process. This is done only when
> > the user issues the "balance start" in background mode.
> > 
> > This was tested by issuing running "btrfs balance start --background
> > --full-balance <path>", when the balance started, issue the same command again
> > in the same terminal:
> > 
> > # ./btrfs balance start --background --full-balance /mnt
> > # ./btrfs balance start --background --full-balance /mnt
> > ERROR: error during balancing '/mnt': Operation now in progress
> > 
> > These two patches together fixes the issue 167[1].
> > 
> > Please review,
> > Thanks.
> > 
> > [1]: https://github.com/kdave/btrfs-progs/issues/167
> 
> 
> David,
> 
> -----
> (To fix this, the parent process should wait a bit if the forked 
> background process still runs and report errors otherwise. There are no 
> blocking calls when the 2nd ioctl is called, so a few seconds should be 
> enough.)
> -----
> 
>   This approach might work in most of the cases. However user thread
>   waiting for 3 sec is not a deterministic way to find if the balance
>   was started successfully in the kernel. IMO.

Yes, that's right, it's the simplest thing to implement right now.

>   Instead can we use the balance start ioctl to spin a kthread
>   to run the actual balance that is __btrfs_balance(). With means
>   until call to __btrfs_balance() we shall use ioctl-thread and
>   to spin up kthread to run __btrfs_balance() and return the ioctl
>   thread with the interim status
>   (So for the --no-background user thread has to monitor the
>   balance status using the balance progress ioctl and return when
>   the status becomes completed and also it should call balance control
>   ioctl if the received sigint).
> 
>   We do use kthread for balance, if mount thread has to resume the
>   balance. so its a kind of extension to it.
> 
>   But in the view of the backward btrfs-progs compatibility (that is new
>   kernel with old progs) it looks like we need a new balance-ioctl
>   altogether, but the question is if its too much infrastructure changes,
>   which otherwise might have worked fairly well with a 3 sec delay? What
>   do you think? I think its a good idea to fix it in the right way.

The balance ioctl could start a kthread, we don't need to do a new ioctl
but just extend flags passed to BTRFS_IOC_BALANCE_V2.

As the current --background option creates a userspace process, this is
something we can't silently change to a kernel thread. So this will
probably need a new option but otherwise I don't see any other problems.

Reporting the status is done in the same way using the ioctl
BTRFS_IOC_BALANCE_PROGRESS .

The 3 second wait is not 100% reliable, we can potentially make it a bit
more reliable if the timeout starts right before the other process
starts the ioctl. To minimize effects of activity in the rest of the
system. This could be done in a simple way by a pipe that signals from
the child to the parent that the ioctl is going to be called next.

      reply	other threads:[~2019-11-15 12:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 23:36 [PATCH btrfs-progs 0/2] balance: check balance errors on background Marcos Paulo de Souza
2019-10-30 23:36 ` [PATCH btrfs-progs 1/2] btrfs-progs: balance: Don't set stderr to /dev/null on balance_start Marcos Paulo de Souza
2019-10-30 23:36 ` [PATCH btrfs-progs 2/2] btrfs-progs: balance: Verify EINPROGRESS on background balance Marcos Paulo de Souza
2019-10-31 10:00 ` [PATCH btrfs-progs 0/2] balance: check balance errors on background Anand Jain
2019-11-15 12:18   ` David Sterba [this message]

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=20191115121847.GS3001@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=marcos.souza.org@gmail.com \
    --cc=mpdesouza@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;
as well as URLs for NNTP newsgroup(s).