linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: <linux-ext4@vger.kernel.org>
Cc: Ted Tso <tytso@mit.edu>, Jan Kara <jack@suse.cz>
Subject: [PATCH 03/15] ext4: Do not iput inode under running transaction in ext4_mkdir()
Date: Fri, 27 Sep 2019 13:15:24 +0200	[thread overview]
Message-ID: <20190927111536.16455-4-jack@suse.cz> (raw)
In-Reply-To: <20190927111536.16455-1-jack@suse.cz>

When ext4_mkdir() fails to add entry into directory, it ends up dropping
freshly created inode under the running transaction and thus inode
truncation happens under that transaction. That breaks assumptions that
ext4_evict_inode() does not get called from a transaction context
(although I'm not aware of any real issue) and is completely
unnecessary. Just stop the transaction before dropping inode reference.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/namei.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 129029534075..46e203f100de 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2781,8 +2781,9 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 		clear_nlink(inode);
 		unlock_new_inode(inode);
 		ext4_mark_inode_dirty(handle, inode);
+		ext4_journal_stop(handle);
 		iput(inode);
-		goto out_stop;
+		goto out_retry;
 	}
 	ext4_inc_count(handle, dir);
 	ext4_update_dx_flag(dir);
@@ -2796,6 +2797,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 out_stop:
 	if (handle)
 		ext4_journal_stop(handle);
+out_retry:
 	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
 		goto retry;
 	return err;
-- 
2.16.4


  parent reply	other threads:[~2019-09-27 11:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 11:15 [PATCH 0/15] ext4: Fix transaction overflow due to revoke descriptors Jan Kara
2019-09-27 11:15 ` [PATCH 01/15] jbd2: Fix possible overflow in jbd2_log_space_left() Jan Kara
2019-09-27 11:15 ` [PATCH 02/15] jbd2: Fixup stale comment in commit code Jan Kara
2019-09-27 11:15 ` Jan Kara [this message]
2019-09-27 11:15 ` [PATCH 04/15] ext4: Use ext4_journal_extend() instead of jbd2_journal_extend() Jan Kara
2019-09-27 11:15 ` [PATCH 05/15] jbd2: Reorganize jbd2_journal_stop() Jan Kara
2019-09-27 11:15 ` [PATCH 06/15] jbd2: Drop pointless check from jbd2_journal_stop() Jan Kara
2019-09-27 11:15 ` [PATCH 07/15] jbd2: Drop pointless wakeup " Jan Kara
2019-09-27 11:15 ` [PATCH 08/15] jbd2: Factor out common parts of stopping and restarting a handle Jan Kara
2019-09-27 11:15 ` [PATCH 09/15] jbd2: Account descriptor blocks into t_outstanding_credits Jan Kara
2019-09-27 11:15 ` [PATCH 10/15] jbd2: Drop jbd2_space_needed() Jan Kara
2019-09-27 11:15 ` [PATCH 11/15] jbd2: Reserve space for revoke descriptor blocks Jan Kara
2019-09-27 11:15 ` [PATCH 12/15] ext4: Avoid unnecessary revokes in ext4_alloc_branch() Jan Kara
2019-09-27 11:15 ` [PATCH 13/15] jbd2: Fix statistics for the number of logged blocks Jan Kara
2019-09-27 11:15 ` [PATCH 14/15] ext4: Provide function to handle transaction restarts Jan Kara
2019-09-27 11:15 ` [PATCH 15/15] ext4: Reserve revoke credits for freed blocks Jan Kara

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=20190927111536.16455-4-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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).