2121#include "gc.h"
2222
2323static LIST_HEAD (f2fs_stat_list );
24- static DEFINE_MUTEX ( f2fs_stat_mutex );
24+ static DEFINE_RAW_SPINLOCK ( f2fs_stat_lock );
2525#ifdef CONFIG_DEBUG_FS
2626static struct dentry * f2fs_debugfs_root ;
2727#endif
@@ -345,8 +345,9 @@ static int stat_show(struct seq_file *s, void *v)
345345{
346346 struct f2fs_stat_info * si ;
347347 int i = 0 , j = 0 ;
348+ unsigned long flags ;
348349
349- mutex_lock ( & f2fs_stat_mutex );
350+ raw_spin_lock_irqsave ( & f2fs_stat_lock , flags );
350351 list_for_each_entry (si , & f2fs_stat_list , stat_list ) {
351352 update_general_status (si -> sbi );
352353
@@ -577,7 +578,7 @@ static int stat_show(struct seq_file *s, void *v)
577578 seq_printf (s , " - paged : %llu KB\n" ,
578579 si -> page_mem >> 10 );
579580 }
580- mutex_unlock ( & f2fs_stat_mutex );
581+ raw_spin_unlock_irqrestore ( & f2fs_stat_lock , flags );
581582 return 0 ;
582583}
583584
@@ -588,6 +589,7 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
588589{
589590 struct f2fs_super_block * raw_super = F2FS_RAW_SUPER (sbi );
590591 struct f2fs_stat_info * si ;
592+ unsigned long flags ;
591593 int i ;
592594
593595 si = f2fs_kzalloc (sbi , sizeof (struct f2fs_stat_info ), GFP_KERNEL );
@@ -623,20 +625,21 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
623625 atomic_set (& sbi -> max_aw_cnt , 0 );
624626 atomic_set (& sbi -> max_vw_cnt , 0 );
625627
626- mutex_lock ( & f2fs_stat_mutex );
628+ raw_spin_lock_irqsave ( & f2fs_stat_lock , flags );
627629 list_add_tail (& si -> stat_list , & f2fs_stat_list );
628- mutex_unlock ( & f2fs_stat_mutex );
630+ raw_spin_unlock_irqrestore ( & f2fs_stat_lock , flags );
629631
630632 return 0 ;
631633}
632634
633635void f2fs_destroy_stats (struct f2fs_sb_info * sbi )
634636{
635637 struct f2fs_stat_info * si = F2FS_STAT (sbi );
638+ unsigned long flags ;
636639
637- mutex_lock ( & f2fs_stat_mutex );
640+ raw_spin_lock_irqsave ( & f2fs_stat_lock , flags );
638641 list_del (& si -> stat_list );
639- mutex_unlock ( & f2fs_stat_mutex );
642+ raw_spin_unlock_irqrestore ( & f2fs_stat_lock , flags );
640643
641644 kfree (si );
642645}
0 commit comments