Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp379169rwb; Thu, 11 Aug 2022 03:17:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR7+gyWWt6rP+Dz0pVG4R8+nMec7GaBNz2dGxAxFhFnE31kWWouu4d9jRmYu5Te2kE8d7+Wq X-Received: by 2002:a05:6402:42ca:b0:43e:3f8d:faf3 with SMTP id i10-20020a05640242ca00b0043e3f8dfaf3mr30848532edc.122.1660213053088; Thu, 11 Aug 2022 03:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660213053; cv=none; d=google.com; s=arc-20160816; b=vhhK4/sIbGVrKkWryJpFK4AvWTAVomZhnudUGo6lgWegc2Egn7FnMpK9MtNnWmVK4r R2SIqotdlc5eIbTPRTvnfc2Xm+llsOagyUNL4NLSyCYKB35Dc/qhmhFEzRtWUXY5siaW 89AxrIQSzsVqPIzu+9gkmtwBA5qFdf8fPbhaRcB3sXB6/YC4AGvXBGQdif7w8h/kxtmr ByAL2SMP76CaRAQ1c85WaTUMxE8ITOyvgub7t6A8RZXqAGw9HL4YBiM56ewlU/6THIpZ 4xl3lUZ9RSpMYy2WyMegFOY8fF9u9ZKcmZ/3DZ6oir9Zlo1wNEkYnCBTeZx+T1FKujzz fPJg== 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=s7apvmPndVQ6qx35FML1j9YXmtZVzx3z1Izipoxr1Zw=; b=CYSGcNoEKeX+3mbbUJHLahJ3ZoCDl4zoMKCFj/RQ5RuWPcxxJcaS94fSjDbVdaLAGz eC8/HAfW4A1tmbJP5m3PcRpMa1tF77hNWu7awB5/hs3vpEE81gF9fuy4aGkxlGXnbGXL +qYfD6vhP7J05C+B5Fj3LVOAn6NC/RpzWbRGj4Pb9vH3otrttc0wYo3YAG/7GoyDYuq0 lriSytvlQ217X/KI13eSOuhou8/TgdhegzqNkxRBkK8/tfiV5sz2z4G5hZrPBpzip4DR TibUZiarLqbssXip9g2fe1koCVeCj53I0YJWx91Wdskvglvad25P4qXYXjlPcU58PHIN wpww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synology.com header.s=123 header.b=BEkyajqE; 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 qc25-20020a170906d8b900b0072ee40a2056si6818792ejb.862.2022.08.11.03.17.07; Thu, 11 Aug 2022 03:17:33 -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=BEkyajqE; 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 S234712AbiHKKJ3 (ORCPT + 99 others); Thu, 11 Aug 2022 06:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229594AbiHKKJ1 (ORCPT ); Thu, 11 Aug 2022 06:09:27 -0400 Received: from synology.com (mail.synology.com [211.23.38.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E43B490C75; Thu, 11 Aug 2022 03:09:25 -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 4AF2F2C86848D; Thu, 11 Aug 2022 18:09:23 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1660212564; bh=uv86+t4HgCDX8AgiBqiKnXGoEwaie1XcX3Kph50O2KQ=; h=From:To:Cc:Subject:Date; b=BEkyajqEU0N2G0wBYg6XsEOvisCXW/MfXaECfBnwDg5bbMekIfpVBKYlWaMeJC794 0Rwue/BU4409/cOHpSzsnT12wRXE19isWB7E2ZR6S9318xz87cVoWqQTxlxtVtJzEz rXNGqv0K5Md11vm6JO5MMC2MKG5PVLlsZOkTES7U= From: bingjingc To: fdmanana@kernel.org, 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 v2 0/2] btrfs: send: fix failures when processing inodes with no links Date: Thu, 11 Aug 2022 18:09:10 +0800 Message-Id: <20220811100912.126447-1-bingjingc@synology.com> X-Mailer: git-send-email 2.37.1 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 There is a bug causing send failures when processing an orphan directory with no links. In commit 46b2f4590aab ("Btrfs: fix send failure when root has deleted files still open")', the orphan inode issue was addressed. The send operation fails with a ENOENT error because of any attempts to generate a path for the inode with a link count of zero. Therefore, in that patch, sctx->ignore_cur_inode was introduced to be set if the current inode has a link count of zero for bypassing some unnecessary steps. And a helper function btrfs_unlink_all_paths() was introduced and called to clean up old paths found in the parent snapshot. However, not only regular files but also directories can be orphan inodes. So if the send operation meets an orphan directory, it will issue a wrong unlink command for that directory now. Soon the receive operation fails with a EISDIR error. Besides, the send operation also fails with a ENOENT error later when it tries to generate a path of it. BingJing Chang (2): btrfs: send: refactor get_inode_info() btrfs: send: fix failures when processing inodes with no links fs/btrfs/send.c | 364 +++++++++++++++++++++--------------------------- 1 file changed, 162 insertions(+), 202 deletions(-) -- 2.37.1