[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <559932D3.30403@users.sourceforge.net>
Date: Sun, 05 Jul 2015 15:36:19 +0200
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: Joel Becker <jlbec@...lplan.org>, Mark Fasheh <mfasheh@...e.com>,
ocfs2-devel@....oracle.com
CC: LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org,
Julia Lawall <julia.lawall@...6.fr>
Subject: [PATCH 07/11] ocfs2: Less function calls in ocfs2_shutdown_local_alloc()
after error detection
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sat, 4 Jul 2015 21:02:05 +0200
The functions kfree() and iput() were called in a few cases by the
ocfs2_shutdown_local_alloc() function during error handling even
if the passed variables contained still a null pointer.
* Return directly if the local allocation feature is unused or if a call
for the ocfs2_get_system_file_inode() function failed.
* Adjust jump targets.
* Drop unnecessary initialisations for the variables "alloc", "alloc_copy",
"bh", "local_alloc_inode" and "main_bm_inode" then.
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
fs/ocfs2/localalloc.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 16579ed..e6d5074 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -377,18 +377,18 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
{
int status;
handle_t *handle;
- struct inode *local_alloc_inode = NULL;
- struct buffer_head *bh = NULL;
+ struct inode *local_alloc_inode;
+ struct buffer_head *bh;
struct buffer_head *main_bm_bh = NULL;
- struct inode *main_bm_inode = NULL;
- struct ocfs2_dinode *alloc_copy = NULL;
- struct ocfs2_dinode *alloc = NULL;
+ struct inode *main_bm_inode;
+ struct ocfs2_dinode *alloc_copy;
+ struct ocfs2_dinode *alloc;
cancel_delayed_work(&osb->la_enable_wq);
flush_workqueue(ocfs2_wq);
if (osb->local_alloc_state == OCFS2_LA_UNUSED)
- goto out;
+ return;
local_alloc_inode =
ocfs2_get_system_file_inode(osb,
@@ -397,7 +397,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
if (!local_alloc_inode) {
status = -ENOENT;
mlog_errno(status);
- goto out;
+ return;
}
osb->local_alloc_state = OCFS2_LA_DISABLED;
@@ -410,7 +410,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
if (!main_bm_inode) {
status = -EINVAL;
mlog_errno(status);
- goto out;
+ goto put_local_alloc_inode;
}
mutex_lock(&main_bm_inode->i_mutex);
@@ -443,7 +443,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
bh, OCFS2_JOURNAL_ACCESS_WRITE);
if (status < 0) {
mlog_errno(status);
- goto out_commit;
+ goto free_copy;
}
ocfs2_clear_local_alloc(alloc);
@@ -458,21 +458,18 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
if (status < 0)
mlog_errno(status);
+free_copy:
+ kfree(alloc_copy);
out_commit:
ocfs2_commit_trans(osb, handle);
-
out_unlock:
brelse(main_bm_bh);
-
ocfs2_inode_unlock(main_bm_inode, 1);
-
out_mutex:
mutex_unlock(&main_bm_inode->i_mutex);
iput(main_bm_inode);
-
-out:
+put_local_alloc_inode:
iput(local_alloc_inode);
- kfree(alloc_copy);
}
/*
--
2.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists