linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erez Zadok <ezk@cs.sunysb.edu>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	viro@ftp.linux.org.uk, hch@infradead.org,
	"Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>,
	Erez Zadok <ezk@cs.sunysb.edu>
Subject: [PATCH 01/25] Unionfs: Simplify unionfs_get_nlinks
Date: Tue, 25 Sep 2007 23:09:40 -0400	[thread overview]
Message-ID: <1190776205713-git-send-email-ezk@cs.sunysb.edu> (raw)
In-Reply-To: <11907762042481-git-send-email-ezk@cs.sunysb.edu>

From: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>

Since we set the right value for d_type in readdir, there's really no point
in having to calculate the number of directory links.  Some on-disk
filesystems don't even store the number of links for directories.

Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
---
 fs/unionfs/subr.c |   41 +++++++----------------------------------
 1 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/fs/unionfs/subr.c b/fs/unionfs/subr.c
index b7e7904..6b93b64 100644
--- a/fs/unionfs/subr.c
+++ b/fs/unionfs/subr.c
@@ -188,16 +188,10 @@ out:
 }
 
 /*
- * returns the sum of the n_link values of all the underlying inodes of the
- * passed inode
+ * returns the right n_link value based on the inode type
  */
 int unionfs_get_nlinks(const struct inode *inode)
 {
-	int sum_nlinks = 0;
-	int dirs = 0;
-	int bindex;
-	struct inode *lower_inode;
-
 	/* don't bother to do all the work since we're unlinked */
 	if (inode->i_nlink == 0)
 		return 0;
@@ -205,33 +199,12 @@ int unionfs_get_nlinks(const struct inode *inode)
 	if (!S_ISDIR(inode->i_mode))
 		return unionfs_lower_inode(inode)->i_nlink;
 
-	for (bindex = ibstart(inode); bindex <= ibend(inode); bindex++) {
-		lower_inode = unionfs_lower_inode_idx(inode, bindex);
-
-		/* ignore files */
-		if (!lower_inode || !S_ISDIR(lower_inode->i_mode))
-			continue;
-
-		BUG_ON(lower_inode->i_nlink < 0);
-
-		/* A deleted directory. */
-		if (lower_inode->i_nlink == 0)
-			continue;
-		dirs++;
-
-		/*
-		 * A broken directory...
-		 *
-		 * Some filesystems don't properly set the number of links
-		 * on empty directories
-		 */
-		if (lower_inode->i_nlink == 1)
-			sum_nlinks += 2;
-		else
-			sum_nlinks += (lower_inode->i_nlink - 2);
-	}
-
-	return (!dirs ? 0 : sum_nlinks + 2);
+	/*
+	 * For directories, we return 1. The only place that could cares
+	 * about links is readdir, and there's d_type there so even that
+	 * doesn't matter.
+	 */
+	return 1;
 }
 
 /* construct whiteout filename */
-- 
1.5.2.2


  reply	other threads:[~2007-09-26  3:33 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26  3:09 [GIT PULL -mm] 00/25 Unionfs updates/cleanups/fixes Erez Zadok
2007-09-26  3:09 ` Erez Zadok [this message]
2007-09-26  3:09 ` [PATCH 02/25] Unionfs: Remove unused #defines Erez Zadok
2007-09-26  3:09 ` [PATCH 03/25] Unionfs: display informational messages only if debug is on Erez Zadok
2007-09-26  8:36   ` Jan Engelhardt
2007-09-26 14:01     ` Erez Zadok
2007-09-26 15:24       ` Jan Engelhardt
2007-09-26 15:28         ` Erez Zadok
2007-09-26  3:09 ` [PATCH 04/25] Unionfs: cache-coherency fixes Erez Zadok
2007-09-26  3:09 ` [PATCH 05/25] Unionfs: cast page->index loff_t before shifting Erez Zadok
2007-09-26  8:31   ` Christoph Hellwig
2007-09-26 13:44     ` Erez Zadok
2007-09-26  3:09 ` [PATCH 06/25] Unionfs: minor coding style updates Erez Zadok
2007-09-26  3:09 ` [PATCH 07/25] Unionfs: add lower nameidata debugging support Erez Zadok
2007-09-26  3:09 ` [PATCH 08/25] Unionfs: lower nameidata support for nfsv4 Erez Zadok
2007-09-26  3:09 ` [PATCH 09/25] Unionfs: add un/likely conditionals on common fileops Erez Zadok
2007-09-26  3:09 ` [PATCH 10/25] Unionfs: add un/likely conditionals on copyup ops Erez Zadok
2007-09-26  4:32   ` Kok, Auke
2007-09-26 13:40     ` Erez Zadok
2007-09-26 15:23       ` Kyle Moffett
2007-09-26 15:43         ` Erez Zadok
2007-09-26 16:47           ` Jan Engelhardt
2007-09-26 16:51             ` Erez Zadok
2007-09-26 18:34       ` Adrian Bunk
2007-09-26  3:09 ` [PATCH 11/25] Unionfs: add un/likely conditionals on debug ops Erez Zadok
2007-09-26 21:34   ` roel
2007-09-26  3:09 ` [PATCH 12/25] Unionfs: add un/likely conditionals on dentry ops Erez Zadok
2007-09-26  3:09 ` [PATCH 13/25] Unionfs: add un/likely conditionals on dir ops Erez Zadok
2007-09-26 21:40   ` roel
2007-09-27 14:28     ` Erez Zadok
2007-09-26  3:09 ` [PATCH 14/25] Unionfs: add un/likely conditionals on headers Erez Zadok
2007-09-26  3:09 ` [PATCH 15/25] Unionfs: add un/likely conditionals on fileops Erez Zadok
2007-09-26  3:09 ` [PATCH 16/25] Unionfs: add un/likely conditionals on inode ops Erez Zadok
2007-09-26  3:09 ` [PATCH 17/25] Unionfs: add un/likely conditionals on lookup ops Erez Zadok
2007-09-26  3:09 ` [PATCH 18/25] Unionfs: add un/likely conditionals on super ops Erez Zadok
2007-09-26  3:09 ` [PATCH 19/25] Unionfs: add un/likely conditionals on mmap ops Erez Zadok
2007-09-26  3:09 ` [PATCH 20/25] Unionfs: add un/likely conditionals on rename ops Erez Zadok
2007-09-26  3:10 ` [PATCH 21/25] Unionfs: add un/likely conditionals on readdir ops Erez Zadok
2007-09-26  3:10 ` [PATCH 22/25] Unionfs: add un/likely conditionals on common subr Erez Zadok
2007-09-26  3:10 ` [PATCH 23/25] Unionfs: add un/likely conditionals on unlink ops Erez Zadok
2007-09-26  3:10 ` [PATCH 24/25] Unionfs: add un/likely conditionals on xattr ops Erez Zadok
2007-09-26  3:10 ` [PATCH 25/25] Unionfs: use poison.h for safe poison pointers Erez Zadok

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1190776205713-git-send-email-ezk@cs.sunysb.edu \
    --to=ezk@cs.sunysb.edu \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=jsipek@cs.sunysb.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).