All of
 help / color / mirror / Atom feed
From: Jan Kara <>
To: <>
Cc: Ted Tso <>, Jan Kara <>
Subject: [PATCH 1/2] ext4: Make sure quota gets properly shutdown on error
Date: Thu,  7 Oct 2021 17:53:35 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

When we hit an error when enabling quotas and setting inode flags, we do
not properly shutdown quota subsystem despite returning error from
Q_QUOTAON quotactl. This can lead to some odd situations like kernel
using quota file while it is still writeable for userspace. Make sure we
properly cleanup the quota subsystem in case of error.

Signed-off-by: Jan Kara <>
 fs/ext4/super.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 88d5d274a868..fbe9cae63786 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -6267,10 +6267,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
 	lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA);
 	err = dquot_quota_on(sb, type, format_id, path);
-	if (err) {
-		lockdep_set_quota_inode(path->dentry->d_inode,
-					     I_DATA_SEM_NORMAL);
-	} else {
+	if (!err) {
 		struct inode *inode = d_inode(path->dentry);
 		handle_t *handle;
@@ -6290,7 +6287,12 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
+		if (err)
+			dquot_quota_off(sb, type);
+	if (err)
+		lockdep_set_quota_inode(path->dentry->d_inode,
+					     I_DATA_SEM_NORMAL);
 	return err;

  reply	other threads:[~2021-10-07 15:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 15:53 [PATCH 0/2] ext4: Quota enabling error handling fixes Jan Kara
2021-10-07 15:53 ` Jan Kara [this message]
2021-10-07 15:53 ` [PATCH 2/2] ext4: Make sure to reset inode lockdep class when quota enabling fails Jan Kara
2021-12-27  5:34 ` [PATCH 0/2] ext4: Quota enabling error handling fixes Theodore Ts'o

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:

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

  git send-email \ \ \ \ \

* 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.