xfs: simplify xfs_ail_max
PATCH 3/4 xfs: simplify xfs_ail_max
From: Jie Liu <[email protected]>
We have already simplified xfs_ail_min() with a new list helper, i.e, list_first_entry_or_null(), but xfs_ail_max() still remains as same as there is no corresponding list helper we can use for now. It's fairly easy to simulate the list behavior of getting the last item in the AIL, therefore we can simplify xfs_ail_max() and move it to the header file to make this pair of AIL routines looks symmetrical.
--- fs/xfs/xfs_trans_ail.c | 14 -------------- fs/xfs/xfs_trans_priv.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-)
fs/xfs/xfs_trans_ail.c +0 -14
@@ -62,20 +62,6 @@ xfs_ail_check(#endif /* DEBUG */ /* -* Return a pointer to the last item in the AIL. If the AIL is empty, then -* return NULL. -*/ -static xfs_log_item_t * -xfs_ail_max ( -struct xfs_ail *ailp) -{ -if (list_empty (&ailp->xa_ail)) -return NULL ; - -return list_entry (ailp->xa_ail.prev, xfs_log_item_t, li_ail); -} - -/* * Return a pointer to the item which follows the given item in the AIL. If * the given item is the last item in the list, then return NULL. */
fs/xfs/xfs_trans_priv.h +13 -0
@@ -97,6 +97,19 @@ xfs_ail_min( li_ail); } +/* +* Return a pointer to the last item in the AIL. If the AIL is empty, then +* return NULL. +*/ +static inline struct xfs_log_item * +xfs_ail_max ( +struct xfs_ail *ailp) +{ +return list_empty (&ailp->xa_ail) ?NULL : + list_last_entry(&ailp->xa_ail, struct xfs_log_item, li_ail); +} + + static inline void xfs_trans_ail_update( struct xfs_ail *ailp,
Signature · 6 lines
1.8.3.2 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 8 lines · Jeff Liu
From: Jie Liu <[email protected]>
We have already simplified
xfs_ail_min()with a new list helper, i.e,list_first_entry_or_null(), butxfs_ail_max()still remains as same as there is no corresponding list helper we can use for now. It's fairly easy to simulate the list behavior of getting the last item in the AIL, therefore we can simplifyxfs_ail_max()and move it to the header file to make this pair of AIL routines looks symmetrical.
The usageof list_last_entry is fine with me, as is making it inline. But I think using the explicit if is a lot more readable than the ? :
expression.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Jeff Liu
From: Jie Liu <[email protected]>
We have already simplified
xfs_ail_min()with a new list helper, i.e,list_first_entry_or_null(), butxfs_ail_max()still remains as same as there is no corresponding list helper we can use for now. It's fairly easy to simulate the list behavior of getting the last item in the AIL, therefore we can simplifyxfs_ail_max()and move it to the header file to make this pair of AIL routines looks symmetrical.
Quoted 3 lines
The usageof
list_last_entryis fine with me, as is making it inline. But I think using the explicit if is a lot more readable than the ? :
expression.
Sounds sensible to me, will take care of it.
Thanks,
-Jeff
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 18 lines · Jeff Liu
From: Jie Liu<[email protected]>
We have already simplified
xfs_ail_min()with a new list helper, i.e,list_first_entry_or_null(), butxfs_ail_max()still remains as same as there is no corresponding list helper we can use for now. It's fairly easy to simulate the list behavior of getting the last item in the AIL, therefore we can simplifyxfs_ail_max()and move it to the header file to make this pair of AIL routines looks symmetrical.Signed-off-by Jie Liu<[email protected]>---
fs/xfs/xfs_trans_priv.h +6
-0+/* +* Return a pointer to the last item in the AIL. If the AIL is empty, then +* return NULL. +*/ +static inline struct xfs_log_item * +xfs_ail_max(
fs/xfs/xfs_trans_priv.h xfs_ail_min( · line 115
Quoted 10 lines
fs/xfs/xfs_trans_priv.h +7
-0+ struct xfs_ail *ailp) +{ +return list_empty (&ailp->xa_ail) ?NULL : + list_last_entry(&ailp->xa_ail, struct xfs_log_item, li_ail); +} + + static inline void xfs_trans_ail_update( struct xfs_ail *ailp,
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs