Skip to contentSkip to conversation

xfs: Simplify xfs_ail_min() with list_first_entry_or_null()

PATCH Applied Jeff Liu 2 participants 2 messages Aug 15, 2013 – Aug 23, 2013 XFS filesystem

lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH v2 1/1 xfs: Simplify xfs_ail_min() with list_first_entry_or_null()

From: Jie Liu <[email protected]>

At xfs_ail_min(), we do check if the AIL list is empty or not before returning the first item in it with list_empty() and list_first_entry().

This can be simplified a bit with a new list operation routine that is the list_first_entry_or_null() which has been introduced by:

commit 6d7581e62f8be462440d7b22c6361f7c9fa4902b
list: introduce list_first_entry_or_null

v2: make xfs_ail_min() as a static inline function and move it to
xfs_trans_priv.h as per Dave Chinner's comments.

---
 fs/xfs/xfs_trans_ail.c  |   14 --------------
 fs/xfs/xfs_trans_priv.h |   12 ++++++++++++
 2 files changed, 12 insertions(+), 14 deletions(-)
fs/xfs/xfs_trans_ail.c +0 -14
index 0eda725..0e7df03 100644
@@ -61,20 +61,6 @@ xfs_ail_check(
 #endif /* DEBUG */
 
 /*
- * Return a pointer to the first item in the AIL.  If the AIL is empty, then
- * return NULL.
- */
-xfs_log_item_t *
-xfs_ail_min(
-	struct xfs_ail  *ailp)
-{
-	if (list_empty(&ailp->xa_ail))
-		return NULL;
-
-	return list_first_entry(&ailp->xa_ail, xfs_log_item_t, li_ail);
-}
-
- /*
  * Return a pointer to the last item in the AIL.  If the AIL is empty, then
  * return NULL.
  */
fs/xfs/xfs_trans_priv.h +12 -0
index d43b130..c52def0 100644
@@ -86,6 +86,18 @@ void	xfs_trans_ail_update_bulk(struct xfs_ail *ailp,
 				struct xfs_ail_cursor *cur,
 				struct xfs_log_item **log_items, int nr_items,
 				xfs_lsn_t lsn) __releases(ailp->xa_lock);
+/*
+ * Return a pointer to the first item in the AIL.  If the AIL is empty, then
+ * return NULL.
+ */
+static inline struct xfs_log_item *
+xfs_ail_min(
+	struct xfs_ail  *ailp)
+{
+	return list_first_entry_or_null(&ailp->xa_ail, struct xfs_log_item,
+					li_ail);
+}
+
 static inline void
 xfs_trans_ail_update(
 	struct xfs_ail		*ailp,
Signature · 6 lines
1.7.9.5

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v2 1/1 Applied
#1 lore raw
Quoted 8 lines · Jeff Liu

From: Jie Liu <[email protected]>

At xfs_ail_min(), we do check if the AIL list is empty or not before returning the first item in it with list_empty() and list_first_entry().

This can be simplified a bit with a new list operation routine that is the list_first_entry_or_null() which has been introduced by:

Quoted 7 lines

commit 6d7581e62f8be462440d7b22c6361f7c9fa4902b
list: introduce list_first_entry_or_null

v2: make xfs_ail_min() as a static inline function and move it to
xfs_trans_priv.h as per Dave Chinner's comments.

Applied. Thanks Jeff.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs