[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-02-02 Thread Nicholas Neumann
Unfortunately I don't feel like I have enough understanding of why
things are working for you given the versions you are dealing with. The
whole thing seems like a complex compatibility matrix of client version,
server version, and negotiated SMB protocol version. I've seen enough
code changes and similar problems to now have validating timestamp
behavior on my to-do checklist on any server (Samba) or client (cifs-
utils) version upgrade.

In general I would say the more recent you are with both, the more
likely it seems that modtimes will work. In my limited experience, the
latest cifs-utils emitted significantly cleaner SMB requests when
preserving modification times.

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  the remote NAS is a synology appliance, running Samba version 4.10.18.
  SMB version 3

  Steps to reproduce:
  1. Similar setup, 1 device running 20.04, another running 22.04, otherwise up 
to date.

  2. mount the NAS on both devices the exact same way
  $ sudo mount -t cifs -o 
vers=3.0,credentials=/etc/samba/smbcreds,iocharset=utf8,rw,uid=1000,gid=1000,dir_mode=0775,file_mode=0664
 //nas/backup /media/scratch

  3. on the 20.04 older desktop, create a test file and show the modify time
  $ fallocate -l 1M test1.txt
  $ stat test1.txt
File: test1.txt
Size: 1048576 Blocks: 2048   IO Block: 4096   regular file
  Device: 801h/2049d  Inode: 13634663Links: 1
  Access: (0664/-rw-rw-r--)  Uid: ( 1000/desktop_user)   Gid: ( 
1000/desktop_user)
  Access: 2023-02-12 18:35:48.978743377 -0700
  Modify: 2023-02-12 

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-02-02 Thread Nicholas Neumann
I kept digging into my specific issue, and now have to add a 4th
dimension to the matrix of variables to consider that can affect modtime
preservation: Samba configuration values. Here are the details.

For my issue, modtimes are not preserved on Synology devices due to the
Synology's default SMB Advanced Setting in the "Others" section of its
UI, "Synchronize data to drive immediately upon SMB client request"

This preference controls the smb "strict sync" configuration value. It
was changed from False to True 6 years ago in Samba 4.7.0:
https://gitlab.com/samba-
team/samba/-/commit/ed483d8e570700a303e11bc03d6250cd0ae4aaed

Synology devices still default this value to False though.
Unfortunately, the False value causes a Samba bugfix that helped with
correct modtimes to not work. This bugfix is here:
https://gitlab.com/samba-
team/samba/-/merge_requests/1210/diffs?commit_id=945158c7652bd0580828fb620afc722bc8a05967
.

Unfortunately that bugfix does not work when strict sync is disabled,
because smbd_smb2_flush_send checks lp_strict_sync and returns early
instead of setting the smbd_smb2_flush_done callback to run;
smbd_smb2_flush_done is where one of the modtime-related fixes was made.

(I've double validated that it is this setting that makes the
difference. Setting it to True on the Synology device causes modtimes to
be preserved. Setting it to False on an Ubuntu VM that was preserving
modtimes causes it to stop.)

I passed this info on to Synology in case they are interested in
changing the default value to match what Samba defaults to. I'll also
mention the issue with the Samba bugfix for modtimes to the Samba
project in case they are interested.

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-01-29 Thread Nicholas Neumann
Thanks for sharing that. Your cifs-utils is the same that I have on an
ubuntu 22 VM, which shows the issue with a server running an earlier
version of Samba (4.7.x) and a later version. I unfortunately don't
readily have a VM with 4.8.x readily available, but the brittleness of
file modtime preservation depending on client and server is surprising,
and I can understand the sarcastic comment! :-)

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  the remote NAS is a synology appliance, running Samba version 4.10.18.
  SMB version 3

  Steps to reproduce:
  1. Similar setup, 1 device running 20.04, another running 22.04, otherwise up 
to date.

  2. mount the NAS on both devices the exact same way
  $ sudo mount -t cifs -o 
