All of lore.kernel.org
 help / color / mirror / Atom feed
* potential data race on disk_i_size in two btrfs_endio_writer_helper()
@ 2019-11-28  3:44 Meng Xu
  0 siblings, 0 replies; only message in thread
From: Meng Xu @ 2019-11-28  3:44 UTC (permalink / raw)
  To: linux-btrfs

Hi Btrfs Developers,

I found a potential data race around the disk_i_size in btrfs inodes.
Following is the call stack in the helper threads.

[Thread 1]
btrfs_endio_write_helper
  normal_work_helper
    finish_ordered_fn
      btrfs_finish_ordered_io
        btrfs_ordered_update_i_size
          [WRITE] BTRFS_I(inode)->disk_i_size = new_i_size;

[Thread 2]
btrfs_endio_write_helper
  normal_work_helper
    finish_ordered_fn
      btrfs_finish_ordered_io
        insert_reserved_file_extent
          __btrfs_drop_extents
            [READ] if (start >= BTRFS_I(inode)->disk_i_size && !replace_extent)

I can confirm that the read and write may happen in close proximity
(in time) and the READ may get either the old value or the new value
of the disk_i_size. Is this a valid data race or some operation
designed for lock-free accesses?

Best Regards,
Meng

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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28  3:44 potential data race on disk_i_size in two btrfs_endio_writer_helper() Meng Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.