From: "zhangyi (F)" <yi.zhang@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>,
<yi.zhang@huawei.com>, <miaoxie@huawei.com>
Subject: [e2fsprogs PATCH] libsupport: fix error handling in quota_write_inode
Date: Mon, 24 Jul 2017 15:01:26 +0800 [thread overview]
Message-ID: <1500879686-741-1-git-send-email-yi.zhang@huawei.com> (raw)
The error return value of quota_file_create() is no longer < 0,
and the error handling in quota_write_inode() is incorrect,
fix these. This also fix a tune2fs segfault that currently
occurs when we add project and quota features to an inode
exhaustion ext4 filesystem.
Fixes: a701823a3150("libsupport: fix gcc -Wall nits")
Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
---
lib/support/mkquota.c | 15 ++++++++-------
lib/support/quotaio.c | 8 +++++---
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c
index 11a878e..00f3a40 100644
--- a/lib/support/mkquota.c
+++ b/lib/support/mkquota.c
@@ -193,20 +193,21 @@ errcode_t quota_write_inode(quota_ctx_t qctx, unsigned int qtype_bits)
continue;
retval = quota_file_create(h, fs, qtype, fmt);
- if (retval < 0) {
- log_debug("Cannot initialize io on quotafile");
- continue;
+ if (retval) {
+ log_debug("Cannot initialize io on quotafile: %s",
+ error_message(retval));
+ goto out;
}
write_dquots(dict, h);
retval = quota_file_close(qctx, h);
- if (retval < 0) {
- log_err("Cannot finish IO on new quotafile: %s",
- strerror(errno));
+ if (retval) {
+ log_debug("Cannot finish IO on new quotafile: %s",
+ strerror(errno));
if (h->qh_qf.e2_file)
ext2fs_file_close(h->qh_qf.e2_file);
(void) quota_inode_truncate(fs, h->qh_qf.ino);
- continue;
+ goto out;
}
/* Set quota inode numbers in superblock. */
diff --git a/lib/support/quotaio.c b/lib/support/quotaio.c
index 240eab3..2daf178 100644
--- a/lib/support/quotaio.c
+++ b/lib/support/quotaio.c
@@ -273,11 +273,13 @@ errcode_t quota_file_open(quota_ctx_t qctx, struct quota_handle *h,
if (h->qh_ops->check_file &&
(h->qh_ops->check_file(h, qtype, fmt) == 0)) {
log_err("qh_ops->check_file failed");
+ err = EIO;
goto errout;
}
if (h->qh_ops->init_io && (h->qh_ops->init_io(h) < 0)) {
log_err("qh_ops->init_io failed");
+ err = EIO;
goto errout;
}
if (allocated_handle)
@@ -288,7 +290,7 @@ errout:
ext2fs_file_close(e2_file);
if (allocated_handle)
ext2fs_free_mem(&h);
- return -1;
+ return err;
}
static errcode_t quota_inode_init_new(ext2_filsys fs, ext2_ino_t ino)
@@ -405,12 +407,12 @@ errcode_t quota_file_close(quota_ctx_t qctx, struct quota_handle *h)
{
if (h->qh_io_flags & IOFL_INFODIRTY) {
if (h->qh_ops->write_info && h->qh_ops->write_info(h) < 0)
- return -1;
+ return EIO;
h->qh_io_flags &= ~IOFL_INFODIRTY;
}
if (h->qh_ops->end_io && h->qh_ops->end_io(h) < 0)
- return -1;
+ return EIO;
if (h->qh_qf.e2_file) {
__u64 new_size, size;
--
2.5.0
next reply other threads:[~2017-07-24 6:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 7:01 zhangyi (F) [this message]
2017-07-24 19:17 ` [e2fsprogs PATCH] libsupport: fix error handling in quota_write_inode Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1500879686-741-1-git-send-email-yi.zhang@huawei.com \
--to=yi.zhang@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).