]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Btrfs: fix race in check-integrity caused by usage of bitfield
authorStefan Behrens <sbehrens@giantdisaster.de>
Tue, 27 Nov 2012 16:10:21 +0000 (16:10 +0000)
committerChris Mason <chris.mason@fusionio.com>
Mon, 17 Dec 2012 01:46:13 +0000 (20:46 -0500)
The structure member mirror_num is modified concurrently to the
structure member is_iodone. This doesn't require any locking by
design, unless everything is stored in the same 32 bits of a
bit field. This was the case and xfstest 284 was able to
trigger false warnings from the checker code. This patch
seperates the bits and fixes the race.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/check-integrity.c

index badc6f141b6fd9b90ad7c5b488804fe4ad4bf8e6..11d47bfb62b418f6f4d5459d8c02a18b05c3731b 100644 (file)
@@ -137,7 +137,7 @@ struct btrfsic_block {
        unsigned int never_written:1;   /* block was added because it was
                                         * referenced, not because it was
                                         * written */
-       unsigned int mirror_num:2;      /* large enough to hold
+       unsigned int mirror_num;        /* large enough to hold
                                         * BTRFS_SUPER_MIRROR_MAX */
        struct btrfsic_dev_state *dev_state;
        u64 dev_bytenr;         /* key, physical byte num on disk */