summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-11-20 15:11:13 -0800
committerAnand Avati <avati@redhat.com>2013-11-21 13:11:18 -0800
commitfee08b2cbf8c118d33dea745e0ae3033b36969da (patch)
treee7f42b21457ba1fe63ad994559dba0d799fb4168 /libglusterfs
parent544dee895a43ec9bb98fc8ace3d124d44bb617f2 (diff)
fuse: revalidate group id cache on uid/gid change detection
- Remember the uid and gid of the pid at the time of caching the group id list. - Next time when referring to the cache confirm that uid and gid of that pid has not changed since. If it has, treat it like a timeout/cache miss. - Solves group id caching issue caused when Samba runs on gluster FUSE mount and changes the uid/gid on a per syscall basis. Change-Id: I3382b037ff0b6d5eaaa36d9c898232543475aeda BUG: 1032438 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/6320 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/gidcache.c16
-rw-r--r--libglusterfs/src/gidcache.h4
2 files changed, 18 insertions, 2 deletions
diff --git a/libglusterfs/src/gidcache.c b/libglusterfs/src/gidcache.c
index c5bdda9..f2d98ab 100644
--- a/libglusterfs/src/gidcache.c
+++ b/libglusterfs/src/gidcache.c
@@ -54,7 +54,8 @@ int gid_cache_reconf(gid_cache_t *cache, uint32_t timeout)
* an additional allocation and memory copy. The caller should copy the data and
* release (unlock) the cache as soon as possible.
*/
-const gid_list_t *gid_cache_lookup(gid_cache_t *cache, uint64_t id)
+const gid_list_t *gid_cache_lookup(gid_cache_t *cache, uint64_t id,
+ uint64_t uid, uint64_t gid)
{
int bucket;
int i;
@@ -72,6 +73,17 @@ const gid_list_t *gid_cache_lookup(gid_cache_t *cache, uint64_t id)
continue;
/*
+ @uid and @gid reflect the latest UID/GID of the
+ process performing the syscall (taken from frame->root).
+
+ If the UID and GID has changed for the PID since the
+ time we cached it, we should treat the cache as having
+ stale values and query them freshly.
+ */
+ if (agl->gl_uid != uid || agl->gl_gid != gid)
+ break;
+
+ /*
* We don't put new entries in the cache when expiration=0, but
* there might be entries still in there if expiration was
* changed very recently. Writing the check this way ensures
@@ -182,6 +194,8 @@ int gid_cache_add(gid_cache_t *cache, gid_list_t *gl)
}
agl->gl_id = gl->gl_id;
+ agl->gl_uid = gl->gl_uid;
+ agl->gl_gid = gl->gl_gid;
agl->gl_count = gl->gl_count;
agl->gl_list = gl->gl_list;
agl->gl_deadline = now + cache->gc_max_age;
diff --git a/libglusterfs/src/gidcache.h b/libglusterfs/src/gidcache.h
index 9379f8e..886721e 100644
--- a/libglusterfs/src/gidcache.h
+++ b/libglusterfs/src/gidcache.h
@@ -32,6 +32,8 @@
typedef struct {
uint64_t gl_id;
+ uint64_t gl_uid;
+ uint64_t gl_gid;
int gl_count;
gid_t *gl_list;
time_t gl_deadline;
@@ -46,7 +48,7 @@ typedef struct {
int gid_cache_init(gid_cache_t *, uint32_t);
int gid_cache_reconf(gid_cache_t *, uint32_t);
-const gid_list_t *gid_cache_lookup(gid_cache_t *, uint64_t);
+const gid_list_t *gid_cache_lookup(gid_cache_t *, uint64_t, uint64_t, uint64_t);
void gid_cache_release(gid_cache_t *, const gid_list_t *);
int gid_cache_add(gid_cache_t *, gid_list_t *);