cifs/samba mount not preserving file timestamps
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Jammy |
Incomplete
|
Undecided
|
Unassigned |
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'
* 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://
500 http://
100 /var/lib/
2:6.9-1 500
500 http://
$ 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,
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://
500 http://
100 /var/lib/
2:6.14-1build1 500
500 http://
$ 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,
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.
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: 13634663 Links: 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/
File: /media/
Size: 1048576 Blocks: 2064 IO Block: 1048576 regular file
Device: 52h/82d Inode: 321811 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/desktop_user) Gid: ( 1000/desktop_user)
Access: 2023-02-12 18:38:25.671230900 -0700
Modify: 2023-02-12 18:35:48.978743300 -0700
Change: 2023-02-12 18:35:48.978743300 -0700
Birth: -
5. rsync again, notice the file is correctly skipped.
$ rsync -avh test1.txt /media/scratch/
sending incremental file list
sent 68 bytes received 12 bytes 160.00 bytes/sec
total size is 1.05M speedup is 13,107.20
6. repeat the same steps above on the newer 22.04 laptop, only this time notice that the modify/change are NOT preserved. rsync re-sends the file because modified time changed.
$ fallocate -l 1M test2.txt
$ stat test2.txt
File: test2.txt
Size: 1048576 Blocks: 2048 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 526622 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ laptop_user) Gid: ( 1000/ laptop_user)
Access: 2023-02-12 18:42:55.467521856 -0700
Modify: 2023-02-12 18:42:55.467521856 -0700
Change: 2023-02-12 18:42:55.467521856 -0700
Birth: 2023-02-12 18:42:55.467521856 -0700
$ rsync -avh test2.txt /media/scratch/
sending incremental file list
test2.txt
sent 1.05M bytes received 35 bytes 2.10M bytes/sec
total size is 1.05M speedup is 1.00
$ stat /media/
File: /media/
Size: 1048576 Blocks: 2064 IO Block: 1048576 regular file
Device: 54h/84d Inode: 565291 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ laptop_user) Gid: ( 1000/ laptop_user)
Access: 2023-02-12 18:43:24.265024500 -0700
Modify: 2023-02-12 18:43:24.265024500 -0700
Change: 2023-02-12 18:43:24.265024500 -0700
Birth: 2023-02-12 18:43:24.248938600 -0700
$ rsync -avh test2.txt /media/scratch/
sending incremental file list
test2.txt
sent 1.05M bytes received 35 bytes 2.10M bytes/sec
total size is 1.05M speedup is 1.00
$ stat /media/
File: /media/
Size: 1048576 Blocks: 2064 IO Block: 1048576 regular file
Device: 54h/84d Inode: 565292 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ laptop_user) Gid: ( 1000/ laptop_user)
Access: 2023-02-12 18:43:45.413195300 -0700
Modify: 2023-02-12 18:43:45.413195300 -0700
Change: 2023-02-12 18:43:45.413195300 -0700
Birth: 2023-02-12 18:43:45.398091900 -0700
As best I can tell I am doing _everything_ EXACTLY the same way. Word for word. The remote system is the same device, same share, same directory. The only difference is the software version, and the extra options thrown in automatically when mounting a cifs share. I've tried to 'unspecify' those extra bits but it still happens.
I'd tag this to a proper package, but i'm not sure if this is cifs-tools, or something else entirely.
The only thing I can find online that's possibly similar is this ask ubuntu thread:
https:/
It sure looks like the same thing, but no solutions are presented.
affects: | ubuntu → samba (Ubuntu) |
Changed in samba (Ubuntu): | |
status: | Fix Released → Incomplete |
status: | Incomplete → Fix Released |
Changed in samba (Ubuntu Jammy): | |
status: | New → Incomplete |
tags: | added: server-todo |
Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https:/ /wiki.ubuntu. com/Bugs/ FindRightPackag e. You might also ask for help in the #ubuntu-bugs irc channel on Libera.chat.
To change the source package that this bug is filed about visit https:/ /bugs.launchpad .net/ubuntu/ +bug/2007055/ +editstatus and add the package name in the text box next to the word Package.
[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]