From 8d1d40832b1c53ae73931f1b536ce1ab7375b3c8 Mon Sep 17 00:00:00 2001 From: Jie Liu Date: Thu, 15 Aug 2013 13:08:35 +0800 Subject: xfs: Simplify xfs_ail_min() with list_first_entry_or_null() 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. Signed-off-by: Jie Liu Reviewed-by: Ben Myers Signed-off-by: Ben Myers --- fs/xfs/xfs_trans_priv.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'fs/xfs/xfs_trans_priv.h') diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h index d43b13004f7c..c52def0b441c 100644 --- a/fs/xfs/xfs_trans_priv.h +++ b/fs/xfs/xfs_trans_priv.h @@ -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, -- cgit v1.2.3