diff options
| -rw-r--r-- | fs/xfs/xfs_trans_ail.c | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 9a69dc06ea86..7908c798a02b 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
| @@ -189,20 +189,6 @@ xfs_trans_ail_cursor_init( | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | /* | 191 | /* |
| 192 | * Set the cursor to the next item, because when we look | ||
| 193 | * up the cursor the current item may have been freed. | ||
| 194 | */ | ||
| 195 | STATIC void | ||
| 196 | xfs_trans_ail_cursor_set( | ||
| 197 | struct xfs_ail *ailp, | ||
| 198 | struct xfs_ail_cursor *cur, | ||
| 199 | struct xfs_log_item *lip) | ||
| 200 | { | ||
| 201 | if (lip) | ||
| 202 | cur->item = xfs_ail_next(ailp, lip); | ||
| 203 | } | ||
| 204 | |||
| 205 | /* | ||
| 206 | * Get the next item in the traversal and advance the cursor. | 192 | * Get the next item in the traversal and advance the cursor. |
| 207 | * If the cursor was invalidated (inidicated by a lip of 1), | 193 | * If the cursor was invalidated (inidicated by a lip of 1), |
| 208 | * restart the traversal. | 194 | * restart the traversal. |
| @@ -216,7 +202,8 @@ xfs_trans_ail_cursor_next( | |||
| 216 | 202 | ||
| 217 | if ((__psint_t)lip & 1) | 203 | if ((__psint_t)lip & 1) |
| 218 | lip = xfs_ail_min(ailp); | 204 | lip = xfs_ail_min(ailp); |
| 219 | xfs_trans_ail_cursor_set(ailp, cur, lip); | 205 | if (lip) |
| 206 | cur->item = xfs_ail_next(ailp, lip); | ||
| 220 | return lip; | 207 | return lip; |
| 221 | } | 208 | } |
| 222 | 209 | ||
| @@ -272,9 +259,10 @@ xfs_trans_ail_cursor_clear( | |||
| 272 | } | 259 | } |
| 273 | 260 | ||
| 274 | /* | 261 | /* |
| 275 | * Initialise the cursor to the first item in the AIL with the given @lsn. | 262 | * Find the first item in the AIL with the given @lsn by searching in ascending |
| 276 | * This searches the list from lowest LSN to highest. Pass a @lsn of zero | 263 | * LSN order and initialise the cursor to point to the next item for a |
| 277 | * to initialise the cursor to the first item in the AIL. | 264 | * ascending traversal. Pass a @lsn of zero to initialise the cursor to the |
| 265 | * first item in the AIL. Returns NULL if the list is empty. | ||
| 278 | */ | 266 | */ |
| 279 | xfs_log_item_t * | 267 | xfs_log_item_t * |
| 280 | xfs_trans_ail_cursor_first( | 268 | xfs_trans_ail_cursor_first( |
| @@ -285,26 +273,24 @@ xfs_trans_ail_cursor_first( | |||
| 285 | xfs_log_item_t *lip; | 273 | xfs_log_item_t *lip; |
| 286 | 274 | ||
| 287 | xfs_trans_ail_cursor_init(ailp, cur); | 275 | xfs_trans_ail_cursor_init(ailp, cur); |
| 288 | lip = xfs_ail_min(ailp); | 276 | |
| 289 | if (lsn == 0) | 277 | if (lsn == 0) { |
| 278 | lip = xfs_ail_min(ailp); | ||
| 290 | goto out; | 279 | goto out; |
| 280 | } | ||
| 291 | 281 | ||
| 292 | list_for_each_entry(lip, &ailp->xa_ail, li_ail) { | 282 | list_for_each_entry(lip, &ailp->xa_ail, li_ail) { |
| 293 | if (XFS_LSN_CMP(lip->li_lsn, lsn) >= 0) | 283 | if (XFS_LSN_CMP(lip->li_lsn, lsn) >= 0) |
| 294 | goto out; | 284 | goto out; |
| 295 | } | 285 | } |
| 296 | lip = NULL; | 286 | return NULL; |
| 287 | |||
| 297 | out: | 288 | out: |
| 298 | xfs_trans_ail_cursor_set(ailp, cur, lip); | 289 | if (lip) |
| 290 | cur->item = xfs_ail_next(ailp, lip); | ||
| 299 | return lip; | 291 | return lip; |
| 300 | } | 292 | } |
| 301 | 293 | ||
| 302 | /* | ||
| 303 | * Initialise the cursor to the last item in the AIL with the given @lsn. | ||
| 304 | * This searches the list from highest LSN to lowest. If there is no item with | ||
| 305 | * the value of @lsn, then it sets the cursor to the last item with an LSN lower | ||
| 306 | * than @lsn. | ||
| 307 | */ | ||
| 308 | static struct xfs_log_item * | 294 | static struct xfs_log_item * |
| 309 | __xfs_trans_ail_cursor_last( | 295 | __xfs_trans_ail_cursor_last( |
| 310 | struct xfs_ail *ailp, | 296 | struct xfs_ail *ailp, |
| @@ -320,8 +306,10 @@ __xfs_trans_ail_cursor_last( | |||
| 320 | } | 306 | } |
| 321 | 307 | ||
| 322 | /* | 308 | /* |
| 323 | * Initialise the cursor to the last item in the AIL with the given @lsn. | 309 | * Find the last item in the AIL with the given @lsn by searching in descending |
| 324 | * This searches the list from highest LSN to lowest. | 310 | * LSN order and initialise the cursor to point to that item. If there is no |
| 311 | * item with the value of @lsn, then it sets the cursor to the last item with an | ||
| 312 | * LSN lower than @lsn. Returns NULL if the list is empty. | ||
| 325 | */ | 313 | */ |
| 326 | struct xfs_log_item * | 314 | struct xfs_log_item * |
| 327 | xfs_trans_ail_cursor_last( | 315 | xfs_trans_ail_cursor_last( |
| @@ -335,7 +323,7 @@ xfs_trans_ail_cursor_last( | |||
| 335 | } | 323 | } |
| 336 | 324 | ||
| 337 | /* | 325 | /* |
| 338 | * splice the log item list into the AIL at the given LSN. We splice to the | 326 | * Splice the log item list into the AIL at the given LSN. We splice to the |
| 339 | * tail of the given LSN to maintain insert order for push traversals. The | 327 | * tail of the given LSN to maintain insert order for push traversals. The |
| 340 | * cursor is optional, allowing repeated updates to the same LSN to avoid | 328 | * cursor is optional, allowing repeated updates to the same LSN to avoid |
| 341 | * repeated traversals. | 329 | * repeated traversals. |
