dm-crypt: use __bio_add_page to add single page to clone bio
[linux-block.git] / fs / fs-writeback.c
index 6faeb45234ed66309ca953fa7f89bb94392e2bef..ae4e51e91ee33ef99c7a98c7936783f5d4149b90 100644 (file)
@@ -978,6 +978,16 @@ restart:
                        continue;
                }
 
+               /*
+                * If wb_tryget fails, the wb has been shutdown, skip it.
+                *
+                * Pin @wb so that it stays on @bdi->wb_list.  This allows
+                * continuing iteration from @wb after dropping and
+                * regrabbing rcu read lock.
+                */
+               if (!wb_tryget(wb))
+                       continue;
+
                /* alloc failed, execute synchronously using on-stack fallback */
                work = &fallback_work;
                *work = *base_work;
@@ -986,13 +996,6 @@ restart:
                work->done = &fallback_work_done;
 
                wb_queue_work(wb, work);
-
-               /*
-                * Pin @wb so that it stays on @bdi->wb_list.  This allows
-                * continuing iteration from @wb after dropping and
-                * regrabbing rcu read lock.
-                */
-               wb_get(wb);
                last_wb = wb;
 
                rcu_read_unlock();