[linux-cifs-client] SMB_COM_CLOSE and LastWriteTime

Jeff Layton jlayton at redhat.com
Wed Apr 23 15:42:58 GMT 2008


On Wed, 23 Apr 2008 17:22:25 +0200
Guenter Kukkukk <linux at kukkukk.com> wrote:

> Am Mittwoch, 23. April 2008 schrieb Jeff Layton:
> > I've had a couple of people open bugs complaining that "cp -p" to a
> > Linux CIFS mount of a Windows share doesn't properly preserve the
> > mtime. It appears that the system calls relating to the destination
> > file are something like:
> > 
> > open()
> > write(), write(), ...
> > futimes()
> > close()
> > 
> > I wrote a small test program to see where it was falling down, and what
> > seems to happen is that the futimes() call sets the time properly on
> > the server but then the close() makes the server clobber the mtime.
> > 
> > On the wire, I can see a SET_PATH_INFO call that sets the mtime, and
> > then the client sends a close request with the last write time set to
> > 0xffffffff. Wireshark interprets this as "no time specified".
> > 
> > After this Close request, the windows server (win2k3 in this case) sets
> > the mtime to the current time of the server. Interestingly samba seems
> > to handle this "correctly" and doesn't change the mtime on the close.
> > 
> > This really seems like a Windows bug IMO, but since windows is really
> > the reference implementation, perhaps CIFS is doing this wrong. Does
> > anyone have insight into what value we should be sending in the
> > LastWriteTime to tell windows not to touch the mtime? Or is there some
> > other way to make this happen?
> > 
> > Thanks,
> 
> Hi Jeff,
> 
> have a look at my post "[linux-cifs-client] Re: timestamp problems with cp -p"
> dated 13th March 2008.
> Included there is a _first_ patch which solved this problem for me - but there's 
> another place in the source, where a similar code sequence is used.
> I've written a test applet to check the circumstances.
> Will add some more info about that later today - need to go now.
> 
> See some further notes and listings in my 3 posts 
> "linux-cifs-client] Re: set last write time = fsync ?" dated 14th March 2008.
> 

Thanks Guenter,
    From what I can tell, the server is respecting the SET_PATH_INFO
call and setting the mtime, it's just that the close is clobbering it.
BTW: I'm testing this with 2.6.25 and I'm pretty sure that the patch to
force a flush on mtime changes is in place.

    Attached is a small test program I used to verify this. When I run
this, I can see the mtime being set to the given value on the server.
But then it gets reset when the close call comes in.

   It seems like the file has the proper contents, so it doesn't
really seem like the server is buffering up the writes, but I'm no
expert in windows internals :-)

-- 
Jeff Layton <jlayton at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: write-time-test.c
Type: text/x-csrc
Size: 750 bytes
Desc: not available
Url : http://lists.samba.org/archive/linux-cifs-client/attachments/20080423/3c215297/write-time-test-0001.bin


More information about the linux-cifs-client mailing list