From patchwork Mon Oct 28 17:39:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 3103441 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 38CECBF924 for ; Mon, 28 Oct 2013 17:39:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30C102022A for ; Mon, 28 Oct 2013 17:39:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35A3C2017C for ; Mon, 28 Oct 2013 17:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932206Ab3J1Rjb (ORCPT ); Mon, 28 Oct 2013 13:39:31 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:46317 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932187Ab3J1Rj3 (ORCPT ); Mon, 28 Oct 2013 13:39:29 -0400 Received: by mail-wg0-f49.google.com with SMTP id x12so6843411wgg.4 for ; Mon, 28 Oct 2013 10:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Z7ZvJVXUYQA9tsxb7wWaTXxdiLD9qTwydUTc19Ersi4=; b=KCoE3wiYp7FK2uipBdKL9EqkYbSaL1Xj3Ze959iRkOH8tKboIB1B6bPysKQq+Aaj3k WkCjhOCn/PnXed2y5QeSNudbLlywrJTTp8TxmaAzJRVTzuyy4tivGaXbRV8UU7r4tDLE 0NcjPSIztLcBhQGSBhL9ja2R+hoyrE7skeYGRLYKHkMmsPyYkfGREbreS7EiPOqkIs0k rf3uDPnG6y2tUBEezcXZuK2eAvhu/Dd2wXbNQ0rYIWBrIgRYP57rBh5YaIfGnoj38dZv I/vhhC4J/iJ2jESefxBsWE0OrdTYD5EB9sJSXlYv4jlmLfocoBqN3mYDdz3mJtZliAQc YLVA== X-Received: by 10.180.91.101 with SMTP id cd5mr10106343wib.50.1382981968555; Mon, 28 Oct 2013 10:39:28 -0700 (PDT) Received: from storm-desktop.lan (bl5-244-40.dsl.telepac.pt. [82.154.244.40]) by mx.google.com with ESMTPSA id mw9sm26812463wib.0.2013.10.28.10.39.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Oct 2013 10:39:28 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH] Btrfs: log recovery, don't unlink inode always on error Date: Mon, 28 Oct 2013 17:39:21 +0000 Message-Id: <1382981961-18260-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.7.9.5 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.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 If we get any error while doing a dir index/item lookup in the log tree, we were always unlinking the corresponding inode in the subvolume. It makes sense to unlink only if the lookup failed to find the dir index/item, which corresponds to NULL or -ENOENT, and not when other errors happen (like a transient -ENOMEM or -EIO). Signed-off-by: Filipe David Borba Manana --- fs/btrfs/tree-log.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index d75303e..2990fa4 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -1832,7 +1832,7 @@ again: dir_key->offset, name, name_len, 0); } - if (IS_ERR_OR_NULL(log_di)) { + if (!log_di || (IS_ERR(log_di) && PTR_ERR(log_di) == -ENOENT)) { btrfs_dir_item_key_to_cpu(eb, di, &location); btrfs_release_path(path); btrfs_release_path(log_path); @@ -1869,6 +1869,9 @@ again: goto again; ret = 0; goto out; + } else if (IS_ERR(log_di)) { + kfree(name); + return PTR_ERR(log_di); } btrfs_release_path(log_path); kfree(name);