Skip to contentSkip to conversation

fs: fix up error handlers for insert_inode_locked

PATCH Superseded Eric Sandeen 3 participants 12 messages Dec 6, 2011 – Dec 8, 2011

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover fs: fix up error handlers for insert_inode_locked

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set. However, error handlers still call unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

Patches follow to skip the call to unlock_new_inode() if insert_inode_locked() fails.

-Eric

#1 lore raw

PATCH 1/6 ext2: fix up error handling for insert_inode_locked

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

(We also were doing dquot_drop, etc before we had initialized the inode, that gets skipped as well)

---

fs/ext2/ialloc.c +3 -2
index c4e81df..769351a 100644
@@ -574,7 +574,7 @@ got:
 	spin_unlock(&sbi->s_next_gen_lock);
 	if (insert_inode_locked(inode) < 0) {
 		err = -EINVAL;
-		goto fail_drop;
+		goto fail_put;
 	}
 
 	dquot_initialize(inode);
@@ -601,8 +601,9 @@ fail_free_drop:
 fail_drop:
 	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
-	clear_nlink(inode);
 	unlock_new_inode(inode);
+fail_put:
+	clear_nlink(inode);
 	iput(inode);
 	return ERR_PTR(err);
 
#2 lore raw

PATCH v2 1/6 ext2: fix up error handling for insert_inode_locked

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set on failure. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

(We also were doing dquot_drop, etc before we had initialized the quota, that gets skipped as well)

---

V2: don't rearrange clear_nlink, and edit commit message.

fs/ext2/ialloc.c +2 -1
index c4e81df..06cbc22 100644
@@ -574,7 +574,7 @@ got:
 	spin_unlock(&sbi->s_next_gen_lock);
 	if (insert_inode_locked(inode) < 0) {
 		err = -EINVAL;
-		goto fail_drop;
+		goto fail_put;
 	}
 
 	dquot_initialize(inode);
@@ -603,6 +603,7 @@ fail_drop:
 	inode->i_flags |= S_NOQUOTA;
 	clear_nlink(inode);
 	unlock_new_inode(inode);
+fail_put:
 	iput(inode);
 	return ERR_PTR(err);
 
#3 lore raw

PATCH 2/6 ext3: fix up error handling for insert_inode_locked

In reply to Eric Sandeen

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

(We also were doing dquot_drop, etc before we had initialized the quota, that gets skipped as well)

---

fs/ext3/ialloc.c +3 -2
index 5c866e0..7d0493b 100644
@@ -526,7 +526,7 @@ got:
 		handle->h_sync = 1;
 	if (insert_inode_locked(inode) < 0) {
 		err = -EINVAL;
-		goto fail_drop;
+		goto fail_put;
 	}
 	spin_lock(&sbi->s_next_gen_lock);
 	inode->i_generation = sbi->s_next_generation++;
@@ -582,8 +582,9 @@ fail_free_drop:
 fail_drop:
 	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
-	clear_nlink(inode);
 	unlock_new_inode(inode);
+fail_put:
+	clear_nlink(inode);
 	iput(inode);
 	brelse(bitmap_bh);
 	return ERR_PTR(err);
#4 lore raw

PATCH v2 2/6 ext3: fix up error handling for insert_inode_locked

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set on failure. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

(We also were doing dquot_drop, etc before we had initialized the quota, that gets skipped as well)

---

V2: don't rearrange clear_nlink, and edit commit message.

fs/ext3/ialloc.c +2 -1
index 5c866e0..5563d99 100644
@@ -526,7 +526,7 @@ got:
 		handle->h_sync = 1;
 	if (insert_inode_locked(inode) < 0) {
 		err = -EINVAL;
-		goto fail_drop;
+		goto fail_put;
 	}
 	spin_lock(&sbi->s_next_gen_lock);
 	inode->i_generation = sbi->s_next_generation++;
@@ -584,6 +584,7 @@ fail_drop:
 	inode->i_flags |= S_NOQUOTA;
 	clear_nlink(inode);
 	unlock_new_inode(inode);
+fail_put:
 	iput(inode);
 	brelse(bitmap_bh);
 	return ERR_PTR(err);
#5 lore raw

PATCH 3/6 ext4: fix up error handling for insert_inode_locked

In reply to Eric Sandeen

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set on failure. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

(We also were doing dquot_drop, etc before we had initialized the quota, that gets skipped as well)

---

fs/ext4/ialloc.c +3 -2
index 00beb4f..f00c19a 100644
@@ -886,7 +886,7 @@ got:
 		ext4_handle_sync(handle);
 	if (insert_inode_locked(inode) < 0) {
 		err = -EINVAL;
-		goto fail_drop;
+		goto fail_put;
 	}
 	spin_lock(&sbi->s_next_gen_lock);
 	inode->i_generation = sbi->s_next_generation++;
