diff options
author | Jie Liu <jeff.liu@oracle.com> | 2013-08-15 01:08:35 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-23 13:57:43 -0400 |
commit | 8d1d40832b1c53ae73931f1b536ce1ab7375b3c8 (patch) | |
tree | beeae7e87ad17163cb7577827cde3bf9c93fd1ca /fs/xfs | |
parent | 46677e679fba8c2db7c94a7142ad9abb72192ebc (diff) |
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 <jeff.liu@oracle.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_trans_ail.c | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_priv.h | 12 |
2 files changed, 12 insertions, 14 deletions
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 0eda7254305f..0e7df03e60c5 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
@@ -61,20 +61,6 @@ xfs_ail_check( | |||
61 | #endif /* DEBUG */ | 61 | #endif /* DEBUG */ |
62 | 62 | ||
63 | /* | 63 | /* |
64 | * Return a pointer to the first item in the AIL. If the AIL is empty, then | ||
65 | * return NULL. | ||
66 | */ | ||
67 | xfs_log_item_t * | ||
68 | xfs_ail_min( | ||
69 | struct xfs_ail *ailp) | ||
70 | { | ||
71 | if (list_empty(&ailp->xa_ail)) | ||
72 | return NULL; | ||
73 | |||
74 | return list_first_entry(&ailp->xa_ail, xfs_log_item_t, li_ail); | ||
75 | } | ||
76 | |||
77 | /* | ||
78 | * Return a pointer to the last item in the AIL. If the AIL is empty, then | 64 | * Return a pointer to the last item in the AIL. If the AIL is empty, then |
79 | * return NULL. | 65 | * return NULL. |
80 | */ | 66 | */ |
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, | |||
86 | struct xfs_ail_cursor *cur, | 86 | struct xfs_ail_cursor *cur, |
87 | struct xfs_log_item **log_items, int nr_items, | 87 | struct xfs_log_item **log_items, int nr_items, |
88 | xfs_lsn_t lsn) __releases(ailp->xa_lock); | 88 | xfs_lsn_t lsn) __releases(ailp->xa_lock); |
89 | /* | ||
90 | * Return a pointer to the first item in the AIL. If the AIL is empty, then | ||
91 | * return NULL. | ||
92 | */ | ||
93 | static inline struct xfs_log_item * | ||
94 | xfs_ail_min( | ||
95 | struct xfs_ail *ailp) | ||
96 | { | ||
97 | return list_first_entry_or_null(&ailp->xa_ail, struct xfs_log_item, | ||
98 | li_ail); | ||
99 | } | ||
100 | |||
89 | static inline void | 101 | static inline void |
90 | xfs_trans_ail_update( | 102 | xfs_trans_ail_update( |
91 | struct xfs_ail *ailp, | 103 | struct xfs_ail *ailp, |