commit:     d1dc56b8af7550ce3d2b4ceb1419cf9ab7d9276f
Author:     Tomáš Mózes <hydrapolic <AT> gmail <DOT> com>
AuthorDate: Sat Jan 18 05:32:11 2020 +0000
Commit:     Alexys Jacob <ultrabug <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 09:44:34 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d1dc56b8

sys-cluster/glusterfs: bump to 6.7, drop old

Closes: https://bugs.gentoo.org/705396
Signed-off-by: Tomáš Mózes <hydrapolic <AT> gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/14373
Signed-off-by: Alexys Jacob <ultrabug <AT> gentoo.org>

 sys-cluster/glusterfs/Manifest                     |   2 +-
 .../files/glusterfs-6.7-fix-rebalance-crash.patch  | 185 +++++++++++++++++++++
 .../{glusterfs-6.1.ebuild => glusterfs-6.7.ebuild} |   5 +-
 3 files changed, 190 insertions(+), 2 deletions(-)

diff --git a/sys-cluster/glusterfs/Manifest b/sys-cluster/glusterfs/Manifest
index 7467705eeaf..3e30ba37cb9 100644
--- a/sys-cluster/glusterfs/Manifest
+++ b/sys-cluster/glusterfs/Manifest
@@ -1,3 +1,3 @@
 DIST glusterfs-4.1.8.tar.gz 7835272 BLAKE2B 
2546b9c0fe38989df71b8f72b193ce42c499621dcaaa4c5e3deeacfba68179f2280fc699cebeb87486171442152fa8b56b42a0d17465b739769eb227c82307d7
 SHA512 
950cd2fd774e3eb00f1ec06d54566736b6fbe8d1aed54477a19d9b2727eff8a70ef7ac32815cc7e01d45b5d357fc01af786e16c451f6ad314d472e61ba04ce85
-DIST glusterfs-6.1.tar.gz 7510074 BLAKE2B 
8002597f8f695d11578be250cafb3f32358ac29d873b27f87bb26edd38b64d896050322d9591b156793fe6ee7af111904961d5a3e7a933f7c5176cf0c6793305
 SHA512 
53f4195ecb565a8dcc0d66e74d07dd7334e3c8b1cc1671517612be32a00e9e9bbfb5e983955c4f116b25f7df990bcd1c05bbd3d0b740e9f8c76a16b9b16bec00
 DIST glusterfs-6.5.tar.gz 7536238 BLAKE2B 
35c58da9e8564bda1f34b095f14316148cae2b5ff1820d22ae945a06d34ac57aea968e5914af3f5831250fd591a103fe4022e160bb96d491a7c915b5b68c54e7
 SHA512 
b7356de07e8126aea80b0489b9ac39ce0d10ea324fe38d05ff5740765e886f80fc7e6bdda9d4db1371d7b955b055cb76ea29e918e759a575db331a6436bad90f
+DIST glusterfs-6.7.tar.gz 7565257 BLAKE2B 
bb38383cad0cbf890b89dd75f7b260d21b381aed6da0bf7cf7b3335941d8e195fe5ff60a1c882df941daeb8ad627fddd1a44223c62d71e2388fd85a7ea46a386
 SHA512 
64d576c91e5accdb3547dc7216d854e96512c9035ddb87dc4018930f2b0a008ad929cd80ae89a340fca7a8d36e2106a30797d7b08768477b1415db95123e07d4

