lkml.org 
[lkml]   [2015]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 10/11] ocfs2: Less function calls in ocfs2_replay_journal() after error detection
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 5 Jul 2015 12:23:37 +0200

The functions brelse() and iput() were called in one case by the
ocfs2_replay_journal() function during error handling even
if the passed variables contained still a pointer which did not refer
to valid data.

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

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

* Delete the variable "got_lock" then.

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

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index c343e36..7bb50f4 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1544,7 +1544,6 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
int slot_num)
{
int status;
- int got_lock = 0;
unsigned int flags;
struct inode *inode = NULL;
struct ocfs2_dinode *fe;
@@ -1555,7 +1554,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
status = ocfs2_read_journal_inode(osb, slot_num, &bh, &inode);
if (status) {
mlog_errno(status);
- goto done;
+ return status;
}

fe = (struct ocfs2_dinode *)bh->b_data;
@@ -1576,7 +1575,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
osb->slot_recovery_generations[slot_num], slot_reco_gen);
osb->slot_recovery_generations[slot_num] = slot_reco_gen;
status = -EBUSY;
- goto done;
+ goto put_inode;
}

/* Continue with recovery as the journal has not yet been recovered */
@@ -1586,9 +1585,8 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
trace_ocfs2_replay_journal_lock_err(status);
if (status != -ERESTARTSYS)
mlog(ML_ERROR, "Could not lock journal!\n");
- goto done;
+ goto put_inode;
}
- got_lock = 1;

fe = (struct ocfs2_dinode *) bh->b_data;

@@ -1599,7 +1597,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
trace_ocfs2_replay_journal_skip(node_num);
/* Refresh recovery generation for the slot */
osb->slot_recovery_generations[slot_num] = slot_reco_gen;
- goto done;
+ goto unlock_inode;
}

/* we need to run complete recovery for offline orphan slots */
@@ -1614,14 +1612,14 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
status = ocfs2_force_read_journal(inode);
if (status < 0) {
mlog_errno(status);
- goto done;
+ goto unlock_inode;
}

journal = jbd2_journal_init_inode(inode);
if (journal == NULL) {
mlog(ML_ERROR, "Linux journal layer error\n");
status = -EIO;
- goto done;
+ goto unlock_inode;
}

status = jbd2_journal_load(journal);
@@ -1630,7 +1628,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
if (!igrab(inode))
BUG();
jbd2_journal_destroy(journal);
- goto done;
+ goto unlock_inode;
}

ocfs2_clear_journal_error(osb->sb, journal, slot_num);
@@ -1665,11 +1663,10 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
printk(KERN_NOTICE "ocfs2: End replay journal (node %d, slot %d) on "\
"device (%u,%u)\n", node_num, slot_num, MAJOR(osb->sb->s_dev),
MINOR(osb->sb->s_dev));
-done:
+unlock_inode:
/* drop the lock on this nodes journal */
- if (got_lock)
- ocfs2_inode_unlock(inode, 1);
-
+ ocfs2_inode_unlock(inode, 1);
+put_inode:
iput(inode);
brelse(bh);

--
2.4.5


\
 
 \ /
  Last update: 2015-07-05 16:01    [W:0.821 / U:0.512 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site