trapexit / mergerfs

a featureful union filesystem
http://spawn.link
Other
4.32k stars 174 forks source link

Android smb clients issue on remove files. #1337

Open serj-47 opened 6 months ago

serj-47 commented 6 months ago

My mergerfs pool consists of two disks and is used to share both disks over the network using the samba protocol, the pool is mounted as follows:

/srv/ST32000641AS:/srv/WD20SPZX /srv/pool mergerfs cache.files=off,dropcacheonclose=true,category.create=epff,fsname=mergerfs,ignorepponrename=true,minfreespace=10G 0 0

smb.conf:

...
[Storage]
path=/srv/pool/Storage
browseable=yes
writeable=yes
only guest=yes
create mask=0777
directory mask=0777
public=yes

So, samba clients with Windows OS or Linux OS can easily access the pool using the samba protocol, and can create, move and delete files and there are no problems. But there are some problems with smb clients on Android. Here is a list of file managers for android that I have tried: -Total Commander, (you need to install a separate plugin to work with smb). -Material Files In both file managers can create and move files on the samba server, but when trying to delete an error occurs about the inability to delete a directory or file. *There is no such problem when sharing a shared directory on a disk without mergerfs.

trapexit commented 6 months ago

Please provide the requested info as defined in the ticket you filled out and in the support section of the page.

joaopedrolages commented 5 months ago

i Have the same issue using mergerfs as OMV 7 plugin When i delete a file on android (total comander or File manager) using SMB share i get the error : The Samba 'panic action' script, /usr/share/samba/panic-action, was called for PID 6018 ().

This means there was a problem with the program, such as a segfault. However, the executable could not be found for process 6018. It may have died unexpectedly, or you may not have permission to debug the process.

First i had the error with NTFS on 2 disks but i deleted them and reformated to BTRFS and i get the same error.

No problem with windows

Once i saw user ADB in SMB diagnotics report.

trapexit commented 5 months ago

As I said above I need details as described in the ticket creation page and the support section of the docs. If the app is dying that's not mergerfs' fault. Nothing mergerfs does should cause an app to die. That would be a bug on their side.

serj-47 commented 5 months ago

As described in the mergerfs wiki, I see that there may be problems with deleting or moving files in some file managers that do not follow the rfc when working with smb, or something like that. Therefore, I tried several file managers with a built-in smb client available in android, as a result, the 'amaze file manager' perfectly deletes files from mergerfs share and there are no errors.

schrock commented 3 months ago

I am experiencing the same issue as described in this bug report, so here are the details:

Describe the bug

When attempting to delete files on a Samba share hosting files in a mergerfs volume via the Android Solid Explorer client app, the Samba service crashes, and the client app complains about an unknown error. Despite the crash, the file is deleted from the mergerfs volume. The crash and associated error does not occur when deleting files on a Samba share hosting files in a regular volume.

As reported by @serj-47, the Amaze File Manager app does not cause Samba to crash.

Please be sure to use latest release of mergerfs to ensure the issue still exists. Not your distro's latest but the latest official release.

I am using mergerfs v2.40.2.

To Reproduce

Steps to reproduce the behavior. List all steps to reproduce. All settings.

Please simplify the reproduction as much as possible.

Relevant portion of /etc/fstab:

/dev/sdb2 /mnt/sdb btrfs defaults 0 0
/dev/sdc2 /mnt/sdc btrfs defaults 0 0
/dev/sdd2 /mnt/sdd btrfs defaults 0 0
/dev/sde2 /mnt/sde btrfs defaults 0 0
/mnt/sd* /mnt/media mergerfs category.create=eppfrd,minfreespace=20G,cache.files=off,dropcacheonclose=true 0 0

Relevant portion of /etc/samba/smb.conf:

[media]
  path = /mnt/media
  browseable = yes
  writable = yes
  read only = no
  valid users = schrock
  guest ok = no

[sdb]
  path = /mnt/sdb
  browseable = yes
  writable = yes
  read only = no
  valid users = schrock
  guest ok = no

Steps to reproduce:

  1. On the server, create a test file in the root of the mergerfs volume like so: touch /mnt/media/file0
  2. In the Android Solid Explorer app, connect to the Samba share media and delete file0.

Expected behavior

The file should be deleted cleanly without Samba crashing on the server or producing any errors on the client.

System information:

trapexit commented 3 months ago

Thank you for the detailed report but samba is crashing itself. This really should be a report to them. Even if mergerfs was returning something odd it shouldn't panic. And looking at the strace shows smbd unlinking "file0" and then closing the fd. Both succeed and look fine. I just tried using Solid Explorer to create and delete a file using samba 4.19.6. No crash.

BTW, your traces are from different times. Your mergerfs trace is minutes after the smbd one.

schrock commented 3 months ago

Thank you for looking at the log files. The thing I find interesting is that I have two Samba shares, one for a regular volume and another for the mergerfs volume. The Samba crash only occurs when deleting files from the mergerfs volume, not the regular volume, which makes me think mergerfs is doing something differently, triggering a different code path in Samba and causing it to crash. I will do some more debugging on my side and see if I can get Samba to log more information.

trapexit commented 3 months ago

At the end of the day a filesystem function is pretty straight forward in that it returns a standard Unix "return int or -1 with errno" and does the thing mentioned. And all of this goes through the kernel which has lots of validation checks. The only "different" thing mergerfs can be doing really is the filesystem behavior itself which of course could cause issues but those are Samba issues in that it is expecting something that may or many not be valid. It certainly shouldn't be issuing a panic because it got confused. Lots of filesystems are not fully POSIX compliant and should at most error gracefully.

I'm not saying this isn't something that could be addressed by mergerfs. What I'm saying is that step one is to understand why Samba panics and kills itself for something that simply can not worth doing that over. That trace from the log isn't detailed enough for me to guess why that is. You have to remember that Samba is complex and it isn't as simple as "you say delete files, samba issues delete, mergerfs delete." There could be hundreds of other syscalls and things going on otherwise.

Gloryandel commented 3 weeks ago

Although the results returned by different samba clients may fail when deleting files, in reality, it was successful and the files were deleted. Everything is normal on Windows. Samba did not report any errors. ES indicates failure, Mix indicates success. samba: ArchLinux samba 2:4.21.1-1 1730338954878

trapexit commented 3 weeks ago

Again... really need to know what the specifics are of the error from the app's perspective or why samba panics.