public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Wang Shilong <wangshilong1991@gmail.com>
To: dsterba@suse.cz
Cc: Wang Shilong <wangsl.fnst@cn.fujitsu.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/4] Btrfs: fix wrong send_in_progress accounting
Date: Wed, 8 Jan 2014 23:09:02 +0800	[thread overview]
Message-ID: <FBF55D09-2D04-4ACF-A159-2DDD3D896C3A@gmail.com> (raw)
In-Reply-To: <20140108121609.GF6498@suse.cz>


Hello David,

> On Tue, Jan 07, 2014 at 05:25:18PM +0800, Wang Shilong wrote:
>> Steps to reproduce:
>> # mkfs.btrfs -f /dev/sda8
>> # mount /dev/sda8 /mnt
>> # btrfs sub snapshot -r /mnt /mnt/snap1
>> # btrfs sub snapshot -r /mnt /mnt/snap2
>> # btrfs send /mnt/snap1 -p /mnt/snap2 -f /mnt/1
>> # dmesg
>> 
>> The problem is that we will sort clone roots(include @send_root), it
>> might push @send_root before thus @send_root's @send_in_progress will
>> be decreased twice.
> 
> Of course, the sort(). I think your fix adds some complexity that's not
> necessary. Whether the clone_roots array is sorted is not important, we
> just have to process each root once.
> 
> send_root becomes a clone_root member, so the missing part is to account
> in the rollback counter:
> 
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -4937,6 +4937,7 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
>         * for possible clone sources.
>         */
>        sctx->clone_roots[sctx->clone_roots_cnt++].root = sctx->send_root;
> +       clone_sources_to_rollback++;

Not really, If we fail to come here, we still need decrease @send_root.
Please correct me if i miss something here.^_^

Thanks,
Wang
> 
>        /* We do a bsearch later */
>        sort(sctx->clone_roots, sctx->clone_roots_cnt,
> @@ -4961,7 +4962,6 @@ out:
>                btrfs_root_dec_send_in_progress(sctx->clone_roots[i].root);
>        if (sctx && !IS_ERR_OR_NULL(sctx->parent_root))
>                btrfs_root_dec_send_in_progress(sctx->parent_root);
> -       btrfs_root_dec_send_in_progress(send_root);

> 
>        kfree(arg);
>        vfree(clone_sources_tmp);
> ---
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2014-01-08 15:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07  9:25 [PATCH v2 1/4] Btrfs: fix wrong send_in_progress accounting Wang Shilong
2014-01-07  9:25 ` [PATCH v2 2/4] Btrfs: fix protection between send and root deletion Wang Shilong
2014-01-13 18:27   ` David Sterba
2014-01-14  2:22     ` Miao Xie
2014-01-15 16:40       ` David Sterba
2014-01-16  2:32         ` Miao Xie
2014-01-21 18:16           ` David Sterba
2014-01-22  8:44             ` Wang Shilong
2014-01-22 12:43               ` David Sterba
2014-01-08 12:16 ` [PATCH v2 1/4] Btrfs: fix wrong send_in_progress accounting David Sterba
2014-01-08 15:09   ` Wang Shilong [this message]
2014-01-13 18:40     ` David Sterba
2014-01-14 11:52       ` Wang Shilong

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=FBF55D09-2D04-4ACF-A159-2DDD3D896C3A@gmail.com \
    --to=wangshilong1991@gmail.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wangsl.fnst@cn.fujitsu.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