Skip to contentSkip to conversation

jfs: simplify lmLogSync() via list_last_entry_or_null()

PATCH In review Jeff Liu 1 participant 2 messages Nov 15, 2013

Subsystems (2)
lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH 6/6 jfs: simplify lmLogSync() via list_last_entry_or_null()

From: Jie Liu <[email protected]>

Simplify the code in lmLogSync() via list_last_entry_or_null().

---
 fs/jfs/jfs_logmgr.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
fs/jfs/jfs_logmgr.c +3 -7
index 7b565d0..2f90779 100644
@@ -963,13 +963,9 @@ static int lmLogSync(struct jfs_log * log, int hard_sync)
 
 	if (log->sync == log->syncpt) {
 		LOGSYNC_LOCK(log, flags);
-		if (list_empty(&log->synclist))
-			log->sync = log->lsn;
-		else {
-			lp = list_entry(log->synclist.next,
-					struct logsyncblk, synclist);
-			log->sync = lp->lsn;
-		}
+		lp = list_last_entry_or_null(&log->synclist, struct logsyncblk,
+					     synclist);
+		log->sync = lp ? lp->lsn : log->lsn;
 		LOGSYNC_UNLOCK(log, flags);
 
 	}
Signature · 1 line
1.8.3.2
author
#1 lore raw

Hi Dave and all,

Please ignore this patch from this series.

Quoted 16 lines · Jeff Liu

From: Jie Liu <[email protected]>

Simplify the code in lmLogSync() via list_last_entry_or_null().

---
 fs/jfs/jfs_logmgr.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
fs/jfs/jfs_logmgr.c +0 -0
index 7b565d0..2f90779 100644
@@ -963,13 +963,9 @@ static int lmLogSync(struct jfs_log * log, int hard_sync)
 
 	if (log->sync == log->syncpt) {

fs/jfs/jfs_logmgr.c static int lmLogSync(struct jfs_log * log, int hard_sync) · line 967

Quoted 10 lines
fs/jfs/jfs_logmgr.c +2 -7
 		LOGSYNC_LOCK(log, flags);
-		if (list_empty(&log->synclist))
-			log->sync = log->lsn;
-		else {
-			lp = list_entry(log->synclist.next,
-					struct logsyncblk, synclist);
-			log->sync = lp->lsn;
-		}
+		lp = list_last_entry_or_null(&log->synclist, struct logsyncblk,
+					     synclist);

Here it could be simplified via list_first_entry_or_null(), my apology for this mistake.

fs/jfs/jfs_logmgr.c static int lmLogSync(struct jfs_log * log, int hard_sync) · line 971

Quoted 5 lines
fs/jfs/jfs_logmgr.c +1 -0
+		log->sync = lp ? lp->lsn : log->lsn;
 		LOGSYNC_UNLOCK(log, flags);
 
 	}

Thanks,
-Jeff