Re: Is concurrent file read/write with O_DIRECT flag atomic?

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

 



On Sun, Nov 12, 2017 at 9:59 AM, Leo Chen <liangc8367@xxxxxxxxx> wrote:
>
>
> I wrote a program to verify my thought. Surprisingly, the readers did
> occasionally read back mixed data. For example, in the first pwrite(),
> the writer writes all 0x11, and in the 2nd pwrite(), it writes all
> 0x22, and in the 3rd write, it writes all 0x33... Occasionally, a
> reader can read back data like "0x11, 0x11, .... 0x11, 0x22, 0x22....
> 0x22". The data appears to be from two consecutive pwrite() calls. I
> checked the offset where the broken starts. The offset seems to be
> sector-aligned (512-byte-aligned).
>
Just for clarification purpose, the writer loop looks like

    while(true) {
        memset(aligned_buffer, seed, 128KB);
        pwrite(fd, aligned_buffer, 128KB);
        seed++;
    }

the reader loop looks like:
    while(true) {
        pread(fd, aligned_reader_buffer, 128KB);
        verify_aligned_reader_buffer();
    }

Thanks,
Leo



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux