Skip to contentSkip to conversation

quota: fixup *_write_file_info() to return proper error code

PATCH In review Yangtao Li 2 participants 3 messages Feb 27, 2023 – Feb 28, 2023 Diskquota

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

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

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.

---
 fs/quota/quota_v1.c | 2 +-
 fs/quota/quota_v2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/quota/quota_v1.c +1 -1
index cd92e5fa0062..a0db3f195e95 100644
@@ -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);
fs/quota/quota_v2.c +1 -1
index b1467f3921c2..ae99e7b88205 100644
@@ -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;
 }
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 quota: make dquot_set_dqinfo return errors from ->write_info

dquot_set_dqinfo() ignores the return code from the ->write_info call, which means that quotacalls like Q_SETINFO never see the error. This doesn't seem right, so fix that.

---
 fs/quota/dquot.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/quota/dquot.c +1 -3
index f27faf5db554..be702905c74f 100644
@@ -2819,7 +2819,6 @@ EXPORT_SYMBOL(dquot_get_state);
 int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii)
 {
 	struct mem_dqinfo *mi;
-	int err = 0;
 
 	if ((ii->i_fieldmask & QC_WARNS_MASK) ||
 	    (ii->i_fieldmask & QC_RT_SPC_TIMER))
@@ -2846,8 +2845,7 @@ int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii)
 	spin_unlock(&dq_data_lock);
 	mark_info_dirty(sb, type);
 	/* Force write to disk */
-	sb->dq_op->write_info(sb, type);
-	return err;
+	return sb->dq_op->write_info(sb, type);
 }
 EXPORT_SYMBOL(dquot_set_dqinfo);
 
Signature · 1 line
2.25.1
#2 lore raw
In reply to Yangtao Li
Quoted 5 lines · Yangtao Li

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.

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

Honza

Quoted 34 lines
---
 fs/quota/quota_v1.c | 2 +-
 fs/quota/quota_v2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/quota/quota_v1.c +1 -1
index cd92e5fa0062..a0db3f195e95 100644
@@ -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);
fs/quota/quota_v2.c +1 -1
index b1467f3921c2..ae99e7b88205 100644
@@ -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;
 }
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR