summaryrefslogtreecommitdiffstats
path: root/fs/quota
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-08-17 19:20:28 +0200
committerJan Kara <jack@suse.cz>2017-08-17 19:20:28 +0200
commitf98bbe37ae96873ce93f36f4cdc7b47d85cc4455 (patch)
tree129500e998d7b2dc7e847005b91dac865b6be580 /fs/quota
parentcb8d01b4f624bbf34fd82cbca19e34a22d1eeef6 (diff)
downloadlinux-stable-f98bbe37ae96873ce93f36f4cdc7b47d85cc4455.tar.gz
linux-stable-f98bbe37ae96873ce93f36f4cdc7b47d85cc4455.tar.bz2
linux-stable-f98bbe37ae96873ce93f36f4cdc7b47d85cc4455.zip
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>
Diffstat (limited to 'fs/quota')
-rw-r--r--fs/quota/quota_v2.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index 21a8bdf7cfec..cdbf71664cdc 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -65,9 +65,11 @@ static int v2_read_header(struct super_block *sb, int type,
if (size != sizeof(struct v2_disk_dqheader)) {
quota_error(sb, "Failed header read: expected=%zd got=%zd",
sizeof(struct v2_disk_dqheader), size);
- return 0;
+ if (size < 0)
+ return size;
+ return -EIO;
}
- return 1;
+ return 0;
}
/* Check whether given file is really vfsv0 quotafile */
@@ -77,7 +79,7 @@ static int v2_check_quota_file(struct super_block *sb, int type)
static const uint quota_magics[] = V2_INITQMAGICS;
static const uint quota_versions[] = V2_INITQVERSIONS;
- if (!v2_read_header(sb, type, &dqhead))
+ if (v2_read_header(sb, type, &dqhead))
return 0;
if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] ||
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)
int ret;
down_read(&dqopt->dqio_sem);
- if (!v2_read_header(sb, type, &dqhead)) {
- ret = -EIO;
+ ret = v2_read_header(sb, type, &dqhead);
+ if (ret < 0)
goto out;
- }
version = le32_to_cpu(dqhead.dqh_version);
if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) ||
(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)
sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
if (size != sizeof(struct v2_disk_dqinfo)) {
quota_error(sb, "Can't read info structure");
- ret = -EIO;
+ if (size < 0)
+ ret = size;
+ else
+ ret = -EIO;
goto out;
}
info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);