Merge tag 'libnvdimm-for-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdim...
[linux-2.6-microblaze.git] / fs / ext4 / balloc.c
index 9dc6e74..a0fb0c4 100644 (file)
@@ -652,8 +652,14 @@ int ext4_should_retry_alloc(struct super_block *sb, int *retries)
         * possible we just missed a transaction commit that did so
         */
        smp_mb();
-       if (sbi->s_mb_free_pending == 0)
+       if (sbi->s_mb_free_pending == 0) {
+               if (test_opt(sb, DISCARD)) {
+                       atomic_inc(&sbi->s_retry_alloc_pending);
+                       flush_work(&sbi->s_discard_work);
+                       atomic_dec(&sbi->s_retry_alloc_pending);
+               }
                return ext4_has_free_clusters(sbi, 1, 0);
+       }
 
        /*
         * it's possible we've just missed a transaction commit here,