linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* potential data race on `delayed_rsv->full`
@ 2019-10-15 18:33 Meng Xu
  2019-11-01 15:45 ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Meng Xu @ 2019-10-15 18:33 UTC (permalink / raw)
  To: linux-btrfs

Hi Btrfs maintainers,

I am reporting a potential data race around the `delayed_rsv->full` field.

[thread 1] mount a btrfs image, a kernel thread of uuid_rescan will be created

btrfs_uuid_rescan_kthread
  btrfs_end_transaction
    __btrfs_end_transaction
      btrfs_trans_release_metadata
        btrfs_block_rsv_release
          __btrfs_block_rsv_release
            --> [READ] else if (block_rsv != global_rsv && !delayed_rsv->full)
                                                            ^^^^^^^^^^^^^^^^^


[thread 2] do a mkdir syscall on the mounted image

__do_sys_mkdir
  do_mkdirat
    vfs_mkdir
      btrfs_mkdir
        btrfs_new_inode
          btrfs_insert_empty_items
            btrfs_cow_block
              __btrfs_cow_block
                alloc_tree_block_no_bg_flush
                  btrfs_alloc_tree_block
                    btrfs_add_delayed_tree_ref
                      btrfs_update_delayed_refs_rsv
                        --> [WRITE] delayed_rsv->full = 0;
                                    ^^^^^^^^^^^^^^^^^^^^^


I could confirm that this is a data race by manually adding and adjusting
delays before the read and write statements although I am not very sure
about the implication of such a data race (e.g., crashing btrfs or causing
violations of assumptions). I would appreciate if you could help check on
this potential bug and advise whether this is a harmful data race or it
is intended.

Best Regards,
Meng

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-05 10:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 18:33 potential data race on `delayed_rsv->full` Meng Xu
2019-11-01 15:45 ` David Sterba
2019-11-01 17:09   ` Meng Xu
2019-11-01 18:16     ` Josef Bacik
2019-11-05 10:01       ` David Sterba

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).