From patchwork Wed Dec 24 06:45:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 5536471 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 255829F2F7 for ; Wed, 24 Dec 2014 06:47:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4939320155 for ; Wed, 24 Dec 2014 06:47:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 528102012D for ; Wed, 24 Dec 2014 06:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751167AbaLXGru (ORCPT ); Wed, 24 Dec 2014 01:47:50 -0500 Received: from mail-pd0-f180.google.com ([209.85.192.180]:51457 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbaLXGru (ORCPT ); Wed, 24 Dec 2014 01:47:50 -0500 Received: by mail-pd0-f180.google.com with SMTP id w10so9386291pde.11 for ; Tue, 23 Dec 2014 22:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=ISzSQ7YlK8OEI8zXnXGwMZ2POkmupiy7458R8LsBxEc=; b=fUM+OD/tLwvCHsik8/gFM3LJBYJWCLoOCYXSItU6v8rdbzVrfOmAFKSAkHW2im5eSe PyHyWsyuM3S3HCR7zx7Bc4sP6CYL/YIUIIbYPnAA3O0MNEpmPB0t5UDZHgSRxaAahShL jvYDJXIrwXyTYIlj3V3VF+qMFrEEWWCSM4s4AU+V09z4PCsxpIZUsBHd/B6ecYLafwxF s5v8ILSA9H10ewE2fMSpjcCvGg0m8+N6mUKjiagYQg2dkJt3J6/SdrBAGbA3YxA4nwcZ t73uIZwEyt6agFfNlkBrRYdILSt8qwutSlyExSkipCqqIgsVuW7tGQEH/GjU/Qgj2zry EX7w== X-Received: by 10.68.189.71 with SMTP id gg7mr50060121pbc.21.1419403669625; Tue, 23 Dec 2014 22:47:49 -0800 (PST) Received: from localhost.localdomain.localdomain ([36.62.181.87]) by mx.google.com with ESMTPSA id w8sm21741816pbt.71.2014.12.23.22.47.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Dec 2014 22:47:49 -0800 (PST) From: Wang Shilong To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: call inode_dec_link_count() on mkdir error path Date: Wed, 24 Dec 2014 14:45:30 +0800 Message-Id: <1419403530-15617-1-git-send-email-wangshilong1991@gmail.com> X-Mailer: git-send-email 1.7.12.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 From: Wang Shilong In btrfs_mkdir(), if it fails to create dir, we should clean up existed items, setting inode's link properly to make sure it could be cleaned up properly. Signed-off-by: Wang Shilong --- fs/btrfs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8de2335..8a036ed 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6255,8 +6255,10 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) out_fail: btrfs_end_transaction(trans, root); - if (drop_on_err) + if (drop_on_err) { + inode_dec_link_count(inode); iput(inode); + } btrfs_balance_delayed_items(root); btrfs_btree_balance_dirty(root); return err;