Skip to content

Commit f98bbe3

Browse files
committed
quota: Propagate ->quota_read errors from v2_read_file_info()
Currently we return -EIO on any error (or short read) from ->quota_read() while reading quota info. Propagate the error code instead. Suggested-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent cb8d01b commit f98bbe3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

fs/quota/quota_v2.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ static int v2_read_header(struct super_block *sb, int type,
6565
if (size != sizeof(struct v2_disk_dqheader)) {
6666
quota_error(sb, "Failed header read: expected=%zd got=%zd",
6767
sizeof(struct v2_disk_dqheader), size);
68-
return 0;
68+
if (size < 0)
69+
return size;
70+
return -EIO;
6971
}
70-
return 1;
72+
return 0;
7173
}
7274

7375
/* Check whether given file is really vfsv0 quotafile */
@@ -77,7 +79,7 @@ static int v2_check_quota_file(struct super_block *sb, int type)
7779
static const uint quota_magics[] = V2_INITQMAGICS;
7880
static const uint quota_versions[] = V2_INITQVERSIONS;
7981

80-
if (!v2_read_header(sb, type, &dqhead))
82+
if (v2_read_header(sb, type, &dqhead))
8183
return 0;
8284
if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] ||
8385
le32_to_cpu(dqhead.dqh_version) > quota_versions[type])
@@ -98,10 +100,9 @@ static int v2_read_file_info(struct super_block *sb, int type)
98100
int ret;
99101

100102
down_read(&dqopt->dqio_sem);
101-
if (!v2_read_header(sb, type, &dqhead)) {
102-
ret = -EIO;
103+
ret = v2_read_header(sb, type, &dqhead);
104+
if (ret < 0)
103105
goto out;
104-
}
105106
version = le32_to_cpu(dqhead.dqh_version);
106107
if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) ||
107108
(info->dqi_fmt_id == QFMT_VFS_V1 && version != 1)) {
@@ -113,7 +114,10 @@ static int v2_read_file_info(struct super_block *sb, int type)
113114
sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
114115
if (size != sizeof(struct v2_disk_dqinfo)) {
115116
quota_error(sb, "Can't read info structure");
116-
ret = -EIO;
117+
if (size < 0)
118+
ret = size;
119+
else
120+
ret = -EIO;
117121
goto out;
118122
}
119123
info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);

0 commit comments

Comments
 (0)