@@ -346,13 +346,27 @@ int btrfs_verify_qgroup_counts(const struct btrfs_fs_info *fs_info, u64 qgroupid
346
346
}
347
347
#endif
348
348
349
- static void qgroup_mark_inconsistent (struct btrfs_fs_info * fs_info )
349
+ __printf (2 , 3 )
350
+ static void qgroup_mark_inconsistent (struct btrfs_fs_info * fs_info , const char * fmt , ...)
350
351
{
352
+ const u64 old_flags = fs_info -> qgroup_flags ;
353
+
351
354
if (btrfs_qgroup_mode (fs_info ) == BTRFS_QGROUP_MODE_SIMPLE )
352
355
return ;
353
356
fs_info -> qgroup_flags |= (BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT |
354
357
BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN |
355
358
BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING );
359
+ if (!(old_flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT )) {
360
+ struct va_format vaf ;
361
+ va_list args ;
362
+
363
+ va_start (args , fmt );
364
+ vaf .fmt = fmt ;
365
+ vaf .va = & args ;
366
+
367
+ btrfs_warn_rl (fs_info , "qgroup marked inconsistent, %pV" , & vaf );
368
+ va_end (args );
369
+ }
356
370
}
357
371
358
372
static void qgroup_read_enable_gen (struct btrfs_fs_info * fs_info ,
@@ -431,13 +445,10 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
431
445
goto out ;
432
446
}
433
447
fs_info -> qgroup_flags = btrfs_qgroup_status_flags (l , ptr );
434
- if (fs_info -> qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE ) {
448
+ if (fs_info -> qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE )
435
449
qgroup_read_enable_gen (fs_info , l , slot , ptr );
436
- } else if (btrfs_qgroup_status_generation (l , ptr ) != fs_info -> generation ) {
437
- qgroup_mark_inconsistent (fs_info );
438
- btrfs_err (fs_info ,
439
- "qgroup generation mismatch, marked as inconsistent" );
440
- }
450
+ else if (btrfs_qgroup_status_generation (l , ptr ) != fs_info -> generation )
451
+ qgroup_mark_inconsistent (fs_info , "qgroup generation mismatch" );
441
452
rescan_progress = btrfs_qgroup_status_rescan (l , ptr );
442
453
goto next1 ;
443
454
}
@@ -448,10 +459,8 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
448
459
449
460
qgroup = find_qgroup_rb (fs_info , found_key .offset );
450
461
if ((qgroup && found_key .type == BTRFS_QGROUP_INFO_KEY ) ||
451
- (!qgroup && found_key .type == BTRFS_QGROUP_LIMIT_KEY )) {
452
- btrfs_err (fs_info , "inconsistent qgroup config" );
453
- qgroup_mark_inconsistent (fs_info );
454
- }
462
+ (!qgroup && found_key .type == BTRFS_QGROUP_LIMIT_KEY ))
463
+ qgroup_mark_inconsistent (fs_info , "inconsistent qgroup config" );
455
464
if (!qgroup ) {
456
465
struct btrfs_qgroup * prealloc ;
457
466
struct btrfs_root * tree_root = fs_info -> tree_root ;
@@ -1841,13 +1850,12 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
1841
1850
if (qgroup -> rfer || qgroup -> excl ||
1842
1851
qgroup -> rfer_cmpr || qgroup -> excl_cmpr ) {
1843
1852
DEBUG_WARN ();
1844
- btrfs_warn_rl (fs_info ,
1845
- "to be deleted qgroup %u/%llu has non-zero numbers, rfer %llu rfer_cmpr %llu excl %llu excl_cmpr %llu" ,
1846
- btrfs_qgroup_level (qgroup -> qgroupid ),
1847
- btrfs_qgroup_subvolid (qgroup -> qgroupid ),
1848
- qgroup -> rfer , qgroup -> rfer_cmpr ,
1849
- qgroup -> excl , qgroup -> excl_cmpr );
1850
- qgroup_mark_inconsistent (fs_info );
1853
+ qgroup_mark_inconsistent (fs_info ,
1854
+ "to be deleted qgroup %u/%llu has non-zero numbers, rfer %llu rfer_cmpr %llu excl %llu excl_cmpr %llu" ,
1855
+ btrfs_qgroup_level (qgroup -> qgroupid ),
1856
+ btrfs_qgroup_subvolid (qgroup -> qgroupid ),
1857
+ qgroup -> rfer , qgroup -> rfer_cmpr ,
1858
+ qgroup -> excl , qgroup -> excl_cmpr );
1851
1859
}
1852
1860
}
1853
1861
del_qgroup_rb (fs_info , qgroupid );
@@ -1965,11 +1973,8 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid,
1965
1973
spin_unlock (& fs_info -> qgroup_lock );
1966
1974
1967
1975
ret = update_qgroup_limit_item (trans , qgroup );
1968
- if (ret ) {
1969
- qgroup_mark_inconsistent (fs_info );
1970
- btrfs_info (fs_info , "unable to update quota limit for %llu" ,
1971
- qgroupid );
1972
- }
1976
+ if (ret )
1977
+ qgroup_mark_inconsistent (fs_info , "qgroup item update error %d" , ret );
1973
1978
1974
1979
out :
1975
1980
mutex_unlock (& fs_info -> qgroup_ioctl_lock );
@@ -2024,7 +2029,7 @@ int btrfs_qgroup_trace_extent_nolock(struct btrfs_fs_info *fs_info,
2024
2029
ret = __xa_store (& delayed_refs -> dirty_extents , index , record , GFP_ATOMIC );
2025
2030
xa_unlock (& delayed_refs -> dirty_extents );
2026
2031
if (xa_is_err (ret )) {
2027
- qgroup_mark_inconsistent (fs_info );
2032
+ qgroup_mark_inconsistent (fs_info , "xarray insert error: %d" , xa_err ( ret ) );
2028
2033
return xa_err (ret );
2029
2034
}
2030
2035
@@ -2091,10 +2096,8 @@ int btrfs_qgroup_trace_extent_post(struct btrfs_trans_handle *trans,
2091
2096
2092
2097
ret = btrfs_find_all_roots (& ctx , true);
2093
2098
if (ret < 0 ) {
2094
- qgroup_mark_inconsistent (fs_info );
2095
- btrfs_warn (fs_info ,
2096
- "error accounting new delayed refs extent (err code: %d), quota inconsistent" ,
2097
- ret );
2099
+ qgroup_mark_inconsistent (fs_info ,
2100
+ "error accounting new delayed refs extent: %d" , ret );
2098
2101
return 0 ;
2099
2102
}
2100
2103
@@ -2586,7 +2589,7 @@ static int qgroup_trace_subtree_swap(struct btrfs_trans_handle *trans,
2586
2589
out :
2587
2590
btrfs_free_path (dst_path );
2588
2591
if (ret < 0 )
2589
- qgroup_mark_inconsistent (fs_info );
2592
+ qgroup_mark_inconsistent (fs_info , "%s error: %d" , __func__ , ret );
2590
2593
return ret ;
2591
2594
}
2592
2595
@@ -2630,7 +2633,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
2630
2633
* mark qgroup inconsistent.
2631
2634
*/
2632
2635
if (root_level >= drop_subptree_thres ) {
2633
- qgroup_mark_inconsistent (fs_info );
2636
+ qgroup_mark_inconsistent (fs_info , "subtree level reached threshold" );
2634
2637
return 0 ;
2635
2638
}
2636
2639
@@ -3130,10 +3133,12 @@ int btrfs_run_qgroups(struct btrfs_trans_handle *trans)
3130
3133
spin_unlock (& fs_info -> qgroup_lock );
3131
3134
ret = update_qgroup_info_item (trans , qgroup );
3132
3135
if (ret )
3133
- qgroup_mark_inconsistent (fs_info );
3136
+ qgroup_mark_inconsistent (fs_info ,
3137
+ "qgroup info item update error %d" , ret );
3134
3138
ret = update_qgroup_limit_item (trans , qgroup );
3135
3139
if (ret )
3136
- qgroup_mark_inconsistent (fs_info );
3140
+ qgroup_mark_inconsistent (fs_info ,
3141
+ "qgroup limit item update error %d" , ret );
3137
3142
spin_lock (& fs_info -> qgroup_lock );
3138
3143
}
3139
3144
if (btrfs_qgroup_enabled (fs_info ))
@@ -3144,7 +3149,8 @@ int btrfs_run_qgroups(struct btrfs_trans_handle *trans)
3144
3149
3145
3150
ret = update_qgroup_status_item (trans );
3146
3151
if (ret )
3147
- qgroup_mark_inconsistent (fs_info );
3152
+ qgroup_mark_inconsistent (fs_info ,
3153
+ "qgroup status item update error %d" , ret );
3148
3154
3149
3155
return ret ;
3150
3156
}
@@ -3551,7 +3557,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
3551
3557
if (!committing )
3552
3558
mutex_unlock (& fs_info -> qgroup_ioctl_lock );
3553
3559
if (need_rescan )
3554
- qgroup_mark_inconsistent (fs_info );
3560
+ qgroup_mark_inconsistent (fs_info , "qgroup inherit needs a rescan" );
3555
3561
if (qlist_prealloc ) {
3556
3562
for (int i = 0 ; i < inherit -> num_qgroups ; i ++ )
3557
3563
kfree (qlist_prealloc [i ]);
@@ -4785,7 +4791,7 @@ int btrfs_qgroup_add_swapped_blocks(struct btrfs_root *subvol_root,
4785
4791
spin_unlock (& blocks -> lock );
4786
4792
out :
4787
4793
if (ret < 0 )
4788
- qgroup_mark_inconsistent (fs_info );
4794
+ qgroup_mark_inconsistent (fs_info , "%s error: %d" , __func__ , ret );
4789
4795
return ret ;
4790
4796
}
4791
4797
@@ -4863,10 +4869,9 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,
4863
4869
free_extent_buffer (reloc_eb );
4864
4870
out :
4865
4871
if (ret < 0 ) {
4866
- btrfs_err_rl (fs_info ,
4867
- "failed to account subtree at bytenr %llu: %d" ,
4868
- subvol_eb -> start , ret );
4869
- qgroup_mark_inconsistent (fs_info );
4872
+ qgroup_mark_inconsistent (fs_info ,
4873
+ "failed to account subtree at bytenr %llu: %d" ,
4874
+ subvol_eb -> start , ret );
4870
4875
}
4871
4876
return ret ;
4872
4877
}
0 commit comments