diff --git 
a/sys-cluster/glusterfs/files/glusterfs-6.7-fix-rebalance-crash.patch 
b/sys-cluster/glusterfs/files/glusterfs-6.7-fix-rebalance-crash.patch
new file mode 100644
index 00000000000..e5a31623a32
--- /dev/null
+++ b/sys-cluster/glusterfs/files/glusterfs-6.7-fix-rebalance-crash.patch
@@ -0,0 +1,185 @@
+From ff1eae7f882b8f12380e0c35a9a73b672583cd4c Mon Sep 17 00:00:00 2001
+From: N Balachandran <[email protected]>
+Date: Tue, 01 Oct 2019 17:37:15 +0530
+Subject: [PATCH] cluster/dht: Correct fd processing loop
+
+The fd processing loops in the
+dht_migration_complete_check_task and the
+dht_rebalance_inprogress_task functions were unsafe
+and could cause an open to be sent on an already freed
+fd. This has been fixed.
+
+> Change-Id: I0a3c7d2fba314089e03dfd704f9dceb134749540
+> Fixes: bz#1757399
+> Signed-off-by: N Balachandran <[email protected]>
+> (cherry picked from commit 9b15867070b0cc241ab165886292ecffc3bc0aed)
+
+Change-Id: I0a3c7d2fba314089e03dfd704f9dceb134749540
+Fixes: bz#1786983
+Signed-off-by: Mohit Agrawal <[email protected]>
+---
+
+diff --git a/xlators/cluster/dht/src/dht-helper.c 
b/xlators/cluster/dht/src/dht-helper.c
+index acad493..4f7370d 100644
+--- a/xlators/cluster/dht/src/dht-helper.c
++++ b/xlators/cluster/dht/src/dht-helper.c
+@@ -1290,6 +1290,7 @@
+     fd_t *tmp = NULL;
+     uint64_t tmp_miginfo = 0;
+     dht_migrate_info_t *miginfo = NULL;
++    gf_boolean_t skip_open = _gf_false;
+     int open_failed = 0;
+ 
+     this = THIS;
+@@ -1428,24 +1429,34 @@
+      * the loop will cause the destruction of the fd. So we need to
+      * iterate the list safely because iter_fd cannot be trusted.
+      */
+-    list_for_each_entry_safe(iter_fd, tmp, &inode->fd_list, inode_list)
+-    {
+-        if (fd_is_anonymous(iter_fd))
+-            continue;
+-
+-        if (dht_fd_open_on_dst(this, iter_fd, dst_node))
+-            continue;
+-
++    iter_fd = list_entry((&inode->fd_list)->next, typeof(*iter_fd), 
inode_list);
++    while (&iter_fd->inode_list != (&inode->fd_list)) {
++        if (fd_is_anonymous(iter_fd) ||
++            (dht_fd_open_on_dst(this, iter_fd, dst_node))) {
++            if (!tmp) {
++                iter_fd = list_entry(iter_fd->inode_list.next, 
typeof(*iter_fd),
++                                     inode_list);
++                continue;
++            }
++            skip_open = _gf_true;
++        }
+         /* We need to release the inode->lock before calling
+          * syncop_open() to avoid possible deadlocks. However this
+          * can cause the iter_fd to be released by other threads.
+          * To avoid this, we take a reference before releasing the
+          * lock.
+          */
+-        __fd_ref(iter_fd);
++        fd_ref(iter_fd);
+ 
+         UNLOCK(&inode->lock);
+ 
++        if (tmp) {
++            fd_unref(tmp);
++            tmp = NULL;
++        }
++        if (skip_open)
++            goto next;
++
+         /* flags for open are stripped down to allow following the
+          * new location of the file, otherwise we can get EEXIST or
+          * truncate the file again as rebalance is moving the data */
+@@ -1467,9 +1478,11 @@
+             dht_fd_ctx_set(this, iter_fd, dst_node);
+         }
+ 
+-        fd_unref(iter_fd);
+-
++    next:
+         LOCK(&inode->lock);
++        skip_open = _gf_false;
++        tmp = iter_fd;
++        iter_fd = list_entry(tmp->inode_list.next, typeof(*tmp), inode_list);
+     }
+ 
+     SYNCTASK_SETID(frame->root->uid, frame->root->gid);
+@@ -1482,6 +1495,10 @@
+ 
+ unlock:
+     UNLOCK(&inode->lock);
++    if (tmp) {
++        fd_unref(tmp);
++        tmp = NULL;
++    }
+ 
+ out:
+     if (dict) {
+@@ -1563,6 +1580,7 @@
+     int open_failed = 0;
+     uint64_t tmp_miginfo = 0;
+     dht_migrate_info_t *miginfo = NULL;
++    gf_boolean_t skip_open = _gf_false;
+ 
+     this = THIS;
+     frame = data;
+@@ -1683,24 +1701,40 @@
+      * the loop will cause the destruction of the fd. So we need to
+      * iterate the list safely because iter_fd cannot be trusted.
+      */
+-    list_for_each_entry_safe(iter_fd, tmp, &inode->fd_list, inode_list)
+-    {
+-        if (fd_is_anonymous(iter_fd))
+-            continue;
+-
+-        if (dht_fd_open_on_dst(this, iter_fd, dst_node))
+-            continue;
+-
++    iter_fd = list_entry((&inode->fd_list)->next, typeof(*iter_fd), 
inode_list);
++    while (&iter_fd->inode_list != (&inode->fd_list)) {
+         /* We need to release the inode->lock before calling
+          * syncop_open() to avoid possible deadlocks. However this
+          * can cause the iter_fd to be released by other threads.
+          * To avoid this, we take a reference before releasing the
+          * lock.
+          */
+-        __fd_ref(iter_fd);
+ 
++        if (fd_is_anonymous(iter_fd) ||
++            (dht_fd_open_on_dst(this, iter_fd, dst_node))) {
++            if (!tmp) {
++                iter_fd = list_entry(iter_fd->inode_list.next, 
typeof(*iter_fd),
++                                     inode_list);
++                continue;
++            }
++            skip_open = _gf_true;
++        }
++
++        /* Yes, this is ugly but there isn't a cleaner way to do this
++         * the fd_ref is an atomic increment so not too bad. We want to
++         * reduce the number of inode locks and unlocks.
++         */
++
++        fd_ref(iter_fd);
+         UNLOCK(&inode->lock);
+ 
++        if (tmp) {
++            fd_unref(tmp);
++            tmp = NULL;
++        }
++        if (skip_open)
++            goto next;
++
+         /* flags for open are stripped down to allow following the
+          * new location of the file, otherwise we can get EEXIST or
+          * truncate the file again as rebalance is moving the data */
+@@ -1721,9 +1755,11 @@
+             dht_fd_ctx_set(this, iter_fd, dst_node);
+         }
+ 
+-        fd_unref(iter_fd);
+-
++    next:
+         LOCK(&inode->lock);
++        skip_open = _gf_false;
++        tmp = iter_fd;
++        iter_fd = list_entry(tmp->inode_list.next, typeof(*tmp), inode_list);
+     }
+ 
+     SYNCTASK_SETID(frame->root->uid, frame->root->gid);
+@@ -1731,6 +1767,10 @@
+ unlock:
+     UNLOCK(&inode->lock);
+ 
++    if (tmp) {
++        fd_unref(tmp);
++        tmp = NULL;
++    }
+     if (open_failed) {
+         ret = -1;
+         goto out;

diff --git a/sys-cluster/glusterfs/glusterfs-6.1.ebuild 
b/sys-cluster/glusterfs/glusterfs-6.7.ebuild
similarity index 97%
rename from sys-cluster/glusterfs/glusterfs-6.1.ebuild
rename to sys-cluster/glusterfs/glusterfs-6.7.ebuild
index 87b3e519ab2..9bb5a61620b 100644
--- a/sys-cluster/glusterfs/glusterfs-6.1.ebuild
+++ b/sys-cluster/glusterfs/glusterfs-6.7.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-PYTHON_COMPAT=( python3_{6,7} )
+PYTHON_COMPAT=( python3_{6,7,8} )
 
 inherit autotools elisp-common python-single-r1 systemd user
 
@@ -80,6 +80,9 @@ pkg_setup() {
 src_prepare() {
        default
 
+       # https://bugzilla.redhat.com/show_bug.cgi?id=1786983
+       eapply "${FILESDIR}/glusterfs-6.7-fix-rebalance-crash.patch"
+
        # build rpc-transport and xlators only once as shared libs
        find rpc/rpc-transport xlators -name Makefile.am |
                xargs sed -i 's|.*$(top_srcdir).*\.sym|\0 -shared|' || die

Reply via email to