Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2456357imw; Wed, 6 Jul 2022 06:19:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vI/NBxzq9K/Ks4HUCWX8gIhL/Pz9chNjAGsh1b2v/eKqQSIU4SpOdfxDh7+cH+P8pzp024 X-Received: by 2002:a05:6402:1502:b0:439:e4a5:4ba9 with SMTP id f2-20020a056402150200b00439e4a54ba9mr28934189edw.19.1657113584596; Wed, 06 Jul 2022 06:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657113584; cv=none; d=google.com; s=arc-20160816; b=K7ZdMD4Xc8wIsbhfM6cG3PrYdV3Kx6894ibAgqxzeTsnO4KHemp/ad+wMr8TpuDJe5 xoSOFljtDyyHJsjbBeWU6PyBskSrUhLwTs7ubPxLnmH0qHMQGgAWHO0Hy1RiPzAboVbz QVfDipq3ocibk+W17LucwgKAP6rWUYb1zeU9NZJlCMcZkpw/hoDdRYTlADU+cF4PKuF4 YnSFqD/oWM5KVxznHWsqkYTh2sRZK6Qkpxjr6UJ/FasACMolacfT/o/czu/MvuQv01Pe obtcwOJ6pcO0/G+6allXMawOKqy9x2Ki1/gAdR9fIuPF8QjHh8ZWfK+xpe4daXBwBwkg WVYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LYDFC69XMHe6JxrxfXEjA0FQW3NSLxG8t3ZCyZH6aBI=; b=Y3xvWASc7UPMlH0LXPxiQbYDcf3YMwnYOkW6+CxkRiQoUC718L4sNVZqY077eR8Xiy aClHYgpCra2yJDEORLpogQ4s0yPXUHSk7q/82KdSSdNoCpRxxkQw1eJdu7AlWYtivHM9 srEEgax4WC5OlbB56iSycj98jUqyBPQ0XADtHrm6zW6Frv01TFEaSTFEcjkDmSOQ091e uQdvnXisVwSBK/Qhw0mDqUrQgFbk4+EfzfoSnBhOtsa99cvfH5xrQ2XJQ0aiTNBHml+I pNn0Ac9jSWWvfIyZnGf+elpjpeyeANLDuqFJ6DLwQEnICM0o39F+B3nKZn25Uyh9t2r0 nDPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synology.com header.s=123 header.b=m7Ed0l9B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synology.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id da26-20020a056402177a00b0043a76c17f47si5815639edb.495.2022.07.06.06.19.19; Wed, 06 Jul 2022 06:19:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@synology.com header.s=123 header.b=m7Ed0l9B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synology.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233312AbiGFNPk (ORCPT + 99 others); Wed, 6 Jul 2022 09:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232052AbiGFNPi (ORCPT ); Wed, 6 Jul 2022 09:15:38 -0400 X-Greylist: delayed 327 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 06 Jul 2022 06:15:37 PDT Received: from synology.com (mail.synology.com [211.23.38.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0137225F1; Wed, 6 Jul 2022 06:15:37 -0700 (PDT) Received: from localhost.localdomain (unknown [10.17.41.204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by synology.com (Postfix) with ESMTPSA id 791051BA2363A; Wed, 6 Jul 2022 21:10:08 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1657113009; bh=7Ow7q0OE+V2ezcJYBI6yuyQyioUIMwsO6+48RC1L7nk=; h=From:To:Cc:Subject:Date; b=m7Ed0l9BZRERmpnawm3hW48qeAx6CZPmQqU1yUuLigny3rB0KkGQFOPeL4ab+y95C V8yaOC/s2C4fsap0zGApsqOZiGmxhJfw8eYr47D5NvlXQEXuZ5NKPrZB21+P4i336R uzosslY0weE22GBQRtgQlc8SsX7DCUpG2hDpmhlk= From: bingjingc To: josef@toxicpanda.com, dsterba@suse.com, clm@fb.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: bingjingc@synology.com, robbieko@synology.com, bxxxjxxg@gmail.com Subject: [PATCH 0/2] btrfs: send: fix a bug that sending a link command on existing file path Date: Wed, 6 Jul 2022 21:09:01 +0800 Message-Id: <20220706130903.1661-1-bingjingc@synology.com> X-Mailer: git-send-email 2.37.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Synology-MCP-Status: no X-Synology-Spam-Flag: no X-Synology-Spam-Status: score=0, required 6, WHITELIST_FROM_ADDRESS 0 X-Synology-Virus-Status: no X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: BingJing Chang btrfs_ioctl_send processes recorded btrfs_keys in a defined order. (First, we process a btrfs_key with a samller objectid. If btrfs_keys have the same objectid, then we compare their types and offsets accordingly.) However, reference paths for an inode can be stored in either BTRFS_INODE_REF_KEY btrfs_keys or BTRFS_INODE_EXTREF_KEY btrfs_keys. And due to the limitation of the helper function - iterate_inode_ref, we can only iterate the entries of ONE btrfs_inode_ref or btrfs_inode_extref. That is, there must be a bug in processing the same reference paths, which are stored in different ways. Please see the second commit for the details. bingjingc (2): btrfs: send: introduce recorded_ref_alloc and recorded_ref_free btrfs: send: fix a bug that sending a link command on existing file path fs/btrfs/send.c | 194 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 180 insertions(+), 14 deletions(-) -- 2.37.0