vers=3.0,credentials=/etc/samba/smbcreds,iocharset=utf8,rw,uid=1000,gid=1000,dir_mode=0775,file_mode=0664
 //nas/backup /media/scratch

  3. on the 20.04 older desktop, create a test file and show the modify time
  $ fallocate -l 1M test1.txt
  $ stat test1.txt
File: test1.txt
Size: 1048576 Blocks: 2048   IO Block: 4096   regular file
  Device: 801h/2049d  Inode: 13634663Links: 1
  Access: (0664/-rw-rw-r--)  Uid: ( 1000/desktop_user)   Gid: ( 
1000/desktop_user)
  Access: 2023-02-12 18:35:48.978743377 -0700
  Modify: 2023-02-12 18:35:48.978743377 -0700
  Change: 2023-02-12 18:35:48.978743377 -0700
   Birth: -

  4. rsync the test file to the mount, stat the file and see the modify/change 
are preserved
  $ rsync -avh test1.txt /media/scratch/
  sending incremental file list
  test1.txt

  sent 1.05M 

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-01-27 Thread Nicholas Neumann
Interesting. Can you run "apt-get -s install cifs-utils" on your client
to see what version of cifs-utils you have installed?

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  the remote NAS is a synology appliance, running Samba version 4.10.18.
  SMB version 3

  Steps to reproduce:
  1. Similar setup, 1 device running 20.04, another running 22.04, otherwise up 
to date.

  2. mount the NAS on both devices the exact same way
  $ sudo mount -t cifs -o 
vers=3.0,credentials=/etc/samba/smbcreds,iocharset=utf8,rw,uid=1000,gid=1000,dir_mode=0775,file_mode=0664
 //nas/backup /media/scratch

  3. on the 20.04 older desktop, create a test file and show the modify time
  $ fallocate -l 1M test1.txt
  $ stat test1.txt
File: test1.txt
Size: 1048576 Blocks: 2048   IO Block: 4096   regular file
  Device: 801h/2049d  Inode: 13634663Links: 1
  Access: (0664/-rw-rw-r--)  Uid: ( 1000/desktop_user)   Gid: ( 
1000/desktop_user)
  Access: 2023-02-12 18:35:48.978743377 -0700
  Modify: 2023-02-12 18:35:48.978743377 -0700
  Change: 2023-02-12 18:35:48.978743377 -0700
   Birth: -

  4. rsync the test file to the mount, stat the file and see the modify/change 
are preserved
  $ rsync -avh test1.txt /media/scratch/
  sending incremental file list
  test1.txt

  sent 1.05M bytes  received 35 bytes  2.10M bytes/sec
  total size is 1.05M  speedup is 1.00
  $ stat /media/scratch/test1.txt 
File: /media/scratch/test1.txt
Size: 1048576 Blocks: 2064   IO Block: 1048576 regular file
  Device: 52h/82d Inode: 321811  Links: 1
  

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-01-26 Thread Nicholas Neumann
Awesome, thanks for the help. Could you run samba -V on the server to
see the samba version running there?

And then on the client, could you run:

cat /proc/mounts

and find the line with your share to see what version of the SMB
protocol it ended up using?

(It'll be a line like:
//10.0.234.59/sambashare /media/ubuntu22btrfs_sambashare cifs 
rw,relatime,vers=3.1.1,cache=strict
)

If you have the time and can run the same script but changing "cp -p" to
"rsync -t" that would be really helpful too. This morning I started
finding scenarios where one of "cp -p"/"rsync -t" would fail but not the
other, depending on protocol.

