matthewr
Posts: 34
Joined: Wed Jul 17, 2019 9:48 am

kernel 5.4.51 breaks cifs: mv cannot overwrite files

Mon Jul 20, 2020 2:01 pm

Hi there

I have a Raspberry Pi 4B that runs a nightly rsync from a local USB disk (ext4) to a NAS (cifs).

The job has worked fine for several months. But in the last few days I am getting rsync errors which stop some files from being transferred. rsync reports "File exists (17)" errors when it is handling an updated file and attempts to rename its temporary copy on the remote destination. See log below.

The errors are associated with the kernel upgrade to 5.4.51. The errors did not occur on 4.19.118 (from apt) or 5.4.50 (from rpi-update). They do occur on 5.4.51 from either apt or rpi-update. See detailed kernel chronology below. Neither rsync (3.1.3) nor cifs-utils (2:6.8-2) have been upgraded recently.

Can anyone advise? I guess as a temporary workaround I could investigate downgrading to 4.19. But it would be good to solve the errors on the current stable kernel in apt. Please let me know if any additional logs or details are needed.

Many thanks!
Matthew

Further details:
rsync command:

Code: Select all

sudo rsync -ah --no-o --no-g --delete-after /mnt/hdd0/backup/ /mnt/nas_pi/backup_nas_copy/
rsync output is:

Code: Select all

rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/.bupindex.DfvqrC" -> "bup/bupindex": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/.bupindex.hlink.pq3IBk" -> "bup/bupindex.hlink": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/.bupindex.meta.BUMlq1" -> "bup/bupindex.meta": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/logs/refs/heads/.aleph.L5EJOK" -> "bup/logs/refs/heads/aleph": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/logs/refs/heads/.percival.JKHxGx" -> "bup/logs/refs/heads/percival": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/logs/refs/heads/.smiley.lyQ5kj" -> "bup/logs/refs/heads/smiley": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/objects/pack/.bup.bloom.Bmr7q8" -> "bup/objects/pack/bup.bloom": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/refs/heads/.aleph.l04WSZ" -> "bup/refs/heads/aleph": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/refs/heads/.percival.hY9WoT" -> "bup/refs/heads/percival": File exists (17)
rsync: rename "/mnt/nas_pi/backup_nas_copy/bup/refs/heads/.smiley.XHDzHL" -> "bup/refs/heads/smiley": File exists (17)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
Kernel chronology:
- until Thursday 16th: using 5.4.50 obtained using rpi-update. No errors.
- Thursday 16th: upgraded to 5.4.51 using rpi-update. Rsync errors.
- Friday 17th: reverted to stable apt kernel (4.19.118) by reinstalling the apt kernel packages. No rsync errors.
- Today: the stable kernel in apt has been upgraded to 5.4.51. Rsync errors.
Last edited by matthewr on Tue Jul 21, 2020 10:02 am, edited 1 time in total.

matthewr
Posts: 34
Joined: Wed Jul 17, 2019 9:48 am

Re: kernel 5.4.51 associated with rsync errors on cifs

Tue Jul 21, 2020 9:33 am

The problem is also encountered using mv. So it's not specific to rsync.

Test:

Expected behaviour:
$ touch foo bar
$ mv -f foo bar

Actual behaviour:
$ touch foo bar
$ mv -f foo bar
mv: cannot move 'foo' to 'bar': File exists

There is a brief reference on StackExchange to a kernel regression introduced in 5.4.51 (which matches my experience above).

matthewr
Posts: 34
Joined: Wed Jul 17, 2019 9:48 am

Re: kernel 5.4.51 associated with rsync errors on cifs

Tue Jul 21, 2020 9:45 am

It appears the 5.4.51 kernel introduced a patch which may have caused the bug:

Zhang Xiaoxu (1):
cifs: Fix the target file was deleted when rename failed.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6154
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: kernel 5.4.51 breaks cifs: mv cannot overwrite files

Tue Jul 21, 2020 10:17 am

Can you create an issue here so we can keep track of this.
It's something that needs to be fixed upstream as it's not pi specific, but we can try to get the fix into official kernels promptly when the fix is identified.


matthewr
Posts: 34
Joined: Wed Jul 17, 2019 9:48 am

Re: kernel 5.4.51 breaks cifs: mv cannot overwrite files

Wed Jul 22, 2020 8:09 am

The 5.4.51 regression only affects the SMB v1 protocol.

Configuring client and server to use SMB v2 or v3 seems to resolve.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6154
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: kernel 5.4.51 breaks cifs: mv cannot overwrite files

Thu Jul 23, 2020 12:47 pm

Issue is confirmed fixed in rpi-update kernel. Will come to apt kernel shortly.

Return to “Troubleshooting”