[linux-cifs-client] SMB_COM_CLOSE and LastWriteTime
linux at kukkukk.com
Thu Apr 24 14:00:11 GMT 2008
Am Mittwoch, 23. April 2008 schrieb Jeff Layton:
> 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 :-)
Hi Jeff, Steve,
i had also written a test applet "settime" some weeks ago - see the
It tries to modify atime and mtime by just reading the current values
and then subtracting about one year for writing them back then. After
a one second delay the now current time values are read again for
During testing the "cp -p ..." problem, i had to add some more functionality
to also simulate
or like in cp -p ...
1.) ./settime mounted_file
just tries to modify the remote time with utimes()
2.) ./settime -o mounted_file
does also open() the file before using utimes() - then a close()
3.) ./setime -w mounted_file
this one is similar to the "cp -p ..." problem
it does the open(), a write(), utimes(), then close()
With these combinations I was able to test some interesting
differences in behaviour.
An additional note:
i get the following, when i use
cp -p foo /mnt/linux/cifs
cp: preserving permissions for `/mnt/linux/cifs/settime.c': Input/output error
I must specify the "noacl" mount option to avoid this.
Happens when mounting recent 3.0.x or 3.2 samba server.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4653 bytes
Desc: not available
Url : http://lists.samba.org/archive/linux-cifs-client/attachments/20080424/cafead98/settime.bin
More information about the linux-cifs-client