diff mbox

ext4: ext4_orphan_add() remove unnecessary comments

Message ID 1309272617-30943-1-git-send-email-lczerner@redhat.com
State Accepted, archived
Headers show

Commit Message

Lukas Czerner June 28, 2011, 2:50 p.m. UTC
The comment from Al Viro about possible race in the ext4_orphan_add() is
not justified. There is no race possible as we always have either i_mutex
locked, or the inode can not be referenced from outside hence the
J_ASSERS should not be hit from the reason described in comment.

This commit replaces it with notion that we are holding i_mutex so it
should not be possible for i_nlink to be changed while waiting for
s_orphan_lock.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 fs/ext4/namei.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

Comments

Theodore Ts'o July 11, 2011, 10:47 p.m. UTC | #1
On Tue, Jun 28, 2011 at 04:50:17PM +0200, Lukas Czerner wrote:
> The comment from Al Viro about possible race in the ext4_orphan_add() is
> not justified. There is no race possible as we always have either i_mutex
> locked, or the inode can not be referenced from outside hence the
> J_ASSERS should not be hit from the reason described in comment.
> 
> This commit replaces it with notion that we are holding i_mutex so it
> should not be possible for i_nlink to be changed while waiting for
> s_orphan_lock.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>

Applied, thanks.

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index b754b77..8dde5ab 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1989,18 +1989,11 @@  int ext4_orphan_add(handle_t *handle, struct inode *inode)
 	if (!list_empty(&EXT4_I(inode)->i_orphan))
 		goto out_unlock;
 
-	/* Orphan handling is only valid for files with data blocks
-	 * being truncated, or files being unlinked. */
-
-	/* @@@ FIXME: Observation from aviro:
-	 * I think I can trigger J_ASSERT in ext4_orphan_add().  We block
-	 * here (on s_orphan_lock), so race with ext4_link() which might bump
-	 * ->i_nlink. For, say it, character device. Not a regular file,
-	 * not a directory, not a symlink and ->i_nlink > 0.
-	 *
-	 * tytso, 4/25/2009: I'm not sure how that could happen;
-	 * shouldn't the fs core protect us from these sort of
-	 * unlink()/link() races?
+	/*
+	 * Orphan handling is only valid for files with data blocks
+	 * being truncated, or files being unlinked. Note that we either
+	 * hold i_mutex, or the inode can not be referenced from outside,
+	 * so i_nlink should not be bumped due to race
 	 */
 	J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
 		  S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);