| To: | Eric Sandeen <sandeen@xxxxxxxxxx>, xfs@xxxxxxxxxxx |
|---|---|
| Subject: | [PATCH 08/14 V2] xfsprogs: free resources in libxfs_alloc_file_space error paths |
| From: | Eric Sandeen <sandeen@xxxxxxxxxxx> |
| Date: | Fri, 11 Apr 2014 17:49:29 -0500 |
| Delivered-to: | xfs@xxxxxxxxxxx |
| In-reply-to: | <1396999504-13769-9-git-send-email-sandeen@xxxxxxxxxx> |
| References: | <1396999504-13769-1-git-send-email-sandeen@xxxxxxxxxx> <1396999504-13769-9-git-send-email-sandeen@xxxxxxxxxx> |
| User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
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@xxxxxxxxxx>
---
V2: Fix comment, remove XXX :)
Although: That ASSERT, while matching kernelspace, seems
weird. We *can* get other errors out of xfs_trans_reserve.
EIO etc... What's the assert all about?
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);
+ 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, cancel trans */
+ xfs_bmap_cancel(&free_list);
+ xfs_trans_cancel(tp, 0);
+ return error;
}
unsigned int
|
| Previous by Date: | [PATCH 03/14 V2] xfsprogs: trivial buffer frees on error paths, Eric Sandeen |
|---|---|
| Next by Date: | Re: Strange hole creation behavior, PÃdraig Brady |
| Previous by Thread: | Re: [PATCH 08/14] xfsprogs: free resources in libxfs_alloc_file_space error paths, Brian Foster |
| Next by Thread: | [PATCH 10/14] xfsprogs: fix too-large memset value in xfs_db's attr code, Eric Sandeen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |