• Kirill Smelkov's avatar
    X wcfs: test: Fix thinko in getting /sys/fs/fuse/connection/<X> for wcfs · 78f36993
    Kirill Smelkov authored
    FUSE puts X as st_dev's minor, which, for minors <= 255 is the same as st_dev.
    However when there are many connections, and minor goes after 255, minor becomes != st_dev:
    
        In [2]: os.makedev(0, 254)
        Out[2]: 254
    
        In [3]: os.makedev(0, 255)
        Out[3]: 255
    
        In [5]: os.makedev(0, 256)
        Out[5]: 1048576
    
    As a result we were constructing wrong patch, and if wcfs was failing we were
    also failing to kill it with something like:
    
        t = <wcfs.wcfs_test.tDB object at 0x7fef78043260>
    
            @func
            def __init__(t):
                t.root = testdb.dbopen()
                def _(): # close/unlock db if __init__ fails
                    exc = sys.exc_info()[1]
                    if exc is not None:
                        dbclose(t.root)
                defer(_)
    
                assert not os.path.exists(testmntpt)
                t.wc = wcfs.join(testzurl, autostart=True)
                assert os.path.exists(testmntpt)
                assert is_mountpoint(testmntpt)
    
                # force-unmount wcfs on timeout to unstuck current test and let it fail.
                # Force-unmount can be done reliably only by writing into
                # /sys/fs/fuse/connections/<X>/abort. For everything else there are
                # cases, when wcfs, even after receiving `kill -9`, will be stuck in kernel.
                # ( git.kernel.org/linus/a131de0a482a makes in-kernel FUSE client to
                #   still wait for request completion even after fatal signal )
        >       t._wcfuseabort   = open("/sys/fs/fuse/connections/%d/abort" % os.stat(testmntpt).st_dev, "w")
        E       IOError: [Errno 2] No such file or directory: '/sys/fs/fuse/connections/2097264/abort'
    
        wcfs/wcfs_test.py:236: IOError
    
    In the above failure st_dev=2097264 corresponds to X=624:
    
        In [6]: os.minor(2097264)
        Out[6]: 624
    78f36993
wcfs_test.py 64.8 KB