@@ -948,8 +948,9 @@ fail_free_drop:
 fail_drop:
 	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
-	clear_nlink(inode);
 	unlock_new_inode(inode);
+fail_put:
+	clear_nlink(inode);
 	iput(inode);
 	brelse(inode_bitmap_bh);
 	return ERR_PTR(err);
#6 lore raw

PATCH v2 3/6 ext4: fix up error handling for insert_inode_locked

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set on failure. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

(We also were doing dquot_drop, etc before we had initialized the quota, that gets skipped as well)

---

V2: don't rearrange clear_nlink, and edit commit message.

fs/ext4/ialloc.c +2 -1
index 00beb4f..1e0c3bf 100644
@@ -886,7 +886,7 @@ got:
 		ext4_handle_sync(handle);
 	if (insert_inode_locked(inode) < 0) {
 		err = -EINVAL;
-		goto fail_drop;
+		goto fail_put;
 	}
 	spin_lock(&sbi->s_next_gen_lock);
 	inode->i_generation = sbi->s_next_generation++;
@@ -950,6 +950,7 @@ fail_drop:
 	inode->i_flags |= S_NOQUOTA;
 	clear_nlink(inode);
 	unlock_new_inode(inode);
+fail_put:
 	iput(inode);
 	brelse(inode_bitmap_bh);
 	return ERR_PTR(err);
#7 lore raw

PATCH 4/6 jffs2: fix up error handling for insert_inode_locked

In reply to Eric Sandeen

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set on failure. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

We can just drop the unlock_new_inode() if insert_inode_locked() fails here.

---

fs/jffs2/fs.c +0 -1
index 4b8afe3..2e01238 100644
@@ -466,7 +466,6 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
 
 	if (insert_inode_locked(inode) < 0) {
 		make_bad_inode(inode);
-		unlock_new_inode(inode);
 		iput(inode);
 		return ERR_PTR(-EINVAL);
 	}
#8 lore raw

Re: [PATCH 4/6] jffs2: fix up error handling for insert_inode_locked

Quoted 11 lines · Eric Sandeen

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set on failure. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

We can just drop the unlock_new_inode() if insert_inode_locked() fails here.

Pushed to l2-mtd-2.6.git tree, thanks!

Artem.

#9 lore raw

PATCH 5/6 jfs: fix up error handling for insert_inode_locked

In reply to Eric Sandeen

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set on failure. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

---

fs/jfs/jfs_inode.c +1 -2
index c1a3e60..7f464c5 100644
@@ -95,7 +95,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
 
 	if (insert_inode_locked(inode) < 0) {
 		rc = -EINVAL;
-		goto fail_unlock;
+		goto fail_put;
 	}
 
 	inode_init_owner(inode, parent, mode);
@@ -156,7 +156,6 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
 fail_drop:
 	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
-fail_unlock:
 	clear_nlink(inode);
 	unlock_new_inode(inode);
 fail_put:
#10 lore raw

PATCH 6/6 reiserfs: fix up error handling for insert_inode_locked4

In reply to Eric Sandeen

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set on failure. However, the error handler still calls unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

---

(I had a hard time unraveling the gotos, so punted with an "inode_locked" var... prettier replacements are fine with me!)

fs/reiserfs/inode.c +4 -1
index 950f13a..b0cab7c 100644
@@ -1779,6 +1779,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
 	struct cpu_key key;
 	struct item_head ih;
 	struct stat_data sd;
+	int inode_locked = 0;
 	int retval;
 	int err;
 
@@ -1816,6 +1817,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
 		err = -EINVAL;
 		goto out_bad_inode;
 	}
+	inode_locked = 1;
 	if (old_format_only(sb))
 		/* not a perfect generation count, as object ids can be reused, but
 		 ** this is as good as reiserfs can do right now.
@@ -1989,7 +1991,8 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
       out_inserted_sd:
 	clear_nlink(inode);
 	th->t_trans_id = 0;	/* so the caller can't use this handle later */
-	unlock_new_inode(inode); /* OK to do even if we hadn't locked it */
+	if (inode_locked)
+		unlock_new_inode(inode);
 	iput(inode);
 	return err;
 }
#11 lore raw
In reply to Eric Sandeen
Quoted 3 lines · Eric Sandeen

after 250df6ed274d767da844a5d9f05720b804240197
(fs: protect inode->i_state with inode->i_lock), insert_inode_locked() no longer returns the inode with I_NEW set. However, error handlers

Whoops that should say "with I_NEW set on failure"

Will resend for the fs patches I copied that text to :(

-Eric

Quoted 12 lines

still call unlock_new_inode() on failure, which does a WARN_ON if I_NEW is not set, so any failure spews a lot of warnings.

Patches follow to skip the call to unlock_new_inode() if insert_inode_locked() fails.

-Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html