From 8f60396bc8ce91dff57d64ae7ce56afb7f7626b1 Mon Sep 17 00:00:00 2001 From: Rajesh Joseph Date: Mon, 14 Nov 2016 15:40:32 +0530 Subject: libglusterfs:Now mempool is added to ctx pool list under a lock mempool is added to ctx pool list without any lock. This can cause undefined behaviour in case of multithreaded environment. Fix: modify the list only under ctx->lock > Reviewed-on: http://review.gluster.org/15842 > NetBSD-regression: NetBSD Build System > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > Reviewed-by: Raghavendra Talur > Reviewed-by: Shyamsundar Ranganathan > Reviewed-by: Poornima G > Reviewed-by: Niels de Vos (cherry picked from commit 277008a3a8583ef10cec9e4182960792e56c5c10) Change-Id: I7bdbb3db48a899bb0e41427e149b13c0facaedba Signed-off-by: Rajesh Joseph BUG: 1397663 Reviewed-on: http://review.gluster.org/15909 Smoke: Gluster Build System Reviewed-by: Poornima G NetBSD-regression: NetBSD Build System Reviewed-by: Manikandan Selvaganesh CentOS-regression: Gluster Build System Reviewed-by: Raghavendra Talur --- libglusterfs/src/mem-pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 78fecec4b0f..88fbdf58319 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -422,7 +422,11 @@ mem_pool_new_fn (unsigned long sizeof_type, if (!ctx) goto out; - list_add (&mem_pool->global_list, &ctx->mempool_list); + LOCK (&ctx->lock); + { + list_add (&mem_pool->global_list, &ctx->mempool_list); + } + UNLOCK (&ctx->lock); out: return mem_pool; -- cgit From f97dc2f9a196e3c8769652e831be25e36a44e634 Mon Sep 17 00:00:00 2001 From: Poornima G Date: Mon, 21 Nov 2016 19:57:08 +0530 Subject: libglusterfs: Fix a read hang Issue: ===== In certain cases, there was no unwind of read from read-ahead xlator, thus resulting in hang. RCA: ==== In certain cases, ioc_readv() issues STACK_WIND_TAIL() instead of STACK_WIND(). One such case is when inode_ctx for that file is not present (can happen if readdirp was called, and populates md-cache and serves all the lookups from cache). Consider the following graph: ... io-cache (parent) | readdir-ahead | read-ahead ... Below is the code snippet of ioc_readv calling STACK_WIND_TAIL: ioc_readv() { ... if (!inode_ctx) STACK_WIND_TAIL (frame, FIRST_CHILD (frame->this), FIRST_CHILD (frame->this)->fops->readv, fd, size, offset, flags, xdata); /* Ideally, this stack_wind should wind to readdir-ahead:readv() but it winds to read-ahead:readv(). See below for explaination. */ ... } STACK_WIND_TAIL (frame, obj, fn, ...) { frame->this = obj; /* for the above mentioned graph, frame->this will be readdir-ahead * frame->this = FIRST_CHILD (frame->this) i.e. readdir-ahead, which * is as expected */ ... THIS = obj; /* THIS will be read-ahead instead of readdir-ahead!, as obj expands * to "FIRST_CHILD (frame->this)" and frame->this was pointing * to readdir-ahead in the previous statement. */ ... fn (frame, obj, params); /* fn will call read-ahead:readv() instead of readdir-ahead:readv()! * as fn expands to "FIRST_CHILD (frame->this)->fops->readv" and * frame->this was pointing ro readdir-ahead in the first statement */ ... } Thus, the readdir-ahead's readv() implementation will be skipped, and ra_readv() will be called with frame->this = "readdir-ahead" and this = "read-ahead". This can lead to corruption / hang / other problems. But in this perticular case, when 'frame->this' and 'this' passed to ra_readv() doesn't match, it causes ra_readv() to call ra_readv() again!. Thus the logic of read-ahead readv() falls apart and leads to hang. Solution: ========= Modify STACK_WIND_TAIL() as: STACK_WIND_TAIL (frame, obj, fn, ...) { next_xl = obj /* resolve obj as the variables passed in obj macro can be overwritten in the further instrucions */ next_xl_fn = fn /* resolve fn and store in a tmp variable, before modifying any variables */ frame->this = next_xl; ... THIS = next_xl; ... next_xl_fn (frame, next_xl, params); ... } BUG: 1399018 Change-Id: Ie662ac8f18fa16909376f1e59387bc5b886bd0f9 Signed-off-by: Poornima G Reviewed-on: http://review.gluster.org/15934 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Raghavendra G --- libglusterfs/src/stack.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index 2899be9bf2f..393fdac8e73 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -275,17 +275,19 @@ STACK_RESET (call_stack_t *stack) #define STACK_WIND_TAIL(frame, obj, fn, params ...) \ do { \ xlator_t *old_THIS = NULL; \ + xlator_t *next_xl = obj; \ + typeof(fn) next_xl_fn = fn; \ \ - frame->this = obj; \ + frame->this = next_xl; \ frame->wind_to = #fn; \ old_THIS = THIS; \ - THIS = obj; \ + THIS = next_xl; \ gf_msg_trace ("stack-trace", 0, \ "stack-address: %p, " \ "winding from %s to %s", \ frame->root, old_THIS->name, \ THIS->name); \ - fn (frame, obj, params); \ + next_xl_fn (frame, next_xl, params); \ THIS = old_THIS; \ } while (0) -- cgit From 1d66eb4af160dfa6350410cd6d03e4aa1caf1c53 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Fri, 9 Dec 2016 09:50:43 +0530 Subject: syncop: fix conditional wait bug in parallel dir scan Problem: The issue as seen by the user is detailed in the BZ but what is happening is if the no. of items in the wait queue == max-qlen, syncop_mt_dir_scan() does a pthread_cond_wait until the launched synctask workers dequeue the queue. But if for some reason the worker fails, the queue is never emptied due to which further invocations of syncop_mt_dir_scan() are blocked forever. Fix: Made some changes to _dir_scan_job_fn - If a worker encounters error while processing an entry, notify the readdir loop in syncop_mt_dir_scan() of the error but continue to process other entries in the queue, decrementing the qlen as and when we dequeue elements, and ending only when the queue is empty. - If the readdir loop in syncop_mt_dir_scan() gets an error form the worker, stop the readdir+queueing of further entries. > Reviewed-on: http://review.gluster.org/16073 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Pranith Kumar Karampuri (cherry picked from commit 2d012c4558046afd6adb3992ff88f937c5f835e4) Change-Id: I39ce073e01a68c7ff18a0e9227389245a6f75b88 BUG: 1403192 Signed-off-by: Ravishankar N Reviewed-on: http://review.gluster.org/16096 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- libglusterfs/src/syncop-utils.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c index 8f25db237f5..de6033fc501 100644 --- a/libglusterfs/src/syncop-utils.c +++ b/libglusterfs/src/syncop-utils.c @@ -266,9 +266,10 @@ _dir_scan_job_fn (void *data) entry = NULL; pthread_mutex_lock (scan_data->mut); { - if (ret || list_empty (&scan_data->q->list)) { - (*scan_data->jobs_running)--; + if (ret) *scan_data->retval |= ret; + if (list_empty (&scan_data->q->list)) { + (*scan_data->jobs_running)--; pthread_cond_broadcast (scan_data->cond); } else { entry = list_first_entry (&scan_data->q->list, @@ -406,10 +407,13 @@ syncop_mt_dir_scan (call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid, ret = fn (subvol, entry, loc, data); gf_dirent_entry_free (entry); if (ret) - break; + goto out; continue; } + if (retval) /*Any jobs failed?*/ + goto out; + pthread_mutex_lock (&mut); { while (qlen == max_qlen) @@ -423,8 +427,7 @@ syncop_mt_dir_scan (call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid, } } pthread_mutex_unlock (&mut); - if (retval) /*Any jobs failed?*/ - break; + if (!entry) continue; @@ -433,7 +436,7 @@ syncop_mt_dir_scan (call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid, &retval, &mut, &cond, &jobs_running, &qlen, fn, data); if (ret) - break; + goto out; } } -- cgit From 79c25deb4f9dda6502968b1fba3fa235f9d87714 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 7 Dec 2016 07:36:19 -0500 Subject: glusterd/geo-rep: Fix glusterd crash Problem: glusterd crashes when geo-rep mountbroker setup is created if the slave user length is more than 8 characters. Cause: _POSIX_LOGIN_NAME_MAX is used which is 9 including NULL byte. Analysis: While the man page says it sufficient for portability, but acutally it's not. Linux allows the creation of username upto 32 characters by default where the max length is 256. And NetBSD's max is 17. Linux: #getconf LOGIN_NAME_MAX 256 NetBSD: #getconf LOGIN_NAME_MAX 17 Fix: Use LOGIN_NAME_MAX instead of _POSIX_LOGIN_NAME_MAX >Reviewed-on: http://review.gluster.org/16053 >Smoke: Gluster Build System >NetBSD-regression: NetBSD Build System >CentOS-regression: Gluster Build System >Reviewed-by: Aravinda VK >Reviewed-by: Atin Mukherjee Change-Id: I26b7230433ecbbed6e6914ed39221a478c0266a8 BUG: 1403109 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/16085 Tested-by: Atin Mukherjee Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Niels de Vos --- libglusterfs/src/compat.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/compat.h b/libglusterfs/src/compat.h index 69adfbcd7fe..ea722028eb5 100644 --- a/libglusterfs/src/compat.h +++ b/libglusterfs/src/compat.h @@ -158,6 +158,10 @@ enum { #define s6_addr32 __u6_addr.__u6_addr32 #endif +#ifndef LOGIN_NAME_MAX +#define LOGIN_NAME_MAX 256 +#endif + /* Posix dictates NAME_MAX to be used */ # ifndef NAME_MAX # ifdef MAXNAMLEN -- cgit From 1e421a5bbf075994882a1fefe1099bf6622d90f6 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Mon, 8 Aug 2016 13:11:29 -0400 Subject: logging: Avoid re-initing log level in io-stats If log level is already set via api or command line, initialization of io-stats xlator overwrites the log level to GF_LOG_INFO. This patch prevents re-initialization of log level if already set. Backport of: > Change-Id: I1f74d94ef8068b95ec696638c0a8b17d8d71aabe > BUG: 1368882 > Signed-off-by: Vijay Bellur > Reported-by: Colin Lord > Reviewed-on: http://review.gluster.org/15112 > NetBSD-regression: NetBSD Build System > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > Reviewed-by: Niels de Vos > Reviewed-by: Pranith Kumar Karampuri Change-Id: I1f74d94ef8068b95ec696638c0a8b17d8d71aabe BUG: 1378384 Signed-off-by: Prasanna Kumar Kalever Reviewed-on: http://review.gluster.org/15544 Smoke: Gluster Build System Reviewed-by: Vijay Bellur Reviewed-by: Niels de Vos NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- libglusterfs/src/ctx.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/ctx.c b/libglusterfs/src/ctx.c index 2aa14654b9e..b009e6270a2 100644 --- a/libglusterfs/src/ctx.c +++ b/libglusterfs/src/ctx.c @@ -35,6 +35,8 @@ glusterfs_ctx_new () ctx->daemon_pipe[0] = -1; ctx->daemon_pipe[1] = -1; + ctx->log.loglevel = DEFAULT_LOG_LEVEL; + /* lock is never destroyed! */ ret = LOCK_INIT (&ctx->lock); if (ret) { -- cgit