From: Andrew Deason Date: Thu, 26 Jul 2012 21:40:03 +0000 (-0500) Subject: LINUX: Hold GLOCK for proc traversal X-Git-Tag: upstream/1.6.2_pre2^2~146 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=0910046da6c0f08768d3d7cb983ce843572498d2;p=packages%2Fo%2Fopenafs.git LINUX: Hold GLOCK for proc traversal The functions that traverse unixuser structures for display via /proc (uu_start et al) call various libafs functions hold and release locks, etc. To do any of that, we need GLOCK. Amongst other issues, we can panic if we try to acquire a contested lock without GLOCK, since we assert glock is held when we sleep for the lock or try to wake other waiters. The same goes for the legacy CellServDB proc file. So, hold and release GLOCK as appropriate. Reviewed-on: http://gerrit.openafs.org/7885 Tested-by: BuildBot Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Derrick Brashear (cherry picked from commit 5237d3d232f22aaf4f67f3a8727a293f4058a7ae) Change-Id: I5895b4bde32b8efa27abc83cc6b9dab7458d5c75 Reviewed-on: http://gerrit.openafs.org/7914 Reviewed-by: Derrick Brashear Tested-by: BuildBot --- diff --git a/src/afs/LINUX/osi_proc.c b/src/afs/LINUX/osi_proc.c index c796d97f2..3f687f35b 100644 --- a/src/afs/LINUX/osi_proc.c +++ b/src/afs/LINUX/osi_proc.c @@ -134,21 +134,29 @@ static void * uu_start(struct seq_file *m, loff_t *pos) { struct unixuser *tu; + void *ret; loff_t n = 0; afs_int32 i; - ObtainReadLock(&afs_xuser); if (!*pos) return (void *)(1); + AFS_GLOCK(); + ObtainReadLock(&afs_xuser); + + ret = NULL; + for (i = 0; i < NUSERS; i++) { for (tu = afs_users[i]; tu; tu = tu->next) { if (++n == *pos) - return tu; + ret = tu; + goto done; } } - return NULL; + done: + AFS_GUNLOCK(); + return ret; } static void * @@ -173,7 +181,9 @@ uu_next(struct seq_file *m, void *p, loff_t *pos) static void uu_stop(struct seq_file *m, void *p) { + AFS_GLOCK(); ReleaseReadLock(&afs_xuser); + AFS_GUNLOCK(); } static int @@ -194,6 +204,8 @@ uu_show(struct seq_file *m, void *p) return 0; } + AFS_GLOCK(); + if (tu->cell == -1) { cellname = ""; } else { @@ -238,6 +250,8 @@ uu_show(struct seq_file *m, void *p) } seq_printf(m, "\n"); + AFS_GUNLOCK(); + return 0; } @@ -277,6 +291,8 @@ csdbproc_info(char *buffer, char **start, off_t offset, int length) decor */ char temp[91]; afs_uint32 addr; + + AFS_GLOCK(); ObtainReadLock(&afs_xcell); @@ -323,6 +339,8 @@ csdbproc_info(char *buffer, char **start, off_t offset, int length) ReleaseReadLock(&afs_xcell); done: + AFS_GUNLOCK(); + *start = buffer + len - (pos - offset); len = pos - offset; if (len > length)