Jump to content

Samba (SMB/CIFS) mount NFO saving issues (Debian 11)


Recommended Posts

Posted

I've been pulling my hair out over this; found a workaround here:

Write CIFS file 'permission denied' (Linux) · Issue #42790 · dotnet/runtime · GitHub

For the td;dr, you need to add nobrl to CIFS mounts.

 

For background, I have my media spread across multiple disks, which I like to have spin down when inactive. The media files themselves are symlinked to a standard media directory structure, which contains all the .nfo metadata and images. Unfortunately, Emby doesn't follow regular local symlinks (or at least it didn't when I first starting using it, and I haven't bothered checking since), and so as a solution, I have the media directory set up as a Samba share, which I then mount to a directory using the kernel CIFS module. So, Emby doesn't "see" the symlinks, but instead, it sees them as if they're the media files themselves. This solution worked perfectly on Mint 17 (eventually kernel 4.4) and Mint 19 (kernel 4.15), and also has the advantage of ensuring that if something ever went horribly wrong with an Emby update, it can only delete metadata and not the files themselves.

For the holiday break, I decided to rebuild my server on Debian 11.1.

I copied the old Emby installation across as-is, and then made sure that all permissions were set up. Everything seemed to be working fine, but after adding some new media today, I found that I couldn't save any new metadata. I wasn't aware at first, because Emby's database was saved fine and the web GUI showed everything as normal, and no errors were in the log file (until turning on debug logging) so it just silently failed. But the media directory only contained the video file and no metadata or images. Debug logging showed:

 System.UnauthorizedAccessException: System.UnauthorizedAccessException: Access to the path '/media/smbshares/media/Films/Some Cool Movie (2000)/Some Cool Movie (1998).nfo' is denied.
         ---> System.IO.IOException: Permission denied
           --- End of inner exception stack trace ---
           at System.IO.FileStream.WriteNative(ReadOnlySpan`1 source)
           at System.IO.FileStream.WriteSpan(ReadOnlySpan`1 source)
           at System.IO.FileStream.<>c.<WriteAsyncInternal>b__110_0(Task t, Object s)
           at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
           at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
        --- End of stack trace from previous location where exception was thrown ---
           at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
        --- End of stack trace from previous location where exception was thrown ---
           at NfoMetadata.Savers.BaseNfoSaver.SaveToFile(Stream stream, String path, LibraryOptions libraryOptions, CancellationToken cancellationToken)
           at NfoMetadata.Savers.BaseNfoSaver.Save(BaseItem item, LibraryOptions libraryOptions, CancellationToken cancellationToken)
           at MediaBrowser.Providers.Manager.ProviderManager.SaveMetadata(BaseItem item, LibraryOptions libraryOptions, ItemUpdateType updateType, IMetadataSaver[] savers, CancellationToken cancellationToken)
        Source: System.Private.CoreLib
        TargetSite: Void WriteNative(System.ReadOnlySpan`1[System.Byte])
        InnerException: System.IO.IOException: Permission denied
        Source:
        TargetSite:

I double-checked everything, and the emby user definitely had write access to the directory, both locally and via the CIFS mount. I even went so far as to write an AppArmor profile, but that was not the problem.

The workaround was to add the "nobrl" (disable byte-range locking) mount option to /etc/fstab. I guess something changed either between kernel 4.15 and 5.10, or between Samba 4.7 and 4.13.

Posted

Hi there, have you taken a look at this?

Also just FYI the beta server has updated to .NET 6 which supposedly has a fix for erroneous access denied errors.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...