hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/btrfs/scrub.c
....@@ -3559,13 +3559,20 @@
35593559 ret = btrfs_inc_block_group_ro(cache, sctx->is_dev_replace);
35603560 if (ret == 0) {
35613561 ro_set = 1;
3562
- } else if (ret == -ENOSPC && !sctx->is_dev_replace) {
3562
+ } else if (ret == -ENOSPC && !sctx->is_dev_replace &&
3563
+ !(cache->flags & BTRFS_BLOCK_GROUP_RAID56_MASK)) {
35633564 /*
35643565 * btrfs_inc_block_group_ro return -ENOSPC when it
35653566 * failed in creating new chunk for metadata.
35663567 * It is not a problem for scrub, because
35673568 * metadata are always cowed, and our scrub paused
35683569 * commit_transactions.
3570
+ *
3571
+ * For RAID56 chunks, we have to mark them read-only
3572
+ * for scrub, as later we would use our own cache
3573
+ * out of RAID56 realm.
3574
+ * Thus we want the RAID56 bg to be marked RO to
3575
+ * prevent RMW from screwing up out cache.
35693576 */
35703577 ro_set = 0;
35713578 } else if (ret == -ETXTBSY) {