From patchwork Wed Jan 8 12:16:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 3453531 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 75991C02DC for ; Wed, 8 Jan 2014 12:16:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B42520149 for ; Wed, 8 Jan 2014 12:16:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ABE8A20109 for ; Wed, 8 Jan 2014 12:16:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755800AbaAHMQM (ORCPT ); Wed, 8 Jan 2014 07:16:12 -0500 Received: from cantor2.suse.de ([195.135.220.15]:52448 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755200AbaAHMQL (ORCPT ); Wed, 8 Jan 2014 07:16:11 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F0665AC3E; Wed, 8 Jan 2014 12:16:09 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 8F843DA84D; Wed, 8 Jan 2014 13:16:09 +0100 (CET) Date: Wed, 8 Jan 2014 13:16:09 +0100 From: David Sterba To: Wang Shilong Cc: linux-btrfs@vger.kernel.org Subject: Re: [PATCH v2 1/4] Btrfs: fix wrong send_in_progress accounting Message-ID: <20140108121609.GF6498@suse.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Wang Shilong , linux-btrfs@vger.kernel.org References: <1389086721-19624-1-git-send-email-wangsl.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1389086721-19624-1-git-send-email-wangsl.fnst@cn.fujitsu.com> User-Agent: Mutt/1.5.22 (2013-10-16) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: --- -- 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 --- 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++; /* 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);