coreutils
[Top][All Lists]
Advanced

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

Re: some concern about the fix of " tail: consistently output all data f


From: Pádraig Brady
Subject: Re: some concern about the fix of " tail: consistently output all data for truncated files"
Date: Wed, 9 Nov 2016 14:12:29 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 09/11/16 01:35, Lian, George (Nokia - CN/Hangzhou) wrote:
> Hi, 
>> What network file system type is this?
> 
> The file systems is GlusterFS of Redhat, 
> 
>> This stale st_size behavior, giving a smaller value _after_ a read,seems 
>> quite problematic to lots of apps though, not just tail(1).
> I agree, but I still suppose more application will do get st_size first then 
> do seek and read which will not over the size of file.
> 
> We also have submit the issue to GlusterFS community, but till now, they 
> can't find the root cause in glusterfs.
> 
> I still complain to "tail application", even if there has some issue on 
> glusterfs, 
> but "tail" eat all the space of the disk (by continues pseudo-truncate for a 
> large syslog file)  , I suggest "tail" could do some change to prevent it.

How about something like this?
I.E be careful not to read more than st_size.

This should avoid the incoherency of a stat() giving
smaller st_size _after_ having read() a larger amount.
Note I still think that's a bad glusterfs bug as the
client system should update its attribute cache when
reading data to the local system.

Now this has the disadvantage of possibly splitting data
over more ==> file headers <== than strictly needed,
but I've also limited to remote files here, so that's
ok I think.

Note the old code (before v8.24) that ignored all existing
data in a truncated file would have also output repeated data
in this case I think, as it did a seek() back to the smaller
st_size. Not so much I suppose that it was problematic in
disk space at least, but still not confusing.

cheers,
Pádraig.

diff --git a/src/tail.c b/src/tail.c
index 96982ed..f002db6 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1222,7 +1222,10 @@ tail_forever (struct File_spec *f, size_t n_files, double

           bytes_read = dump_remainder (name, fd,
                                        (f[i].blocking
-                                        ? COPY_A_BUFFER : COPY_TO_EOF));
+                                        ? COPY_A_BUFFER :
+                                          S_ISREG (mode) && f[i].remote
+                                          ? stats.st_size - f[i].size :
+                                            COPY_TO_EOF));
           any_input |= (bytes_read != 0);
           f[i].size += bytes_read;
         }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]