[PATCH 09/11] ocfs2: One function call less in ocfs2_trylock_journal() after error detection

SF Markus Elfring
2015-07-05T13:38:39Z

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 4 Jul 2015 22:34:43 +0200

The iput() function was called in one case by the
ocfs2_trylock_journal() function during error handling even
if the passed variable "inode" contained still a null pointer.

* Return directly if a call of the ocfs2_get_system_file_inode() function
failed at the beginning.

* Rename a jump label according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/ocfs2/journal.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index c644997..c343e36 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1749,21 +1749,18 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
int slot_num)
{
int status, flags;
- struct inode *inode = NULL;
+ struct inode *inode;

inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE,
slot_num);
if (inode = NULL) {
mlog(ML_ERROR, "access error\n");
- status = -EACCES;
- goto bail;
+ return -EACCES;
}
if (is_bad_inode(inode)) {
mlog(ML_ERROR, "access error (bad inode)\n");
- iput(inode);
- inode = NULL;
status = -EACCES;
- goto bail;
+ goto put_inode;
}
SET_INODE_JOURNAL(inode);

@@ -1772,11 +1769,11 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
if (status < 0) {
if (status != -EAGAIN)
mlog_errno(status);
- goto bail;
+ goto put_inode;
}

ocfs2_inode_unlock(inode, 1);
-bail:
+put_inode:
iput(inode);
return status;
}
--
2.4.5