Commit 78f36993 authored by Kirill Smelkov's avatar Kirill Smelkov

X wcfs: test: Fix thinko in getting /sys/fs/fuse/connection/<X> for wcfs

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
parent e4e5571a
......@@ -233,7 +233,7 @@ class tDB(_tDB):
# 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")
t._wcfuseabort = open("/sys/fs/fuse/connections/%d/abort" % os.minor(os.stat(testmntpt).st_dev), "w")
nogilready = chan(dtype='C.structZ')
go(t._abort_ontimeout, 10*time.second, nogilready) # NOTE must be: with_timeout << · << wcfs_pin_timeout
nogilready.recv() # wait till _abort_ontimeout enters nogil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment