21ab4e
From cc7992b8b63a24ab676ac0b86f31547fa66dfa7b Mon Sep 17 00:00:00 2001
21ab4e
From: Niels de Vos <ndevos@redhat.com>
21ab4e
Date: Tue, 1 Aug 2017 10:42:11 +0200
21ab4e
Subject: [PATCH 583/587] libglusterfs: the global_xlator should have valid
21ab4e
 cbks
21ab4e
21ab4e
There is a case where Gluster/NFS needs to resolve a path outside of the
21ab4e
nfs-xlator itself. While resolving the path to fetch the GFID for
21ab4e
creating the NFS-filehandle, gfapi may set an inode-ctx through
21ab4e
glfs_resolve_at(). This inode-ctx is linked with the global_xlator.
21ab4e
21ab4e
Because the global_xlator does not have any cbks, loc_wipe() will cause
21ab4e
a segfault when it calls inode_unref() and xl->cbks->forget(). It is
21ab4e
assumed that all xlators have a cbks symbol, otherwise loading of the
21ab4e
xlator will fail. The global_xlator is not loaded in the same way, so
21ab4e
there is no failure noticed when the instance is created. By adding an
21ab4e
empty `struct xlator_cbks`, the global_xlator behaves similat to other
21ab4e
xlators that do not implement all callbacks.
21ab4e
21ab4e
I would have preferred to keep the inode-ctx setting through
21ab4e
glfs_resolve_at() contained within Gluster/NFS. Unfortunately
21ab4e
Gluster/NFS also uses the inode-ctx, and is not prepared to see the
21ab4e
values that glfs_resolve_at() stores there.
21ab4e
21ab4e
This problem is not easily reproducible because it involves mounting
21ab4e
over WebNFS (like Solaris 10 can do). The segfault will also not be
21ab4e
immediate, unless the following is done:
21ab4e
21ab4e
1. create a subdir on a volume
21ab4e
2. mount the volume/subdir over WebNFS
21ab4e
3. unmount the volume/subdir
21ab4e
4. mount the root of the volume
21ab4e
5. delete the subdir on the volume -> segfault of Gluster/NFS
21ab4e
21ab4e
Cherry picked from commit cec5036f7e99ae265bb5e0e7f3df30166466eb2c:
21ab4e
> Change-Id: I2bd71d033e97edc07ba93b2d4ada558f65d68999
21ab4e
> BUG: 1468291
21ab4e
> Signed-off-by: Niels de Vos <ndevos@redhat.com>
21ab4e
> Reviewed-on: https://review.gluster.org/17897
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Amar Tumballi <amarts@redhat.com>
21ab4e
> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
21ab4e
21ab4e
Change-Id: I2bd71d033e97edc07ba93b2d4ada558f65d68999
21ab4e
BUG: 1472773
21ab4e
Signed-off-by: Niels de Vos <ndevos@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/113997
21ab4e
Reviewed-by: Jiffin Thottan <jthottan@redhat.com>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 libglusterfs/src/globals.c | 12 ++++++++++++
21ab4e
 1 file changed, 12 insertions(+)
21ab4e
21ab4e
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c
21ab4e
index c537971..0ac1ab9 100644
21ab4e
--- a/libglusterfs/src/globals.c
21ab4e
+++ b/libglusterfs/src/globals.c
21ab4e
@@ -125,6 +125,17 @@ glusterfs_this_destroy (void *ptr)
21ab4e
         FREE (ptr);
21ab4e
 }
21ab4e
 
21ab4e
+static struct xlator_cbks global_cbks = {
21ab4e
+        .forget                 = NULL,
21ab4e
+        .release                = NULL,
21ab4e
+        .releasedir             = NULL,
21ab4e
+        .invalidate             = NULL,
21ab4e
+        .client_destroy         = NULL,
21ab4e
+        .client_disconnect      = NULL,
21ab4e
+        .ictxmerge              = NULL,
21ab4e
+        .ictxsize               = NULL,
21ab4e
+        .fdctxsize              = NULL,
21ab4e
+};
21ab4e
 
21ab4e
 int
21ab4e
 glusterfs_this_init ()
21ab4e
@@ -141,6 +152,7 @@ glusterfs_this_init ()
21ab4e
 
21ab4e
         global_xlator.name = "glusterfs";
21ab4e
         global_xlator.type = "global";
21ab4e
+        global_xlator.cbks = &global_cbks;
21ab4e
 
21ab4e
         INIT_LIST_HEAD (&global_xlator.volume_options);
21ab4e
 
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e