<div dir="ltr"><div dir="ltr"><div><div>All,<br><br></div>There have been issues related to POSIX compliance especially while <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1512691" target="_blank">running Database workloads</a> on Glusterfs. Recently we&#39;ve worked on fixing some of them. This mail is an update on that effort.<br></div><div><br></div><div>The issues themselves can be classfied into following categories:<br></div><div><ul><li style="margin-left:15px">rename atomicity. When rename (src, dst) is done with dst already present, at no point in time access to dst (like open, stat, chmod etc) should fail. However, since the rename itself changes the association of dst-path from dst-inode to src-inode, inode based operations like open, stat etc that have already completed resolution of dst-path  into dst-inode will end up not finding the dst-inode after rename causing them to fail. However VFS provides a workaround for this by doing the resolution of path once again provided operations fail with ESTALE. There were some issues associated with this:</li><ul><li style="margin-left:15px">Glusterfs in some codepaths returned ENOENT even when the operation is on an inode and hence VFS didn&#39;t retry the resolution. Much of the discussion around this topic can be found at this <a href="https://www.spinics.net/lists/gluster-devel/msg18981.html" target="_blank">mail thread</a>. This issue has <a href="http://review.gluster.org/r/I2e752ca60dd8af1b989dd1d29c7b002ee58440b4" target="_blank">been</a> <a href="http://review.gluster.org/r/I8d07d2ebb5a0da6c3ea478317442cb42f1797a4b" target="_blank">fixed</a> <a href="http://review.gluster.org/r/Ia07e3cece404811703c8cfbac9b402ca5fe98c1e" target="_blank">by</a> various patches<br></li><li style="margin-left:15px">VFS retries exactly once. So, when retry fails with ESTALE, VFS gives up and syscalls like open are failed. We&#39;ve hit this class of issues in bugs like <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1543279" target="_blank">these</a>. The current understanding is real world workloads won&#39;t hit this race and hence one retry mechanism is enough. NFS relies on the same mechanism of VFS and NFS developers say they&#39;ve not hit bugs of this kind in real workloads.</li><li style="margin-left:15px">DHT in rename codepaths acquires locks on src and dst inodes. If a parallel rename overwrote dst-inode, this locking fails and rename operation used to fail. The issue is tracked and fixed as part of this <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1543279" target="_blank">bug</a>.<br></li></ul><li style="margin-left:15px">Quorum imposition by afr in open fop. afr imposes Quorum on fd based operations, but not on open. This means operations can fail on a valid fd due to lack of Quorum. Not fixed yet and is tracked on this <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1634664" target="_blank">bug</a>.<br></li><li style="margin-left:15px">Operations on a valid fd failing after the file was deleted by rename/unlink.</li><ul><li style="margin-left:15px">Fuse-bridge used to randomly pick fds in fstat codepath as earlier versions of fuse api didn&#39;t provide filehandle as argument of Getattr request. This resulted in fstat failures when the file was deleted either through rename/unlink after it has been successfully opened. This is fixed in this <a href="http://review.gluster.org/r/I67eebbf5407ca725ed111fbda4181ead10d03f6d" target="_blank">patch</a> and this <a href="http://review.gluster.org/r/I88dd29b3607cd2594eee9d72a1637b5346c8d49c" target="_blank">patch</a>.<br></li><li style="margin-left:15px">performance/open-behind fakes an open call. Due to bugs in rename/unlink codepath, it couldn&#39;t open file before the file was deleted due to rename or unlink. Fixed by this <a href="https://review.gluster.org/#/c/glusterfs/+/20428/" target="_blank">patch</a></li></ul><li style="margin-left:15px">Stale (meta)data cached by various performance xlators<br></li><ul><li style="margin-left:15px">md-cache used to cache stale fstat. Fixed by this <a href="http://review.gluster.org/r/Ia4bb9dd36494944e2d91e9e71a79b5a3974a8c77" target="_blank">patch</a>.</li><li style="margin-left:15px">write-behind did not provide correct stat in rename cbk when writes on src were cached in write-behind. Fixed by this <a href="http://review.gluster.org/r/Ic9f2adf8edd0b58ebaf661f3a8d0ca086bc63111" target="_blank">patch</a>.</li><li style="margin-left:15px">write-behind did not provide correct stat in readdirp response. Fixed by this <a href="http://review.gluster.org/r/I12d167bf450648baa64be1cbe1ca0fddf5379521" target="_blank">patch</a></li><li style="margin-left:15px">Ordering of operations done on different fds by write-behind. It considered operations on different fds as independent. So an fstat done after a write is complete when both operations are on different fds, didn&#39;t fetch stat that reflected the write operation. This is fixed by this <a href="http://review.gluster.org/r/Iee748cebb6d2a5b32f9328aff2b5b7cbf6c52c05" target="_blank">patch</a></li><li style="margin-left:15px">readdir-ahead used to provide stale stat. The issue is fixed by this <a href="http://review.gluster.org/Ia27ff49a61922e88c73a1547ad8aacc9968a69df" target="_blank">patch</a></li><li style="margin-left:15px">Most of the caching xlators rely on ctime/mtime of stat to find out whether the current (meta)data is newer/stale than the cached (meta)data. However ctime/mtime provided by replica/afr is not always consistent as it can pick stat from any of its subvolumes. This issue can be solved once <a href="https://github.com/gluster/glusterfs/issues/208" target="_blank">ctime generatior</a> becomes production ready and is enabled by default. Note that ctime generator xlator can also help in fixing issues with <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1179169" target="_blank">tar</a>, <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1379568" target="_blank">ElasticSearch</a> etc that rely on correctness of ctime. Also, I still see a rare pgbench failure even after all the fixes to bz 1512691 due to unreliable ctime/mtime from underlying xlators.</li><li style="margin-left:15px">Though this <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1601166" target="_blank">issue</a> is not really a consistency issue, it hindered performance of read-ahead as fstats flushed read-ahead cache. Note that fstats also have an impact on write-behind when reads and writes are interleaved on a file as fstats wait on cached-writes in write-behind. A <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1563508" target="_blank">bug</a> has been filed on fuse kernel module for implementation of noatime feature so that fstats are not issued during reads.</li></ul><li style="margin-left:15px">AMQP needed flock -w to work. Tracked as part of this <a href="https://github.com/gluster/glusterfs/issues/465" target="_blank">issue</a>.</li></ul><div>The issues listed above are either fixed or work is in progress to fix them. There are still more issues which are not worked upon yet and we&#39;ll provide updates on them in future. Some of the prominent known issues (the list is not exhaustive) are:</div><div><ul><li style="margin-left:15px"><a href="https://bugzilla.redhat.com/show_bug.cgi?id=1563848" target="_blank">Missing dentries</a> when performance.parallel-readdir is enabled. Note that its a cache coherence issue, the dentries and files are still intact on backend.<br></li><li style="margin-left:15px">Evaluate and initiate discussion on how to propagate errors encountered during commit of cached writes, to application. A wider discussion (across different filesystems) on this topic is found at: <a href="https://lwn.net/Articles/752063/" target="_blank">https://lwn.net/Articles/752063/</a>. Thanks to @csabahenk for pointing this discussion.<br></li><li style="margin-left:15px">Sanitize the stack to return ESTALE for inode missing and ENOENT for path missing. For eg., storage/posix sometimes return ENOENT for scenarios where gfid handles are missing, even though the correct error is ESTALE. Failing to return ESTALE can throw off the retry logic in VFS. An open failing with ENOENT is wrong as open is a gfid based operation. An easy fix would be to fuse-bridge convert all ENOENT errors to ESTALE in _all_ inode based fop responses. Currently its done only in open(dir) codepath. This has to be extended to other codepaths too.<br></li><li style="margin-left:15px">Lookup and rename in DHT are not atomic. rename is a compound operation in DHT which involves some hardlinking and in the rename window both src and dst are visible as hardlinks to each other. If lookup samples src or dst in this window, it&#39;ll perceive the file to have hardlinks.</li><li style="margin-left:15px">stale dentries of src in inode-tables (of fuse, protocol/server) after successful rename of src and dst. This can be caused due to a lookup on src racing with rename. This issue is not very much different from the issue of caching xlators needing a way of identifying which among the two (meta)data is latest. ctime generator xlator can be used here to compare ctime of parent directory as recorded in itable with that of in lookup response and making sure only latest dentry is linked into inode table.</li><ul><li style="margin-left:15px">Note that stale dentries can cause corruption in applications like SAS, pgbench that rely on the pattern of create a tmp file, write to it and rename it to the file to be consumed by another thread. Since src resolves to dst inode due to stale dentries having same stat of dst, the dst file ends up corrupted as writes of next cycle end up on the file being consumed for previous cycle. So, this is an important issue to be fixed.</li></ul><li style="margin-left:15px">There are few bugs on SAS </li><ul><li style="margin-left:15px"><a href="https://bugzilla.redhat.com/show_bug.cgi?id=1630735" target="_blank">issues with fcntl locking</a>. </li><li style="margin-left:15px">From my limited conversation with people who use/work on SAS, it seem to rely on fsync as a checkpoint after which the changes by one job should be visible to other jobs which could be running on different mounts on a different machine. This means, fsync on one mount should update caches of other mounts too with updated data. This functionality is currently missing in Glusterfs.</li></ul></ul></div>regards,</div><div>Raghavendra</div></div></div>