[PATCH 06/11] ocfs2: Two checks less in ocfs2_local_alloc_slide_window()

From: SF Markus Elfring
Date: Sun Jul 05 2015 - 09:35:21 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 4 Jul 2015 18:18:23 +0200

* Return directly from the ocfs2_local_alloc_slide_window() function
if a call of the ocfs2_local_alloc_reserve_for_window() function failed
at the beginning.

* Rename jump labels according to the Linux coding style convention.

* Drop an unnecessary initialisation for the variable "handle" then.

* Delete a call of the mlog_errno() function at the end.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
fs/ocfs2/localalloc.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index a614037..16579ed 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -1248,7 +1248,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
int status = 0;
struct buffer_head *main_bm_bh = NULL;
struct inode *main_bm_inode = NULL;
- handle_t *handle = NULL;
+ handle_t *handle;
struct ocfs2_dinode *alloc;
struct ocfs2_dinode *alloc_copy = NULL;
struct ocfs2_alloc_context *ac = NULL;
@@ -1263,15 +1263,14 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
if (status < 0) {
if (status != -ENOSPC)
mlog_errno(status);
- goto bail;
+ return status;
}

handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS);
if (IS_ERR(handle)) {
status = PTR_ERR(handle);
- handle = NULL;
mlog_errno(status);
- goto bail;
+ goto clean_up_main;
}

alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data;
@@ -1285,7 +1284,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
if (!alloc_copy) {
status = -ENOMEM;
mlog_errno(status);
- goto bail;
+ goto commit;
}
memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size);

@@ -1295,7 +1294,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
OCFS2_JOURNAL_ACCESS_WRITE);
if (status < 0) {
mlog_errno(status);
- goto bail;
+ goto commit;
}

ocfs2_clear_local_alloc(alloc);
@@ -1305,31 +1304,27 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
main_bm_inode, main_bm_bh);
if (status < 0) {
mlog_errno(status);
- goto bail;
+ goto commit;
}

status = ocfs2_local_alloc_new_window(osb, handle, ac);
if (status < 0) {
if (status != -ENOSPC)
mlog_errno(status);
- goto bail;
+ goto commit;
}

atomic_inc(&osb->alloc_stats.moves);

-bail:
- if (handle)
- ocfs2_commit_trans(osb, handle);
-
+commit:
+ ocfs2_commit_trans(osb, handle);
+clean_up_main:
brelse(main_bm_bh);
iput(main_bm_inode);
kfree(alloc_copy);

if (ac)
ocfs2_free_alloc_context(ac);
-
- if (status)
- mlog_errno(status);
return status;
}

--
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/