linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Possible data race on btrfs_set_block_group_used(&cache->item, ...) when two syncfs runs in parallel
@ 2019-11-28  2:15 Meng Xu
  0 siblings, 0 replies; only message in thread
From: Meng Xu @ 2019-11-28  2:15 UTC (permalink / raw)
  To: linux-btrfs

Hi Btrfs Developer,

I am writing to report a data race between
btrfs_set_block_group_used(&cache->item, ...) and memcpy() while both
threads are running syncfs. Following is the call stack observed at
run time. I can confirm that the order of the [READ] and [WRITE]
statements are not deterministic.

[Setup]
create("bar", 511) = 3;
dup2(3, 198) = 198;
open("baz", 2097152, 511) = 4;


[Thread 1]
syncfs(4);

__do_sys_syncfs
  sync_filesystem
    __sync_filesystem
      btrfs_sync_fs
        btrfs_commit_transaction
          btrfs_start_dirty_block_groups
            write_one_cache_group
              write_extent_buffer
                [READ] memcpy(kaddr + offset, src, cur)  (src is the
pointer read)


[Thread 2]
syncfs(198);

__do_sys_syncfs
  sync_filesystem
    __sync_filesystem
      btrfs_sync_fs
        btrfs_commit_transaction
          btrfs_run_delayed_refs
            __btrfs_run_delayed_refs
               btrfs_run_delayed_refs_for_head
                 run_one_delayed_ref
                   run_delayed_tree_ref
                     alloc_reserved_tree_block
                       btrfs_update_block_group
                         btrfs_set_block_group_used
                           [WRITE]
btrfs_set_block_group_used(&cache->item, old_val);

Would you mind confirming whether this is a valid data race and
whether this might lead to inconsistent states on disk?

Best Regards,
Meng

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-28  2:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-28  2:15 Possible data race on btrfs_set_block_group_used(&cache->item, ...) when two syncfs runs in parallel Meng Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).