SMB / Scanning problems

  • 2 or 3 days ago I started experiencing problems with my Media mount from a Synlogy Box:

    Here's the debug log WQTC

    lsof gives me:

    ---
    760 /usr/lib/kodi/kodi.bin /storage/.kodi/userdata/Database/MyVideos107.db
    760 /usr/lib/kodi/kodi.bin /storage/.kodi/userdata/Database/MyVideos107.db
    760 /usr/lib/kodi/kodi.bin /storage/Media/Series/Battlestar Galactica (2003)
    ---

    As can be seen the problems seems to be scanning the Folder 'Battlestar Galactica (2003) where it hangs either very long or forever, the Series is already in the Library. While scanning the mounted directory is completely stale and nothing can be accessed there (console hangs of I do a 'ls' for example).
    I also tried with a completely new installation on the SD card, unfortunately no success.

    The Media Folder is mounted via the system.d script provided:

    -----
    # This is a sample service script to mount CIFS/SAMBA shares.
    # Please read carefully the comments in this file. For production usage
    # you can remove all comments (lines beginning with "#") from this file.


    [Unit]
    # The description should be used to explain what this servicefile is for
    Description=Media cifs mount script

    # if we do network mounts like here we *require* 'network-online.service'
    # which checks if the network is online
    Requires=network-online.service

    # our scripts must start *after* 'network-online.service', on timeout and if
    # 'network-online.service' fails we can not mount and this scripts fails too
    After=network-online.service

    # usually we mount networks shares because we want they avaible *before* XBMC starts.
    # so XBMC has access to this mounts from beginning. Note: this slows down the boot!
    Before=kodi.service


    [Mount]
    # The share we want mount
    What=//10.0.0.1/Media

    # Where we want mount this share
    Where=/storage/Media

    # Any options you usually use with the "-o" parameter in the mount command
    Options=username=XXXX,password=XXXX

    # filesystem type
    Type=cifs


    [Install]
    # The target is used by 'systemctl enable <name_of_this_file.mount>' to link
    # this service to a runlevel for starting on boot. usually 'multi-user.target'
    # is ok here.
    WantedBy=multi-user.target

    # Important:
    # this file must be renamed to <mountpoint>.mount where <mountpoint>, is the FULL path
    # where the share will be mounted but slashes "/" MUST BE REPLACED with dashes "-" with .mount
    # as extension.
    # This means, if we want mount to "/storage/music2" (see above "Where=/storage/music2")
    # then this file must be renamed to 'storage-music2.mount' and can be enabled via ssh with the
    # command 'systemctl enable storage-music2.mount'

    ----

    Edited once, last by gaelic (October 7, 2016 at 8:38 AM).

  • Just asking the obvious question here: why use mounts via the system.d script, and not directly via the Kodi GUI ?

    Also, if it worked okay a few days ago, what changed in the hardware setup department?

  • I'm using the mount via systemd since forever as it is working stable and convenient for ages now (openelec back in the days).
    No hardware changes have been made, but maybe the update to alpha 6 causes this problem.

    Here's the recent log where can be seen that just this one series was stale for about one hour:

    cMYL

    Anyways, I will try out the mount via kodi this evening.

    Edited once, last by gaelic (October 7, 2016 at 10:31 AM).

  • The problem still resides when using smb directly within kodi, only not this special directory is hanging but tvshow directories keep failing randomly with these lines:

    Code
    13:29:14 1189.024414 T:1874850720   ERROR: GetDirectory - Error getting smb://10.0.0.1/Media/Series/The Mighty Boosh/
    13:30:44 1279.179443 T:1874850720   ERROR: SMBDirectory->GetDirectory: Unable to open directory : 'smb://USERNAME:[email protected]/Media/Series/The%20Mighty%20Boosh'
                                                unix_err:'16' error : 'Invalid argument'

    Now I've completely switched to NFS and everything is perfect. For me SMB seems to be unstable and unreliable in general.

  • Seems SMB is royally screwed up in Kodi - and in my opinion isn't a LibreELEC issue. My main install of v7.90.007 won't display past the 108th movie on my main Windows server share. It's not the file as I can move it and just the next one pops in, I have also tested this on my Android tablet runnning the latest Kodi nightly and it does exactly the same. No matter what do with the files on the server only 108 of them get listed. If I use FX File Explorer on the same tablet I can see all 229 movie files so I'm pretty sure my server is fine, as it was before.

    I also have an issue where after a certain amount of time the SMB connection simply dies, I get an "Invalid argument" and I have to reboot, yet I can watch many films/shows for hours, then come back the next day having left it switched on and I get the same error again. The server never shuts down.

    I wanted to mention this here for reference, and I will now go visit the Kodi forums in the hope I can find a solution.


  • Seems SMB is royally screwed up in Kodi - and in my opinion isn't a LibreELEC issue. My main install of v7.90.007 won't display past the 108th movie on my main Windows server share. It's not the file as I can move it and just the next one pops in, I have also tested this on my Android tablet runnning the latest Kodi nightly and it does exactly the same. No matter what do with the files on the server only 108 of them get listed. If I use FX File Explorer on the same tablet I can see all 229 movie files so I'm pretty sure my server is fine, as it was before.

    I also have an issue where after a certain amount of time the SMB connection simply dies, I get an "Invalid argument" and I have to reboot, yet I can watch many films/shows for hours, then come back the next day having left it switched on and I get the same error again. The server never shuts down.

    I wanted to mention this here for reference, and I will now go visit the Kodi forums in the hope I can find a solution.

    Yes, this is exactly my experience. Unless it is not only related to the number of files (i've got several hundred in my Series directory).

  • When mounting through systemd/kernel, as far as Kodi's concerned it's a regular filesystem. Sounds to me like the issue is with the Synology drive and not with the network protocol. Odd that it works with NFS though. Perhaps you'll see issues there as well given time.

    Edited once, last by escalade (October 24, 2016 at 2:50 PM).

  • I can rule out (of course not 100%) the Synology Box as several other clients do not experience any problems browsing the shares, copying files, etc., although none of the is "streaming" files for playback.
    ---
    I may have found a solution to the problem and it seems wifi related, which was also causing freezes in video playback from time to time (the files played without any flaws on my archlinux/gnome laptop):

    I use a rpi3 with an external wifi-usb adapter with a rtl8812au chipset. I adjusted the modules parameters as follows:

    Code
    [code]
    options 8812au rtw_vht_enable=1 rtw_ht_enable=0 rtw_power_mgnt=0 rtw_enusbss=0 rtw_ips_mode=1


    [/code]

    Code
    I was only testing this setup with NFS so far, but the playback of a once problematic file (kodi playback stall/freeze) went well. I'll keep you updated.
  • I've done serveral tests now with SMB and NFS. My issues are completely resolved with the options for kernel modules provided. No scanning issues, no video freezes or stutters.
    Maybe another person with network issues / NFS, SMB issues / performance can also test this ... of course if you're using an external USB wifi stick.

  • Is there any way to get SMB2+ support added to LE?

    As a test I disabled SMB1 on my Windows Server 2012 R2 box and now the shares cannot be accessed. SMB1 is being deprecated slowly with Microsoft even telling people it should no longer be enabled for security. LE needs to move with the times.

  • I seem to have the same problem as Taomyn, my system was running fine before updating to 7.90.008, I have 1 share on a Server 2012 R2 box which has some 300 files in it, Kodi won't show past the 106th file for some reason, only happened a few days ago when the update happened, unbeleivably fustrating.


  • I seem to have the same problem as Taomyn, my system was running fine before updating to 7.90.008, I have 1 share on a Server 2012 R2 box which has some 300 files in it, Kodi won't show past the 106th file for some reason, only happened a few days ago when the update happened, unbeleivably fustrating.

    I opened a ticket at Kodi for this, but no-one has even bothered to respond so far. Would you mind commenting on it yourself and maybe it will gain some attention?

    #17038 (SMB share on Windows 2012 R2 server not finding all files) – Kodi - TRAC

    It's not just LibreELEC that's a problem, their own Android release suffers the same way.

  • Taomyn

    How can you be so sure SMB is the issue? Did you try mounting the SMB share through the kernel instead of accessing directly with Kodi? SMB2/3 is supported by the kernel, although it's disabled in the LE config (should probably be PR'ed and enabled).


  • Taomyn

    How can you be so sure SMB is the issue? Did you try mounting the SMB share through the kernel instead of accessing directly with Kodi? SMB2/3 is supported by the kernel, although it's disabled in the LE config (should probably be PR'ed and enabled).

    Well, on my tablet where Kodi is also failing, I can access the same SMB share using FX Explorer so I'm pretty sure the issue lies with Kodi. I also have my SSH server located on another machine but does allow me to access the same share - it works everywhere but it's far slower than direct via SMB otherwise I'd switch over.

    Can you elaborate on how I can mount the share through the kernel or better still enable SMB2/3 so I can test that? I can easily disable SMB1/2 to be sure it's getting used.

  • I'm not saying the issue isn't with Kodi but you were pointing at the SMB protocol specifically, hence my suggestion. The fact that you can access the share with FX Explorer or whatever doesn't prove anything.

    As for mounting through the kernel, look at the OP.

    LibreELEC.tv/linux.x86_64.conf at master · LibreELEC/LibreELEC.tv · GitHub
    Linux Kernel Driver DataBase: CONFIG_CIFS_SMB2: SMB2 network file system support

    Edited once, last by escalade (November 11, 2016 at 10:42 AM).

  • I did the following steops to (parly) resolve the problems:

    a) switching between kodi smb and system smb didn't help
    b) switching from smb to nfs did help partially (scanning worked, but slowly, sometimes even failing)
    c) turning of powersaving on the usb wireless card completely resovled the problem, although I'm still on nfs and not using smb ... I don't wanna change the Library at this moment.

    How are you connected to the server/NAS?


  • I'm not saying the issue isn't with Kodi but you were pointing at the SMB protocol specifically, hence my suggestion. The fact that you can access the share with FX Explorer or whatever doesn't prove anything.

    As for mounting through the kernel, look at the OP.

    LibreELEC.tv/linux.x86_64.conf at master · LibreELEC/LibreELEC.tv · GitHub
    Linux Kernel Driver DataBase: CONFIG_CIFS_SMB2: SMB2 network file system support

    Actually it does prove that Kodi and hence LE has a problem with SMB and doesn't when using SSH, so of course I'd point at it directly where else would I?

    I'll see tonight if I can mount the share using the system.d script and test that. Are you also saying that if I can edit the "linux.x86_64.conf" to enable SMB2 or is that a build file so it would need to be rebuilt (something beyond what I can do)?
    [hr]


    How are you connected to the server/NAS?

    My box has built-in 5Ghz N wireless, so not USB. I did also hard wire it temporarily, but it made no difference.

    Edited once, last by Taomyn (November 11, 2016 at 11:28 AM).