potential data race on disk_i_size in two btrfs_endio_writer_helper()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux