author: Naohiro Aota <naota@elisp.net> 2023-06-06 14:36:35 +0900
committer: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2023-07-19 16:36:56 +0200
commit: f61029274c7024e40ac1d600bc9ef94afc84717c
parent: 9d9586ef1ac9059dfe42b464778963b281f2cfc5
Commit Summary:
Diffstat:
1 file changed, 9 insertions, 2 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 995cc325de59..802865dc8183 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1798,8 +1798,15 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
}
spin_unlock(&bg->lock);
- /* Get out fast, in case we're unmounting the filesystem */
- if (btrfs_fs_closing(fs_info)) {
+ /*
+ * Get out fast, in case we're read-only or unmounting the
+ * filesystem. It is OK to drop block groups from the list even
+ * for the read-only case. As we did sb_start_write(),
+ * "mount -o remount,ro" won't happen and read-only filesystem
+ * means it is forced read-only due to a fatal error. So, it
+ * never gets back to read-write to let us reclaim again.
+ */
+ if (btrfs_need_cleaner_sleep(fs_info)) {
up_write(&space_info->groups_sem);
goto next;
}