From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 08/14] xfsprogs: free resources in libxfs_alloc_file_space error paths
Date: Fri, 11 Apr 2014 15:03:31 -0400 [thread overview]
Message-ID: <20140411190330.GC16717@laptop.bfoster> (raw)
In-Reply-To: <1396999504-13769-9-git-send-email-sandeen@redhat.com>
On Tue, Apr 08, 2014 at 06:24:58PM -0500, Eric Sandeen wrote:
> The bmap freelist & transaction pointer weren't
> being freed in libxfs_alloc_file_space error paths;
> more or less copy the error handling that exists
> in kernelspace to resolve this.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> libxfs/util.c | 20 +++++++++++++++++---
> 1 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/libxfs/util.c b/libxfs/util.c
> index 1b05540..f1aa4c6 100644
> --- a/libxfs/util.c
> +++ b/libxfs/util.c
> @@ -582,8 +582,17 @@ libxfs_alloc_file_space(
> resblks = (uint)XFS_DIOSTRAT_SPACE_RES(mp, datablocks);
> error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
> resblks, 0);
> - if (error)
> + /*
> + * Check for running out of space
> + */
> + if (error) {
> + /*
> + * Free the transaction structure.
> + */
> + ASSERT(error == ENOSPC); /* XXX ERS? */
XXX ?
> + xfs_trans_cancel(tp, 0);
> break;
> + }
> xfs_trans_ijoin(tp, ip, 0);
> xfs_trans_ihold(tp, ip);
>
> @@ -593,12 +602,12 @@ libxfs_alloc_file_space(
> &reccount, &free_list);
>
> if (error)
> - break;
> + goto error0;
>
> /* complete the transaction */
> error = xfs_bmap_finish(&tp, &free_list, &committed);
> if (error)
> - break;
> + goto error0;
>
> error = xfs_trans_commit(tp, 0);
> if (error)
> @@ -612,6 +621,11 @@ libxfs_alloc_file_space(
> allocatesize_fsb -= allocated_fsb;
> }
> return error;
> +
> +error0: /* Cancel bmap, unlock inode, cancel trans */
Nit, but since it appears we don't lock the inode, the comment is wrong.
Brian
> + xfs_bmap_cancel(&free_list);
> + xfs_trans_cancel(tp, 0);
> + return error;
> }
>
> unsigned int
> --
> 1.7.1
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-04-11 19:03 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-08 23:24 [PATCH 00/14] xfsprogs: varius & sundry fixes for coverity defects Eric Sandeen
2014-04-08 23:24 ` [PATCH 01/14] xfsprogs: fix various fd leaks Eric Sandeen
2014-04-08 23:24 ` [PATCH 02/14] xfsprogs: refactor fsrall_cleanup in xfs_fsr Eric Sandeen
2014-04-08 23:24 ` [PATCH 03/14] xfsprogs: trivial buffer frees on error paths Eric Sandeen
2014-04-11 19:03 ` Brian Foster
2014-04-11 22:25 ` [PATCH 03/14 V2] " Eric Sandeen
2014-04-08 23:24 ` [PATCH 04/14] xfsprogs: fix memory leak in xlog_recover_add_to_trans Eric Sandeen
2014-04-08 23:24 ` [PATCH 05/14] libxfs: fix memory leak in xfs_dir2_node_removename Eric Sandeen
2014-04-08 23:24 ` [PATCH 06/14] xfs_quota: fix memory leak in quota_group_type() error path Eric Sandeen
2014-04-08 23:24 ` [PATCH 07/14] xfs_logprint: fix leak in error path of xlog_print_record() Eric Sandeen
2014-04-08 23:24 ` [PATCH 08/14] xfsprogs: free resources in libxfs_alloc_file_space error paths Eric Sandeen
2014-04-11 19:03 ` Brian Foster [this message]
2014-04-11 22:49 ` [PATCH 08/14 V2] " Eric Sandeen
2014-04-08 23:24 ` [PATCH 09/14] xfsprogs: annotate a case fallthrough in libxfs_ialloc Eric Sandeen
2014-04-08 23:25 ` [PATCH 10/14] xfsprogs: fix too-large memset value in xfs_db's attr code Eric Sandeen
2014-04-08 23:25 ` [PATCH 11/14] xfs_quota: remove impossible tests in printpath Eric Sandeen
2014-04-08 23:25 ` [PATCH 12/14] xfs_repair: address never-true tests in repair/bmap.c on 64 bit Eric Sandeen
2014-04-09 13:55 ` Mark Tinguely
2014-04-09 14:36 ` [PATCH 12/14 V2] " Eric Sandeen
2014-04-08 23:25 ` [PATCH 13/14] mkfs: catch unknown format in protofile parsing Eric Sandeen
2014-04-08 23:25 ` [PATCH 14/14] xfs_db: don't use invalid index in ring_f Eric Sandeen
2014-04-09 22:18 ` [PATCH 15/14] xfs_io: free memory on error path exit from bmap_f() Eric Sandeen
2014-04-10 13:38 ` Mark Tinguely
2014-04-10 14:15 ` Eric Sandeen
2014-04-11 19:02 ` [PATCH 00/14] xfsprogs: varius & sundry fixes for coverity defects Brian Foster
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=20140411190330.GC16717@laptop.bfoster \
--to=bfoster@redhat.com \
--cc=sandeen@redhat.com \
--cc=xfs@oss.sgi.com \
/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).