[1/2] quota: fixup *_write_file_info() to return proper error code

Message ID 20230227120216.31306-1-frank.li@vivo.com
State New
Headers
Series [1/2] quota: fixup *_write_file_info() to return proper error code |

Commit Message

李扬韬 Feb. 27, 2023, 12:02 p.m. UTC
  For v1_write_file_info function, when quota_write() returns 0,
it should be considered an EIO error. And for v2_write_file_info(),
fix to proper error return code instead of raw number.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/quota/quota_v1.c | 2 +-
 fs/quota/quota_v2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

Jan Kara Feb. 28, 2023, 10:35 a.m. UTC | #1
On Mon 27-02-23 20:02:15, Yangtao Li wrote:
> For v1_write_file_info function, when quota_write() returns 0,
> it should be considered an EIO error. And for v2_write_file_info(),
> fix to proper error return code instead of raw number.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Thanks! Both patches look good now. I'll queue them into my tree.

								Honza

> ---
>  fs/quota/quota_v1.c | 2 +-
>  fs/quota/quota_v2.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
> index cd92e5fa0062..a0db3f195e95 100644
> --- a/fs/quota/quota_v1.c
> +++ b/fs/quota/quota_v1.c
> @@ -206,7 +206,7 @@ static int v1_write_file_info(struct super_block *sb, int type)
>  	      sizeof(struct v1_disk_dqblk), v1_dqoff(0));
>  	if (ret == sizeof(struct v1_disk_dqblk))
>  		ret = 0;
> -	else if (ret > 0)
> +	else if (ret >= 0)
>  		ret = -EIO;
>  out:
>  	up_write(&dqopt->dqio_sem);
> diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
> index b1467f3921c2..ae99e7b88205 100644
> --- a/fs/quota/quota_v2.c
> +++ b/fs/quota/quota_v2.c
> @@ -212,7 +212,7 @@ static int v2_write_file_info(struct super_block *sb, int type)
>  	up_write(&dqopt->dqio_sem);
>  	if (size != sizeof(struct v2_disk_dqinfo)) {
>  		quota_error(sb, "Can't write info structure");
> -		return -1;
> +		return size < 0 ? size : -EIO;
>  	}
>  	return 0;
>  }
> -- 
> 2.25.1
>
  

Patch

diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
index cd92e5fa0062..a0db3f195e95 100644
--- a/fs/quota/quota_v1.c
+++ b/fs/quota/quota_v1.c
@@ -206,7 +206,7 @@  static int v1_write_file_info(struct super_block *sb, int type)
 	      sizeof(struct v1_disk_dqblk), v1_dqoff(0));
 	if (ret == sizeof(struct v1_disk_dqblk))
 		ret = 0;
-	else if (ret > 0)
+	else if (ret >= 0)
 		ret = -EIO;
 out:
 	up_write(&dqopt->dqio_sem);
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index b1467f3921c2..ae99e7b88205 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -212,7 +212,7 @@  static int v2_write_file_info(struct super_block *sb, int type)
 	up_write(&dqopt->dqio_sem);
 	if (size != sizeof(struct v2_disk_dqinfo)) {
 		quota_error(sb, "Can't write info structure");
-		return -1;
+		return size < 0 ? size : -EIO;
 	}
 	return 0;
 }