From patchwork Sat Jan 23 20:38:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 74929 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0NKdZKw023590 for ; Sat, 23 Jan 2010 20:39:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752879Ab0AWUi2 (ORCPT ); Sat, 23 Jan 2010 15:38:28 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751977Ab0AWUiZ (ORCPT ); Sat, 23 Jan 2010 15:38:25 -0500 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:48978 "EHLO e28smtp09.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752136Ab0AWUiV (ORCPT ); Sat, 23 Jan 2010 15:38:21 -0500 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp09.in.ibm.com (8.14.3/8.13.1) with ESMTP id o0NK66FU026950 for ; Sun, 24 Jan 2010 01:36:06 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o0NKcJVn1556494 for ; Sun, 24 Jan 2010 02:08:19 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o0NKcIRa024325 for ; Sun, 24 Jan 2010 07:38:18 +1100 Received: from localhost.localdomain ([9.77.206.84]) by d28av04.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o0NKcGoN024304; Sun, 24 Jan 2010 07:38:18 +1100 From: "Aneesh Kumar K.V" To: chris.mason@oracle.com Cc: linux-btrfs@vger.kernel.org, "Aneesh Kumar K.V" Subject: [PATCH 3/3] btrfs: Update the directory link count correctly Date: Sun, 24 Jan 2010 02:08:09 +0530 Message-Id: <1264279089-14913-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.6.1.394.gdedc0 In-Reply-To: <1264279089-14913-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1264279089-14913-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9a56b3b..12b9d6e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2703,8 +2703,17 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) dentry->d_name.name, dentry->d_name.len); if (!err) { btrfs_i_size_write(inode, 0); - btrfs_drop_nlink(inode); + /* + * Directories have link count 2. + */ + btrfs_clear_nlink(dentry->d_inode); btrfs_update_inode(trans, root, inode); + /* + * If we are removing a directory drop the link count from + * the parent directory + */ + btrfs_drop_nlink(dir); + btrfs_update_inode(trans, root, dir); } out: nr = trans->blocks_used;