Re: Appending to an open file - O_APPEND flag

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

 



Hi!

I mount cephfs using kernel client (3.10.0-229.11.1.el7.x86_64).

The effect is the same when doing "echo >>" from another machine and from a machine keeping the file open.

The file is opened with open( ..,  O_WRONLY|O_LARGEFILE|O_APPEND|O_BINARY|O_CREAT)

Shell ">>" is implemented as (from strace bash -c "echo '7789' >>  /mnt/ceph/test):

    open("/mnt/ceph/test", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3

The test file had ~500KB size.

Each subsequent "echo >>" writes to the start of the test file, first "echo" overwriting the original contents, next "echos" overwriting bytes written by the preceding "echo".

Thanks!

J.


On 01.09.2015 18:15, Gregory Farnum wrote:


On Sep 1, 2015 4:41 PM, "Janusz Borkowski" <janusz.borkowski@xxxxxxxxxxxxxx> wrote:
>
> Hi!
>
> open( ... O_APPEND) works fine in a single system. If many processes write to the same file, their output will never overwrite each other.
>
> On NFS overwriting is possible, as appending is only emulated - each write is preceded by a seek to the current file size and race condition may occur.
>
> How it is in cephfs?

CephFS generally ought to handle appends correctly. If it's not we will want to fix that.

>
> I have a file F opened with  O_APPEND|O_WRONLY by some process. In a console I type
>
>     $ echo "asd" >> F
>
> Effectively, this is opening of file F by another process with O_APPEND flag .
>
> The string "asd" is written to the beginning of file F, overwriting the starting bytes in the file. Is it a bug or a feature? If a feature, how it is described?

Are you doing this in the same box that's got the the file open, or a different one? Are you using the ceph-fuse or kernel clients on the systems?

I'm not sure how the shell actually handles >> so I'd like to see this reproduced with strace or an example program to be sure it's really not handling append properly.
-Greg

>
> It is ceph Hammer and kernel 3.10.0-229.11.1.el7.x86_64
>
> Thanks!
>
> J.
>
> _______________________________________________
> ceph-users mailing list
> ceph-users@xxxxxxxxxxxxxx
> http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com


_______________________________________________
ceph-users mailing list
ceph-users@xxxxxxxxxxxxxx
http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com

[Index of Archives]     [Information on CEPH]     [Linux Filesystem Development]     [Ceph Development]     [Ceph Large]     [Ceph Dev]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [xfs]


  Powered by Linux