(Thought I was losing my mind this morning b/c one of my reliable
reproducers had stopped - turned out I had changed the SMB protocol
version on the client to see if it affected my other reproducer - it
didn't, so I forgot I had changed it.)

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  the remote NAS is a synology appliance, running Samba version 4.10.18.
  SMB version 3

  Steps to reproduce:
  1. Similar setup, 1 device running 20.04, another running 22.04, otherwise up 
to date.

  2. mount the NAS on both devices the exact same way
  $ sudo mount -t cifs -o 
vers=3.0,credentials=/etc/samba/smbcreds,iocharset=utf8,rw,uid=1000,gid=1000,dir_mode=0775,file_mode=0664
 //nas/backup /media/scratch

  3. on the 20.04 older desktop, create a test file and show the modify time
  $ fallocate -l 1M test1.txt
  $ stat test1.txt
File: test1.txt
Size: 1048576 Blocks: 2048   IO Block: 4096   regular file
  Device: 

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-01-25 Thread Nicholas Neumann
Oooh, now it gets exciting. You mentioned you were using the RN214,
which runs Netgear ReadyNAS, which appears to be based on a pretty old
version of Debian. So I fired up an Ubuntu 15 VM and created an SMB
share on it. The bug reproduces there...

That gives us a server environment where we can fully debug things, as
opposed to the constrained Synology environment where many tools are
unavailable. I'm happy. :-)

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  the remote NAS is a synology appliance, running Samba version 4.10.18.
  SMB version 3

  Steps to reproduce:
  1. Similar setup, 1 device running 20.04, another running 22.04, otherwise up 
to date.

  2. mount the NAS on both devices the exact same way
  $ sudo mount -t cifs -o 
vers=3.0,credentials=/etc/samba/smbcreds,iocharset=utf8,rw,uid=1000,gid=1000,dir_mode=0775,file_mode=0664
 //nas/backup /media/scratch

  3. on the 20.04 older desktop, create a test file and show the modify time
  $ fallocate -l 1M test1.txt
  $ stat test1.txt
File: test1.txt
Size: 1048576 Blocks: 2048   IO Block: 4096   regular file
  Device: 801h/2049d  Inode: 13634663Links: 1
  Access: (0664/-rw-rw-r--)  Uid: ( 1000/desktop_user)   Gid: ( 
1000/desktop_user)
  Access: 2023-02-12 18:35:48.978743377 -0700
  Modify: 2023-02-12 18:35:48.978743377 -0700
  Change: 2023-02-12 18:35:48.978743377 -0700
   Birth: -

  4. rsync the test file to the mount, stat the file and see the modify/change 
are preserved
  $ rsync -avh test1.txt /media/scratch/
  sending incremental file list
  test1.txt

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-01-25 Thread Nicholas Neumann
So just to make sure I was clear, "fixing" the client to send cleaner
messages does avoid the problem. But (imho) the real issue is on the
server, since other servers can deal with the less clean messages just
fine, and there's nothing wrong (again, imho) with the less clean
messages.

Is that uname -r, etc, on your client machine?

A script to test all of this is a good idea. I started with what you put
and tried to simplify it a bit. This is where I ended up:

#!/bin/bash

source_path=/tmp/mod_time_test_file
target_path=/media/rn214/user/Temp/mod_time_test_file

rm "$source_path"
rm "$target_path"
echo abcd > "$source_path"

#Set date to January 1 2020 at 12:34.56 PM
touch -t "202001011234.56" "$source_path"

cp -p "$source_path" "$target_path"

echo "Copy complete; sleeping 10 seconds before stat"
#We sleep, as smbd actually does work after the cp -p returns.
#An immediate stat may return the current time for the modified timestamp
#even though it will be corrected shortly
sleep 10

source_time=$(stat -c "%y" "$source_path")
target_time=$(stat -c "%y" "$target_path")

echo "Source modtime: $source_time"
echo "Target modtime: $target_time"

if [ "$source_time" = "$target_time" ]; then echo "PASS: Modtime
preserved"; else echo "FAIL: Modtime not preserved"; fi

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  the remote NAS is a synology appliance, running Samba version 4.10.18.
  SMB version 3

  Steps to reproduce:
  1. Similar setup, 1 device running 20.04, another running 22.04, otherwise up 
to date.

  2. mount the NAS on both devices the 

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-01-24 Thread Nicholas Neumann
Here is a comparison of the network captures between an Ubuntu Server
23.10 client and Ubuntu Server 22.04.3 LTS client. The difference noted
is consistent with when the bug reproduces - that is, Windows 10, Ubuntu
Server 23.10, and latest arch all have the SetInfo by itself and the bug
does not reproduce. Ubuntu Server 22.04.3LTS and Ubuntu Server
20.04.6LTS have the SetInfo wrapped, and the bug does reproduce, but
only with Synology as the Server.

With TrueNAS 13.0-U3.1 or Ubuntu 22.04.3 Server LTS as the server, the
bug does not reproduce for any client, even though the SetInfo remains
wrapped for some clients.

** Attachment added: "trace_difference.png"
   
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2007055/+attachment/5741974/+files/trace_difference.png

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  the remote NAS is a synology appliance, running Samba version 4.10.18.
  SMB version 3

  Steps to reproduce:
  1. Similar setup, 1 device running 20.04, another running 22.04, otherwise up 
to date.

  2. mount the NAS on both devices the exact same way
  $ sudo mount -t cifs -o 
vers=3.0,credentials=/etc/samba/smbcreds,iocharset=utf8,rw,uid=1000,gid=1000,dir_mode=0775,file_mode=0664
 //nas/backup /media/scratch

  3. on the 20.04 older desktop, create a test file and show the modify time
  $ fallocate -l 1M test1.txt
  $ stat test1.txt
File: test1.txt
Size: 1048576 Blocks: 2048   IO Block: 4096   regular file
  Device: 801h/2049d  Inode: 13634663Links: 1
  Access: (0664/-rw-rw-r--)  Uid: ( 

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-01-24 Thread Nicholas Neumann
So I've got more investigation results. I no longer think it is the Last
Access difference that is relevant, but rather differences in the SMB
request pattern from the client that triggers buggy server behavior.

First, the updated results:

1. To reproduce, The file must be non-empty. The issue does not
reproduce with an empty file.

2. This reproduces using Ubuntu Server 20.04.6 LTS and 22.04.3 LTS as
the client, and two different Synology NAS machines, one running the
latest DSM 7.1, the other running the latest DSM 7.2. A shared folder on
a "Basic" single disk volume/storage pool is all that is needed.

3. This does not reproduce when the client is the latest archlinux
2024.01.01 ISO or Ubuntu Server 23.10, or with Windows 10 via command
line "copy".

4. This does not reproduce when the *server* is changed to an Ubuntu
22.04.3 LTS box, even when it is running on BTRFS. This is surprising
b/c Ubuntu 22.04.3 LTS and the Synology server both run Samba 4.15.13.

5. This does not reproduce when the server is TrueNAS (running
13.0-U3.1)

So now we can look at a number of network traces and see what is
different. One thing sticks out. The traces are definitely "cleaner" in
the archlinux and ubuntu server 23.10 cases. In Ubuntu 20 and Ubuntu 22,
the packet that sets the file info has that request "wrapped' by create
file/close file SMB messages. In Ubuntu 23.10 and arch, these wrapper
create/close are not present in the packet that sets the file info.

While I don't think Ubuntu 20/22 are doing anything wrong, I could see
the extra create file/close file messages causing the Synology server to
lose track of the fact that the last operation on the file was to set
the mod time, and that when the file is closed it's mod time does not
need to be updated. Then when the final file close message comes in, the
mod time is incorrectly updated (because the file had bytes written to
it before the mod time was set).

Finally, it is worth asking *why* the traces in arch/Ubuntu23 are
cleaner/different. Both of those use cifs-utils 7.0, while Ubuntu 20/22
are on 6.x . But I don't see anything in the 7.0 commits that relates to
this. I may just be looking in the wrong place.

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu 

[Kernel-packages] [Bug 2007055] Re: cifs/samba mount not preserving file timestamps

2024-01-22 Thread Nicholas Neumann
So I encountered this recently as well. I've got some strong evidence
that at least part of the problem is the SMB *server*, specifically a
Synology NAS.

We are migrating from a TrueNAS to Synology, and I noticed the timestamp
issue after rsync'ing files from an Ubuntu 22.04 client. I simplified by
switching to cp -p and then proceeded to grab network captures of
copying a single file from the client via cp -p.

Performing cp -p to the TrueNAS device preserves modification time. The same 
command to the synology device does not. The network captures are very similar. 
Of particular note, they both send the same SMB2_FILE_BASIC_INFO:
SMB2_FILE_BASIC_INFO
Create: No time specified (0)
Last Access: Jan 22, 2024 13:15:35.923752400 Central Standard Time
Last Write: Nov 22, 2023 13:15:09.416423500 Central Standard Time
Last Change: Jan 22, 2024 13:23:52.482749400 Central Standard Time
File Attributes: 0x
Unknown: 

Interestingly, on Windows, where a simple "copy" command line operation 
preserves the file modification time on the Synology share, sends slightly 
different info:
SMB2_FILE_BASIC_INFO
Create: No time specified (0)
Last Access: No time specified (0)
Last Write: Nov 22, 2023 13:15:09.416423500 Central Standard Time
Last Change: Jan 22, 2024 13:34:57.144137700 Central Standard Time
File Attributes: 0x
Unknown: 

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/2007055

Title:
  cifs/samba mount not preserving file timestamps

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Jammy:
  Incomplete

Bug description:
  I think I've found a bug or regression in something when trying to
  mount a remote samba share. Modified/Created times are not properly
  preserved in newer versions of Ubuntu. Because of this, rsync thinks
  files are different based on their modified times and keeps re-syncing
  them.

  I have a NAS on my network, running samba.

  I have two devices, a desktop and laptop. Both are running Ubuntu, and
  set up the exact same way. The desktop is running ubuntu 20.04, the
  laptop 22.04.

  I have mounted the NAS on both devices the exact same way. I attempt
  to copy a file (rsync) the exact same way. On the 20.04 desktop, this
  works perfectly fine. On the 22.04 laptop, the modified times are not
  preserved and set to the current time, preventing things like rsync -t
  from working.

  The only difference i can find is that between the two systems, the newer 
laptop 22.04 mount adds a few more options than the older system to the cifs 
mount options. These are added automatically without being specified explicitly 
(see the mount -v output below): 
  * 'forceuid'/'forcegid' are changed to 'noforceuid'/'noforcegid
  *  iocharset=utf8 added
  *  serverino added

  desktop:

  $ lsb_release -rd
  Description:Ubuntu 20.04.5 LTS
  Release:20.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.9-1ubuntu0.2
Candidate: 2:6.9-1ubuntu0.2
Version table:
   *** 2:6.9-1ubuntu0.2 500
  500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 
Packages
  500 http://security.ubuntu.com/ubuntu focal-security/main amd64 
Packages
  100 /var/lib/dpkg/status
   2:6.9-1 500
  500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
  $ uname -a
  Linux desktop 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v 
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,soft,nounix,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  
  laptop:

  $ lsb_release -rd
  Description:KDE neon 5.26
  Release:22.04
  $ apt-cache policy cifs-utils
  cifs-utils:
Installed: 2:6.14-1ubuntu0.1
Candidate: 2:6.14-1ubuntu0.1
Version table:
   *** 2:6.14-1ubuntu0.1 500
  500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
  500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
  100 /var/lib/dpkg/status
   2:6.14-1build1 500
  500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  $ uname -a
  Linux laptop 5.15.0-60-generic #66-Ubuntu SMP Fri Jan 20 14:29:49 UTC 2023 
x86_64 x86_64 x86_64 GNU/Linux
  $ mount -v
  //nas/backup on /media/scratch type cifs 
(rw,relatime,vers=3.0,cache=strict,username=nas_rw,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.10,file_mode=0664,dir_mode=0775,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

  the remote NAS is a synology appliance, running Samba version 4.10.18.
  SMB version 3

  Steps to reproduce:
  1. Similar setup, 1 device running 20.04,