Sample Header Ad - 728x90

can't delete folders on samba share

0 votes
0 answers
1079 views
I am dealing with a really weird issue I can't identify the cause of. I have a samba share mounted using autofs in Rocky 9.2 with the flags -fstype=cifs,rw,nounix,file_mode=0700,dir_mode=0700,multiuser,sec=krb5,user=username,cruid=username,gid=primarygroup,_netdev. It mounts fine and I can add and delete files fine but folders are behaving very weirdly when I try to delete things. For example the following:
$ mkdir dir
$ mkdir dir/{a,b}
$ touch dir/{a,b}/f{1..5}
$ tree dir
dir
├── a
│   ├── f1
│   ├── f2
│   ├── f3
│   ├── f4
│   └── f5
└── b
    ├── f1
    ├── f2
    ├── f3
    ├── f4
    └── f5

2 directories, 10 files
$ rm --recursive --force --verbose dir
removed 'dir/b/f2'
removed 'dir/b/f4'
removed 'dir/b/f5'
removed 'dir/b/f1'
removed 'dir/b/f3'
removed directory 'dir/b'
removed 'dir/a/f2'
removed 'dir/a/f4'
removed 'dir/a/f5'
removed 'dir/a/f1'
removed 'dir/a/f3'
removed directory 'dir/a'
rm: cannot remove 'dir': Directory not empty
$ tree dir
dir
├── a
└── b

2 directories, 0 files
$ rm --recursive --force --verbose dir
rm: cannot remove 'dir': Directory not empty
$ ls --all --recursive dir # in the output note the lack of . and .. in dir/a and dir/b
dir:
.  ..  a  b

dir/a:

dir/b:
$ rmdir dir/a
rmdir: failed to remove 'dir/a': No such file or directory
$ rmdir dir/b
rmdir: failed to remove 'dir/b': No such file or directory
$ tree dir
dir
├── a
└── b

2 directories, 0 files
$ ls --all --recursive -l dir
dir:
total 0
drwx------. 2 username primarygroup 0 Jun  9 16:23 .
drwx------. 2 username primarygroup 0 Jun  9 16:23 ..
drwx------. 2 username primarygroup 0 Jun  9 16:23 a
drwx------. 2 username primarygroup 0 Jun  9 16:23 b

dir/a:
total 0

dir/b:
total 0
I've tried doing it as root, making the permissions 0777 for both files and directories, and mounting it manually rather than with autofs and I get the same behaviour. No relevant messages seem to be turning up in the logs (not discounting I may not be looking at the right log). Update 1: Switching off SELinux didn't help. Nor did turning off the firewall. Update 2: It seems like restarting autofs will clear them (usually requires a restart). But it won't consistently remove all of them. After 2 restarts and with no extra calls to rm or rmdir the folders had completely disappeared. But I can still recreate the problem. So I guess the SMB server must have the correct information but it's not being represented locally maybe...? Update 3: I turned on logging for cifs. I did this with echo 7 | sudo tee /proc/fs/cifs/cifsFYI. Then when I go through a simpler version of the steps again:
$ mkdir --parent h/a
at the same time in logs we get:
Jun 12 16:04:56 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
$ rm --recursive h
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0x80000006 STATUS_NO_MORE_FILES
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0x80000006 STATUS_NO_MORE_FILES
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:12 localhost kernel: CIFS: Status code returned 0xc0000101 STATUS_DIRECTORY_NOT_EMPTY
$ rm --recursive h
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0x80000006 STATUS_NO_MORE_FILES
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000056 STATUS_DELETE_PENDING
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000056 STATUS_DELETE_PENDING
Jun 12 16:05:27 localhost kernel: CIFS: Status code returned 0xc0000056 STATUS_DELETE_PENDING
$ tree h
h
└── a

1 directory, 0 files
Jun 12 16:07:28 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:07:28 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:07:28 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:07:28 localhost kernel: CIFS: Status code returned 0x80000006 STATUS_NO_MORE_FILES
Jun 12 16:07:28 localhost kernel: CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
Jun 12 16:07:28 localhost kernel: CIFS: Status code returned 0xc0000056 STATUS_DELETE_PENDING
Jun 12 16:07:28 localhost kernel: CIFS: Status code returned 0xc0000056 STATUS_DELETE_PENDING
Asked by BumpySiren (11 rep)
Jun 9, 2023, 04:30 AM
Last activity: Mar 19, 2025, 11:41 AM