@@ -2252,72 +2252,26 @@ xfs_buf_cmp(
2252
2252
return 0 ;
2253
2253
}
2254
2254
2255
- /*
2256
- * Submit buffers for write. If wait_list is specified, the buffers are
2257
- * submitted using sync I/O and placed on the wait list such that the caller can
2258
- * iowait each buffer. Otherwise async I/O is used and the buffers are released
2259
- * at I/O completion time. In either case, buffers remain locked until I/O
2260
- * completes and the buffer is released from the queue.
2261
- */
2262
- static int
2263
- xfs_buf_delwri_submit_buffers (
2264
- struct list_head * buffer_list ,
2265
- struct list_head * wait_list )
2255
+ static bool
2256
+ xfs_buf_delwri_submit_prep (
2257
+ struct xfs_buf * bp )
2266
2258
{
2267
- struct xfs_buf * bp , * n ;
2268
- int pinned = 0 ;
2269
- struct blk_plug plug ;
2270
-
2271
- list_sort (NULL , buffer_list , xfs_buf_cmp );
2272
-
2273
- blk_start_plug (& plug );
2274
- list_for_each_entry_safe (bp , n , buffer_list , b_list ) {
2275
- if (!wait_list ) {
2276
- if (!xfs_buf_trylock (bp ))
2277
- continue ;
2278
- if (xfs_buf_ispinned (bp )) {
2279
- xfs_buf_unlock (bp );
2280
- pinned ++ ;
2281
- continue ;
2282
- }
2283
- } else {
2284
- xfs_buf_lock (bp );
2285
- }
2286
-
2287
- /*
2288
- * Someone else might have written the buffer synchronously or
2289
- * marked it stale in the meantime. In that case only the
2290
- * _XBF_DELWRI_Q flag got cleared, and we have to drop the
2291
- * reference and remove it from the list here.
2292
- */
2293
- if (!(bp -> b_flags & _XBF_DELWRI_Q )) {
2294
- xfs_buf_list_del (bp );
2295
- xfs_buf_relse (bp );
2296
- continue ;
2297
- }
2298
-
2299
- trace_xfs_buf_delwri_split (bp , _RET_IP_ );
2300
-
2301
- /*
2302
- * If we have a wait list, each buffer (and associated delwri
2303
- * queue reference) transfers to it and is submitted
2304
- * synchronously. Otherwise, drop the buffer from the delwri
2305
- * queue and submit async.
2306
- */
2307
- bp -> b_flags &= ~_XBF_DELWRI_Q ;
2308
- bp -> b_flags |= XBF_WRITE ;
2309
- if (wait_list ) {
2310
- bp -> b_flags &= ~XBF_ASYNC ;
2311
- list_move_tail (& bp -> b_list , wait_list );
2312
- } else {
2313
- bp -> b_flags |= XBF_ASYNC ;
2314
- xfs_buf_list_del (bp );
2315
- }
2316
- xfs_buf_submit (bp );
2259
+ /*
2260
+ * Someone else might have written the buffer synchronously or marked it
2261
+ * stale in the meantime. In that case only the _XBF_DELWRI_Q flag got
2262
+ * cleared, and we have to drop the reference and remove it from the
2263
+ * list here.
2264
+ */
2265
+ if (!(bp -> b_flags & _XBF_DELWRI_Q )) {
2266
+ xfs_buf_list_del (bp );
2267
+ xfs_buf_relse (bp );
2268
+ return false;
2317
2269
}
2318
- blk_finish_plug (& plug );
2319
2270
2320
- return pinned ;
2271
+ trace_xfs_buf_delwri_split (bp , _RET_IP_ );
2272
+ bp -> b_flags &= ~_XBF_DELWRI_Q ;
2273
+ bp -> b_flags |= XBF_WRITE ;
2274
+ return true;
2321
2275
}
2322
2276
2323
2277
/*
@@ -2340,7 +2294,30 @@ int
2340
2294
xfs_buf_delwri_submit_nowait (
2341
2295
struct list_head * buffer_list )
2342
2296
{
2343
- return xfs_buf_delwri_submit_buffers (buffer_list , NULL );
2297
+ struct xfs_buf * bp , * n ;
2298
+ int pinned = 0 ;
2299
+ struct blk_plug plug ;
2300
+
2301
+ list_sort (NULL , buffer_list , xfs_buf_cmp );
2302
+
2303
+ blk_start_plug (& plug );
2304
+ list_for_each_entry_safe (bp , n , buffer_list , b_list ) {
2305
+ if (!xfs_buf_trylock (bp ))
2306
+ continue ;
2307
+ if (xfs_buf_ispinned (bp )) {
2308
+ xfs_buf_unlock (bp );
2309
+ pinned ++ ;
2310
+ continue ;
2311
+ }
2312
+ if (!xfs_buf_delwri_submit_prep (bp ))
2313
+ continue ;
2314
+ bp -> b_flags |= XBF_ASYNC ;
2315
+ xfs_buf_list_del (bp );
2316
+ xfs_buf_submit (bp );
2317
+ }
2318
+ blk_finish_plug (& plug );
2319
+
2320
+ return pinned ;
2344
2321
}
2345
2322
2346
2323
/*
@@ -2357,9 +2334,21 @@ xfs_buf_delwri_submit(
2357
2334
{
2358
2335
LIST_HEAD (wait_list );
2359
2336
int error = 0 , error2 ;
2360
- struct xfs_buf * bp ;
2337
+ struct xfs_buf * bp , * n ;
2338
+ struct blk_plug plug ;
2361
2339
2362
- xfs_buf_delwri_submit_buffers (buffer_list , & wait_list );
2340
+ list_sort (NULL , buffer_list , xfs_buf_cmp );
2341
+
2342
+ blk_start_plug (& plug );
2343
+ list_for_each_entry_safe (bp , n , buffer_list , b_list ) {
2344
+ xfs_buf_lock (bp );
2345
+ if (!xfs_buf_delwri_submit_prep (bp ))
2346
+ continue ;
2347
+ bp -> b_flags &= ~XBF_ASYNC ;
2348
+ list_move_tail (& bp -> b_list , & wait_list );
2349
+ xfs_buf_submit (bp );
2350
+ }
2351
+ blk_finish_plug (& plug );
2363
2352
2364
2353
/* Wait for IO to complete. */
2365
2354
while (!list_empty (& wait_list )) {
0 commit comments