@@ -65,28 +65,21 @@ static void bdi_debug_init(void)
6565static int bdi_debug_stats_show (struct seq_file * m , void * v )
6666{
6767 struct backing_dev_info * bdi = m -> private ;
68- struct bdi_writeback * wb ;
68+ struct bdi_writeback * wb = & bdi -> wb ;
6969 unsigned long background_thresh ;
7070 unsigned long dirty_thresh ;
7171 unsigned long bdi_thresh ;
7272 unsigned long nr_dirty , nr_io , nr_more_io , nr_wb ;
7373 struct inode * inode ;
7474
75- /*
76- * inode lock is enough here, the bdi->wb_list is protected by
77- * RCU on the reader side
78- */
7975 nr_wb = nr_dirty = nr_io = nr_more_io = 0 ;
8076 spin_lock (& inode_lock );
81- list_for_each_entry (wb , & bdi -> wb_list , list ) {
82- nr_wb ++ ;
83- list_for_each_entry (inode , & wb -> b_dirty , i_list )
84- nr_dirty ++ ;
85- list_for_each_entry (inode , & wb -> b_io , i_list )
86- nr_io ++ ;
87- list_for_each_entry (inode , & wb -> b_more_io , i_list )
88- nr_more_io ++ ;
89- }
77+ list_for_each_entry (inode , & wb -> b_dirty , i_list )
78+ nr_dirty ++ ;
79+ list_for_each_entry (inode , & wb -> b_io , i_list )
80+ nr_io ++ ;
81+ list_for_each_entry (inode , & wb -> b_more_io , i_list )
82+ nr_more_io ++ ;
9083 spin_unlock (& inode_lock );
9184
9285 get_dirty_limits (& background_thresh , & dirty_thresh , & bdi_thresh , bdi );
@@ -98,19 +91,16 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v)
9891 "BdiDirtyThresh: %8lu kB\n"
9992 "DirtyThresh: %8lu kB\n"
10093 "BackgroundThresh: %8lu kB\n"
101- "WritebackThreads: %8lu\n"
10294 "b_dirty: %8lu\n"
10395 "b_io: %8lu\n"
10496 "b_more_io: %8lu\n"
10597 "bdi_list: %8u\n"
106- "state: %8lx\n"
107- "wb_list: %8u\n" ,
98+ "state: %8lx\n" ,
10899 (unsigned long ) K (bdi_stat (bdi , BDI_WRITEBACK )),
109100 (unsigned long ) K (bdi_stat (bdi , BDI_RECLAIMABLE )),
110101 K (bdi_thresh ), K (dirty_thresh ),
111- K (background_thresh ), nr_wb , nr_dirty , nr_io , nr_more_io ,
112- !list_empty (& bdi -> bdi_list ), bdi -> state ,
113- !list_empty (& bdi -> wb_list ));
102+ K (background_thresh ), nr_dirty , nr_io , nr_more_io ,
103+ !list_empty (& bdi -> bdi_list ), bdi -> state );
114104#undef K
115105
116106 return 0 ;
@@ -270,24 +260,6 @@ static void bdi_wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi)
270260 INIT_LIST_HEAD (& wb -> b_more_io );
271261}
272262
273- static void bdi_task_init (struct backing_dev_info * bdi ,
274- struct bdi_writeback * wb )
275- {
276- struct task_struct * tsk = current ;
277-
278- spin_lock (& bdi -> wb_lock );
279- list_add_tail_rcu (& wb -> list , & bdi -> wb_list );
280- spin_unlock (& bdi -> wb_lock );
281-
282- tsk -> flags |= PF_FLUSHER | PF_SWAPWRITE ;
283- set_freezable ();
284-
285- /*
286- * Our parent may run at a different priority, just set us to normal
287- */
288- set_user_nice (tsk , 0 );
289- }
290-
291263static int bdi_start_fn (void * ptr )
292264{
293265 struct bdi_writeback * wb = ptr ;
@@ -301,7 +273,13 @@ static int bdi_start_fn(void *ptr)
301273 list_add_rcu (& bdi -> bdi_list , & bdi_list );
302274 spin_unlock_bh (& bdi_lock );
303275
304- bdi_task_init (bdi , wb );
276+ current -> flags |= PF_FLUSHER | PF_SWAPWRITE ;
277+ set_freezable ();
278+
279+ /*
280+ * Our parent may run at a different priority, just set us to normal
281+ */
282+ set_user_nice (current , 0 );
305283
306284 /*
307285 * Clear pending bit and wakeup anybody waiting to tear us down
@@ -312,12 +290,7 @@ static int bdi_start_fn(void *ptr)
312290
313291 ret = bdi_writeback_task (wb );
314292
315- /*
316- * Remove us from the list
317- */
318- spin_lock (& bdi -> wb_lock );
319- list_del_rcu (& wb -> list );
320- spin_unlock (& bdi -> wb_lock );
293+ wb -> task = NULL ;
321294
322295 /*
323296 * Flush any work that raced with us exiting. No new work
@@ -326,7 +299,6 @@ static int bdi_start_fn(void *ptr)
326299 if (!list_empty (& bdi -> work_list ))
327300 wb_do_writeback (wb , 1 );
328301
329- wb -> task = NULL ;
330302 return ret ;
331303}
332304
@@ -391,7 +363,13 @@ static int bdi_forker_task(void *ptr)
391363{
392364 struct bdi_writeback * me = ptr ;
393365
394- bdi_task_init (me -> bdi , me );
366+ current -> flags |= PF_FLUSHER | PF_SWAPWRITE ;
367+ set_freezable ();
368+
369+ /*
370+ * Our parent may run at a different priority, just set us to normal
371+ */
372+ set_user_nice (current , 0 );
395373
396374 for (;;) {
397375 struct backing_dev_info * bdi , * tmp ;
@@ -598,8 +576,6 @@ EXPORT_SYMBOL(bdi_register_dev);
598576 */
599577static void bdi_wb_shutdown (struct backing_dev_info * bdi )
600578{
601- struct bdi_writeback * wb ;
602-
603579 if (!bdi_cap_writeback_dirty (bdi ))
604580 return ;
605581
@@ -615,14 +591,14 @@ static void bdi_wb_shutdown(struct backing_dev_info *bdi)
615591 bdi_remove_from_list (bdi );
616592
617593 /*
618- * Finally, kill the kernel threads . We don't need to be RCU
594+ * Finally, kill the kernel thread . We don't need to be RCU
619595 * safe anymore, since the bdi is gone from visibility. Force
620596 * unfreeze of the thread before calling kthread_stop(), otherwise
621597 * it would never exet if it is currently stuck in the refrigerator.
622598 */
623- list_for_each_entry ( wb , & bdi -> wb_list , list ) {
624- thaw_process (wb -> task );
625- kthread_stop (wb -> task );
599+ if ( bdi -> wb . task ) {
600+ thaw_process (bdi -> wb . task );
601+ kthread_stop (bdi -> wb . task );
626602 }
627603}
628604
@@ -667,7 +643,6 @@ int bdi_init(struct backing_dev_info *bdi)
667643 spin_lock_init (& bdi -> wb_lock );
668644 INIT_RCU_HEAD (& bdi -> rcu_head );
669645 INIT_LIST_HEAD (& bdi -> bdi_list );
670- INIT_LIST_HEAD (& bdi -> wb_list );
671646 INIT_LIST_HEAD (& bdi -> work_list );
672647
673648 bdi_wb_init (& bdi -> wb , bdi );
0 commit comments