Merge tag 'for-5.12/block-ipi-2021-02-21' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / fs / erofs / zmap.c
index ae32554..14d2de3 100644 (file)
@@ -36,8 +36,14 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
        void *kaddr;
        struct z_erofs_map_header *h;
 
-       if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags))
+       if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) {
+               /*
+                * paired with smp_mb() at the end of the function to ensure
+                * fields will only be observed after the bit is set.
+                */
+               smp_mb();
                return 0;
+       }
 
        if (wait_on_bit_lock(&vi->flags, EROFS_I_BL_Z_BIT, TASK_KILLABLE))
                return -ERESTARTSYS;
@@ -83,6 +89,8 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
 
        vi->z_physical_clusterbits[1] = vi->z_logical_clusterbits +
                                        ((h->h_clusterbits >> 5) & 7);
+       /* paired with smp_mb() at the beginning of the function */
+       smp_mb();
        set_bit(EROFS_I_Z_INITED_BIT, &vi->flags);
 unmap_done:
        kunmap_atomic(kaddr);