From patchwork Wed Sep 12 20:49:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 10597465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32C8813BF for ; Wed, 12 Sep 2018 12:49:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2465929E96 for ; Wed, 12 Sep 2018 12:49:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18DFA29EB2; Wed, 12 Sep 2018 12:49:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE9CC29E96 for ; Wed, 12 Sep 2018 12:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbeILRyM (ORCPT ); Wed, 12 Sep 2018 13:54:12 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34145 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbeILRyM (ORCPT ); Wed, 12 Sep 2018 13:54:12 -0400 Received: by mail-pg1-f195.google.com with SMTP id d19-v6so1029947pgv.1 for ; Wed, 12 Sep 2018 05:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2rDzUBiAXq8WeOya5qKO0dSqC2zbQBO5oRNMD/vUpdo=; b=fWf24rg8s3OZihlyU3TFGdUrm11opc4OD5661KCiQt9Z/+9z2fAJf+w47I0qbmMPev F4xMSZkK8FYh9zzZjEl7plT2fgfbPvwyep1gN9NkjxYYpaSyMzv+T3FT/sHKhB5t1ukO obYtKOe5YlNmcDFKD1hD/D5YN/PpsYf5xC5sFd2sX6l6zVC6WPA4Q/2TvFfWf4Y2Hq/6 TyQY0PuZI4DoYu6y1cEjJjV0+M4bt3pMF0IeENH7heLOJauCYx3aMVzLhxlOUc48EJp4 2PkyMHaB78Uc5msc23XWw4dJG629x8YeJNI0aC975K5CrLVC5+jEjPsPVrWPdJnVhDIB fu7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2rDzUBiAXq8WeOya5qKO0dSqC2zbQBO5oRNMD/vUpdo=; b=hdzIz3yOwhjBqnDrNinRQfURapjCO/feZ7OESk4GZjLeQ2f6wMf/7i/NMIyJIk1AwN TAg7bLqbIqv9+N24q7uY+g3hpiw5J2Jghpq8X5gtiXrvCE7S0xwyIojDLlytNzOz2xM7 ZJTSBZHqHY1SG4TcCGVrOGE76xXII/osH5e5QgfJDx00GuNcS7hDSGh1Tc3r9nEPZ77u VGjF/6VQbiT+Bgm3+MDtg+RU1UFTeCZRLWbsSTrjCTPnV7hk9WLlbC0wn6ht+GR60IFK +P+oWZ28O8Yzq8KZVYSR1nInb5EWw94pHpj7jvKd05a9y0waP9QP0sMXG++z4qDn7acv 9Kqw== X-Gm-Message-State: APzg51CY1Ld2myOfcfHT/JMZgv99eL8u42pnSDd6UvBbfpYpvc+DS5oh jbPrM5Odq2qyReHDHDnC019HVr2j X-Google-Smtp-Source: ANB0VdbG6oW0B3I5bQ0WSxno08UpghSAUi0G9kxrZv7eUeTMDnahrjSmcGpjHb1sdFbN5FaO+T7iyw== X-Received: by 2002:a63:9809:: with SMTP id q9-v6mr2104766pgd.58.1536756589601; Wed, 12 Sep 2018 05:49:49 -0700 (PDT) Received: from cat-arch.lan (li1862-137.members.linode.com. [172.105.208.137]) by smtp.gmail.com with ESMTPSA id w12-v6sm1739393pfd.110.2018.09.12.05.49.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 05:49:48 -0700 (PDT) From: damenly.su@gmail.com X-Google-Original-From: suy.fnst@cn.fujitsu.com To: linux-btrfs@vger.kernel.org Cc: suy.fnst@cn.fujitsu.com Subject: [PATCH v2 2/7] btrfs-progs: make btrfs_unlink() lookup inode_extref Date: Wed, 12 Sep 2018 20:49:19 +0000 Message-Id: <20180912204924.10089-3-suy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180912204924.10089-1-suy.fnst@cn.fujitsu.com> References: <20180912204924.10089-1-suy.fnst@cn.fujitsu.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Su Yue btrfs_unlink() uses btrfs_lookup_inode_ref() to look up inode_ref but forget inode_extref case. Let btrfs_unlink() call btrfs_lookup_inode_extref() if inode_ref is found and EXTENDED_IREF feature is enabled. Fixes: 0cc75eddd093 ("btrfs-progs: Add btrfs_unlink() and btrfs_add_link() functions.") Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- inode.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/inode.c b/inode.c index 2398bca4a109..598ad0ab6b4c 100644 --- a/inode.c +++ b/inode.c @@ -277,6 +277,7 @@ int btrfs_unlink(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_key key; struct btrfs_inode_item *inode_item; struct btrfs_inode_ref *inode_ref; + struct btrfs_inode_extref *inode_extref = NULL; struct btrfs_dir_item *dir_item; u64 inode_size; u32 nlinks; @@ -296,7 +297,18 @@ int btrfs_unlink(struct btrfs_trans_handle *trans, struct btrfs_root *root, ret = PTR_ERR(inode_ref); goto out; } - if (inode_ref) + + if (!inode_ref && btrfs_fs_incompat(root->fs_info, EXTENDED_IREF)) { + btrfs_release_path(path); + inode_extref = btrfs_lookup_inode_extref(trans, root, path, + name, namelen, ino, parent_ino, 0); + if (IS_ERR(inode_extref)) { + ret = PTR_ERR(inode_extref); + goto out; + } + } + + if (inode_ref || inode_extref) del_inode_ref = 1; btrfs_release_path(path);