linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: set an error code in ext4_quota_off()
@ 2017-04-21 10:53 Dan Carpenter
  2017-04-24 14:46 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-04-21 10:53 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara; +Cc: Andreas Dilger, linux-ext4, kernel-janitors

We accidentally return success instead of a negative error code on these
paths.

Fixes: 957153fce8d2 ("ext4: Set flags on quota files directly")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 4a32c9279f35..735adca37fdf 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5377,8 +5377,10 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
 
 		inode_lock(inode);
 		handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
-		if (IS_ERR(handle))
+		if (IS_ERR(handle)) {
+			err = PTR_ERR(handle);
 			goto unlock_inode;
+		}
 		EXT4_I(inode)->i_flags |= EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL;
 		inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
 				S_NOATIME | S_IMMUTABLE);
@@ -5478,8 +5480,10 @@ static int ext4_quota_off(struct super_block *sb, int type)
 	/* Update modification times of quota files when userspace can
 	 * start looking at them */
 	handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
-	if (IS_ERR(handle))
+	if (IS_ERR(handle)) {
+		err = PTR_ERR(handle);
 		goto out_unlock;
+	}
 	EXT4_I(inode)->i_flags &= ~(EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL);
 	inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
 	inode->i_mtime = inode->i_ctime = current_time(inode);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: set an error code in ext4_quota_off()
  2017-04-21 10:53 [PATCH] ext4: set an error code in ext4_quota_off() Dan Carpenter
@ 2017-04-24 14:46 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2017-04-24 14:46 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Theodore Ts'o, Jan Kara, Andreas Dilger, linux-ext4,
	kernel-janitors

On Fri 21-04-17 13:53:45, Dan Carpenter wrote:
> We accidentally return success instead of a negative error code on these
> paths.
> 
> Fixes: 957153fce8d2 ("ext4: Set flags on quota files directly")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

So actually this is deliberate. Although setting inode flags fails, we have
already enabled / disabled quotas and so we just return success. Failing to
set the flags is just a loss of safety measure but not a hard failure...
But I guess it deserves a comment so I'll add it.

								Honza

> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 4a32c9279f35..735adca37fdf 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -5377,8 +5377,10 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
>  
>  		inode_lock(inode);
>  		handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
> -		if (IS_ERR(handle))
> +		if (IS_ERR(handle)) {
> +			err = PTR_ERR(handle);
>  			goto unlock_inode;
> +		}
>  		EXT4_I(inode)->i_flags |= EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL;
>  		inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
>  				S_NOATIME | S_IMMUTABLE);
> @@ -5478,8 +5480,10 @@ static int ext4_quota_off(struct super_block *sb, int type)
>  	/* Update modification times of quota files when userspace can
>  	 * start looking at them */
>  	handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
> -	if (IS_ERR(handle))
> +	if (IS_ERR(handle)) {
> +		err = PTR_ERR(handle);
>  		goto out_unlock;
> +	}
>  	EXT4_I(inode)->i_flags &= ~(EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL);
>  	inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
>  	inode->i_mtime = inode->i_ctime = current_time(inode);
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-24 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-21 10:53 [PATCH] ext4: set an error code in ext4_quota_off() Dan Carpenter
2017-04-24 14:46 ` Jan Kara

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).