From: Aditya Kali <adityakali@google.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 4/9] quota: fix memory leak in quota_compare_and_update()
Date: Mon, 12 May 2014 23:48:42 -0700 [thread overview]
Message-ID: <CAGr1F2FwRLuAtdrJsU+BHaMF05+rihqYW2MfmPCYj-oMm0McOA@mail.gmail.com> (raw)
In-Reply-To: <1399782773-20029-5-git-send-email-tytso@mit.edu>
On Sat, May 10, 2014 at 9:32 PM, Theodore Ts'o <tytso@mit.edu> wrote:
> The quota_handle wasn't getting closed in quota_compare_and_update().
> Fix this, and also make sure that quota_file_close() doesn't
> unnecessarily modify the quota inode if it's not necessary. Otherwise
> e2fsck will claim that the file system is modified when it didn't need
> to be.
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> Cc: adityakali@google.com
Reviewed-by: Aditya Kali <adityakali@google.com>
Thanks!
> ---
> lib/quota/mkquota.c | 9 ++++++++-
> lib/quota/quotaio.c | 9 +++++++--
> 2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c
> index f5ae0e0..ed10890 100644
> --- a/lib/quota/mkquota.c
> +++ b/lib/quota/mkquota.c
> @@ -597,7 +597,7 @@ errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
> err = qh.qh_ops->scan_dquots(&qh, scan_dquots_callback, &scan_data);
> if (err) {
> log_err("Error scanning dquots");
> - goto out;
> + goto out_close_qh;
> }
>
> for (n = dict_first(dict); n; n = dict_next(dict, n)) {
> @@ -612,6 +612,13 @@ errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
> }
> *usage_inconsistent = scan_data.usage_is_inconsistent;
>
> +out_close_qh:
> + err = quota_file_close(&qh);
> + if (err) {
> + log_err("Cannot close quotafile: %s", error_message(errno));
> + if (qh.qh_qf.e2_file)
> + ext2fs_file_close(qh.qh_qf.e2_file);
> + }
> out:
> return err;
> }
> diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c
> index 7e98ed7..a95a1f9 100644
> --- a/lib/quota/quotaio.c
> +++ b/lib/quota/quotaio.c
> @@ -356,9 +356,14 @@ errcode_t quota_file_close(struct quota_handle *h)
> if (h->qh_ops->end_io && h->qh_ops->end_io(h) < 0)
> return -1;
> if (h->qh_qf.e2_file) {
> + __u64 new_size, size;
> +
> + new_size = compute_inode_size(h->qh_qf.fs, h->qh_qf.ino);
> ext2fs_file_flush(h->qh_qf.e2_file);
> - ext2fs_file_set_size2(h->qh_qf.e2_file,
> - compute_inode_size(h->qh_qf.fs, h->qh_qf.ino));
> + if (ext2fs_file_get_lsize(h->qh_qf.e2_file, &size))
> + new_size = 0;
> + if (size != new_size)
> + ext2fs_file_set_size2(h->qh_qf.e2_file, new_size);
> ext2fs_file_close(h->qh_qf.e2_file);
> }
>
> --
> 1.9.0
>
--
Aditya
next prev parent reply other threads:[~2014-05-13 6:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-11 4:32 [PATCH 0/9] e2fsprogs: fix quota support Theodore Ts'o
2014-05-11 4:32 ` [PATCH 1/9] quota: add debugging code to print the dquot structure Theodore Ts'o
2014-05-13 6:30 ` Aditya Kali
2014-05-11 4:32 ` [PATCH 2/9] quota: fix e2fsck so we update the quota file correctly Theodore Ts'o
2014-05-13 6:35 ` Aditya Kali
2014-05-11 4:32 ` [PATCH 3/9] quota: fix e2fsck to notice missing quota entries Theodore Ts'o
2014-05-13 6:42 ` Aditya Kali
2014-05-11 4:32 ` [PATCH 4/9] quota: fix memory leak in quota_compare_and_update() Theodore Ts'o
2014-05-13 6:48 ` Aditya Kali [this message]
2014-05-11 4:32 ` [PATCH 5/9] quota: integrate mkquota.h into quotaio.h Theodore Ts'o
2014-05-13 6:53 ` Aditya Kali
2014-05-11 4:32 ` [PATCH 6/9] quota: support storing the quota file handles in the quota context Theodore Ts'o
2014-05-13 7:10 ` Aditya Kali
2014-05-11 4:32 ` [PATCH 7/9] debugfs: add commands to query the quota information Theodore Ts'o
2014-05-13 7:28 ` Aditya Kali
2014-05-11 4:32 ` [PATCH 8/9] tests: add basic e2fsck regression test for fixing the quota inode Theodore Ts'o
2014-05-13 7:29 ` Aditya Kali
2014-05-11 4:32 ` [PATCH 9/9] quota: remove warning message that we have fixed the nasty quota bugs Theodore Ts'o
2014-05-11 4:42 ` Theodore Ts'o
2014-05-13 7:32 ` Aditya Kali
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=CAGr1F2FwRLuAtdrJsU+BHaMF05+rihqYW2MfmPCYj-oMm0McOA@mail.gmail.com \
--to=adityakali@google.com \
--cc=linux-ext4@vger.kernel.org \
--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).