From b198e072cda4bbb98e19701399c4bb4f0743cf20 Mon Sep 17 00:00:00 2001 From: Ajeet Jha Date: Mon, 2 Dec 2013 12:55:18 +0530 Subject: glusterd/geo-rep: more glusterd and cli fixes for geo-rep. -> handle option validation cases in reset case. -> Creating valid conf path when glusterd restarts. -> Reading the gsyncd worker thread status and displaying it. -> Displaying status-detail per worker. -> Fetch checkpoint info in geo-rep status. -> use-tarssh value validation added. misc: misc geo-rep fixes based on cluster, logrotate etc.. -> cluster/dht: fix 'stime' getxattr getting overwritten. -> cluster/afr: return max of 'stime' values in subvol. -> geo-rep-logrotate: Sending SIGHUP to geo-rep auxiliary. -> cluster/dht: fix convoluted logic while aggregating. -> cluster/*: fix 'stime' min/max fetch logic. Change-Id: I811acea0bbd6194797a3e55d89295d1ea021ac85 BUG: 1036552 Signed-off-by: Ajeet Jha Reviewed-on: http://review.gluster.org/6405 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- libglusterfs/src/mem-types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h index fc0aa9018..726d38eb6 100644 --- a/libglusterfs/src/mem-types.h +++ b/libglusterfs/src/mem-types.h @@ -118,6 +118,7 @@ enum gf_common_mem_types_ { gf_common_mt_auxgids = 102, gf_common_mt_syncopctx = 103, gf_common_mt_iobrefs = 104, - gf_common_mt_end = 105 + gf_common_mt_gsync_status_t = 105, + gf_common_mt_end = 106 }; #endif -- cgit From a9623ada6f7b39ac2d567f66a496072487d8e6ec Mon Sep 17 00:00:00 2001 From: Vijaykumar M Date: Thu, 12 Dec 2013 11:40:36 +0530 Subject: pathinfo: Provide user namespace access. Locality can be now queried by unprivileged users with key "glusterfs.pathinfo". Setting both "glusterfs.pathinfo" and "trusted.glusterfs.pathinfo" on disk is prevented with this patch. Original Author: Vijay Bellur Change-Id: I4f7a0db8ad59165c4aeda04b23173255157a8b79 Signed-off-by: Vijaykumar M Reviewed-on: http://review.gluster.org/5101 Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/glusterfs.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index dfe443016..ed483d19c 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -84,15 +84,18 @@ #define GF_XATTR_NODE_UUID_KEY "trusted.glusterfs.node-uuid" #define GF_XATTR_VOL_ID_KEY "trusted.glusterfs.volume-id" #define GF_XATTR_LOCKINFO_KEY "trusted.glusterfs.lockinfo" -#define GF_XATTR_GET_REAL_FILENAME_KEY "user.glusterfs.get_real_filename:" +#define GF_XATTR_GET_REAL_FILENAME_KEY "glusterfs.get_real_filename:" +#define GF_XATTR_USER_PATHINFO_KEY "glusterfs.pathinfo" #define QUOTA_LIMIT_KEY "trusted.glusterfs.quota.limit-set" #define GF_READDIR_SKIP_DIRS "readdir-filter-directories" #define BD_XATTR_KEY "user.glusterfs" -#define XATTR_IS_PATHINFO(x) (strncmp (x, GF_XATTR_PATHINFO_KEY, \ - strlen (GF_XATTR_PATHINFO_KEY)) == 0) +#define XATTR_IS_PATHINFO(x) ((strncmp (x, GF_XATTR_PATHINFO_KEY, \ + strlen (x)) == 0) || \ + (strncmp (x, GF_XATTR_USER_PATHINFO_KEY, \ + strlen (x)) == 0)) #define XATTR_IS_NODE_UUID(x) (strncmp (x, GF_XATTR_NODE_UUID_KEY, \ strlen (GF_XATTR_NODE_UUID_KEY)) == 0) #define XATTR_IS_LOCKINFO(x) (strncmp (x, GF_XATTR_LOCKINFO_KEY, \ -- cgit From 0d7279d32d5f55c0210bdcfda2d3f83e35f524b6 Mon Sep 17 00:00:00 2001 From: Poornima G Date: Mon, 23 Dec 2013 05:11:15 +0000 Subject: gfapi: Closed the logfile fd and initialize to NULL in glfs_fini Currently if logfile is closed and other threads call gf_log after glfs_fini() is executed, it may lead to memory corruption. Adding gf_log_fini() which closes the logfile and initializes the logfile to NULL, thus any further logging happens to stderr. Also added gf_log_globals_fini() which should be filled in the future to release all the logging resources. Change-Id: I879163e1a3636e65300d166f782517ee773cab65 BUG: 1030228 Signed-off-by: Poornima G Reviewed-on: http://review.gluster.org/6552 Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Shyamsundar Ranganathan Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/logging.c | 35 ++++++++++++++++++++++++++++++++++- libglusterfs/src/logging.h | 2 ++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index e3a4a9fde..0058233a7 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -108,11 +108,44 @@ gf_log_set_xl_loglevel (void *this, gf_loglevel_t level) } void -gf_log_fini (void) +gf_log_globals_fini (void) { pthread_mutex_destroy (&THIS->ctx->log.logfile_mutex); } +/** gf_log_fini - function to perform the cleanup of the log information + * @data - glusterfs context + * @return: success: 0 + * failure: -1 + */ +int +gf_log_fini (void *data) +{ + glusterfs_ctx_t *ctx = data; + int ret = 0; + + if (ctx == NULL) { + ret = -1; + goto out; + } + + pthread_mutex_lock (&ctx->log.logfile_mutex); + { + if (ctx->log.logfile) { + if (fclose (ctx->log.logfile) != 0) + ret = -1; + /* Logfile needs to be set to NULL, so that any + call to gf_log after calling gf_log_fini, will + log the message to stderr. + */ + ctx->log.logfile = NULL; + } + } + pthread_mutex_unlock (&ctx->log.logfile_mutex); + + out: + return ret; +} #ifdef GF_USE_SYSLOG /** diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h index cc806a767..e2b7e664d 100644 --- a/libglusterfs/src/logging.h +++ b/libglusterfs/src/logging.h @@ -153,6 +153,8 @@ int gf_cmd_log_init (const char *filename); void set_sys_log_level (gf_loglevel_t level); +int gf_log_fini(void *data); + #define GF_DEBUG(xl, format, args...) \ gf_log ((xl)->name, GF_LOG_DEBUG, format, ##args) #define GF_INFO(xl, format, args...) \ -- cgit From 2ce8918759e9676a54791848fd2ac85f48a05016 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Wed, 1 Jan 2014 21:36:27 +0530 Subject: libglusterfs: Add missing goto in eh_new() Change-Id: I64bbd8d5d919e78286a0521b62ca75f22ad296fa BUG: 795419 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/6623 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- libglusterfs/src/event-history.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/event-history.c b/libglusterfs/src/event-history.c index 82baa521a..e89df09c9 100644 --- a/libglusterfs/src/event-history.c +++ b/libglusterfs/src/event-history.c @@ -29,6 +29,7 @@ eh_new (size_t buffer_size, gf_boolean_t use_buffer_once, gf_log ("", GF_LOG_ERROR, "allocating circular buffer failed"); GF_FREE (history); history = NULL; + goto out; } history->buffer = buffer; -- cgit From d1f8b7ebc71df415f6b8ff37e9654ecee0d9064c Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Thu, 19 Dec 2013 14:11:45 +0100 Subject: Use linkat() instead of link() for portability sake POSIX does not says wether link(2) on symlink should link on symlink itself or on target. Linux use symlink, most other systems use target. Using linkat(2) allows the behavior to be specified, so that the behavior is portable. Also fix configure test for NetBSD linkata(2), which ceased to work. BUG: 764655 Change-Id: Iccd27ac076b7a74e40dcbaa1c4762fd3ad59da5f Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/6539 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/syscall.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c index e8954cc23..a619f9c41 100644 --- a/libglusterfs/src/syscall.c +++ b/libglusterfs/src/syscall.c @@ -120,7 +120,12 @@ sys_rename (const char *oldpath, const char *newpath) int sys_link (const char *oldpath, const char *newpath) { +#ifdef HAVE_LINKAT + /* see HAVE_LINKAT in xlators/storage/posix/src/posix.c */ + return linkat (AT_FDCWD, oldpath, AT_FDCWD, newpath, 0); +#else return link (oldpath, newpath); +#endif } -- cgit From f54e9ca3897177ee41b5f5299b94b719448c46cd Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Sat, 28 Dec 2013 08:31:55 +0100 Subject: Use linkat() instead of link() for portability sake POSIX does not says wether link(2) on symlink should link on symlink itself or on target. Linux use symlink, most other systems use target. Using linkat(2) allows the behavior to be specified, so that the behavior is portable. Also fix configure test for NetBSD linkat(2), which ceased to work. BUG: 764655 Change-Id: I2633fde3b0828ca8c199e11c827720c513e15852 Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/6613 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c index a619f9c41..117fa209e 100644 --- a/libglusterfs/src/syscall.c +++ b/libglusterfs/src/syscall.c @@ -120,7 +120,7 @@ sys_rename (const char *oldpath, const char *newpath) int sys_link (const char *oldpath, const char *newpath) { -#ifdef HAVE_LINKAT +#ifdef HAVE_LINKAT /* see HAVE_LINKAT in xlators/storage/posix/src/posix.c */ return linkat (AT_FDCWD, oldpath, AT_FDCWD, newpath, 0); #else -- cgit From 79cbf27b9b98d1feebcc2f1db5fc1c976d2c24cf Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Fri, 3 Jan 2014 13:36:40 +0530 Subject: Glusterd : glusterd process generates core due to NULL store handle Problem : glusterd crashed as backtrace revealed that store handle was set to NULL. Solution : In glusterd_store_global_info() function out block the handle is dereferenced with out any NULL check which caused this segmentation fault. A NULL check is introduced to avoid this. While testing this fix, another issue was noticed where GF_ASSERT macro again does not gurantee the NULL dereference check and hence this macro call has been replaced by GF_VALIDATE_OR_GOTO macro call in places where there is a danger of macro getting crashed due to NULL dereference check. Change-Id: Ic301aa45ce4bbdc2da751d2386439df7bb24c016 BUG: 1040844 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/6619 Reviewed-by: Niels de Vos Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/store.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c index 48c79ee02..5af23592b 100644 --- a/libglusterfs/src/store.c +++ b/libglusterfs/src/store.c @@ -62,8 +62,8 @@ gf_store_mkstemp (gf_store_handle_t *shandle) int fd = -1; char tmppath[PATH_MAX] = {0,}; - GF_ASSERT (shandle); - GF_ASSERT (shandle->path); + GF_VALIDATE_OR_GOTO ("store", shandle, out); + GF_VALIDATE_OR_GOTO ("store", shandle->path, out); snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path); fd = open (tmppath, O_RDWR | O_CREAT | O_TRUNC | O_SYNC, 0600); @@ -71,7 +71,7 @@ gf_store_mkstemp (gf_store_handle_t *shandle) gf_log ("", GF_LOG_ERROR, "Failed to open %s, error: %s", tmppath, strerror (errno)); } - +out: return fd; } @@ -127,8 +127,8 @@ gf_store_rename_tmppath (gf_store_handle_t *shandle) int32_t ret = -1; char tmppath[PATH_MAX] = {0,}; - GF_ASSERT (shandle); - GF_ASSERT (shandle->path); + GF_VALIDATE_OR_GOTO ("store", shandle, out); + GF_VALIDATE_OR_GOTO ("store", shandle->path, out); snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path); ret = rename (tmppath, shandle->path); @@ -149,8 +149,8 @@ gf_store_unlink_tmppath (gf_store_handle_t *shandle) int32_t ret = -1; char tmppath[PATH_MAX] = {0,}; - GF_ASSERT (shandle); - GF_ASSERT (shandle->path); + GF_VALIDATE_OR_GOTO ("store", shandle, out); + GF_VALIDATE_OR_GOTO ("store", shandle->path, out); snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path); ret = unlink (tmppath); @@ -160,7 +160,7 @@ gf_store_unlink_tmppath (gf_store_handle_t *shandle) } else { ret = 0; } - +out: return ret; } -- cgit From aa3b01533efcd85fc1e654ac14a03ab8e1d5bbab Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Tue, 3 Dec 2013 16:30:45 -0800 Subject: locks: various fixes - implement ref/unref of entry locks (and fix bad pointer deref crashes) - code cleanup and deleted various data types - fix improper read/write lock conflict detection in entrylk - fix indefinite hang of blocked locks on disconnect - register locks in client_t synchronously, fix crashes in disconnect path Change-Id: Id273690c9111b8052139d1847060d1fb5a711924 BUG: 849630 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/6638 Tested-by: Gluster Build System Reviewed-by: Kaleb KEITHLEY Reviewed-by: Vijay Bellur --- libglusterfs/src/client_t.h | 1 + libglusterfs/src/glusterfs.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/client_t.h b/libglusterfs/src/client_t.h index f7812f8f0..548081896 100644 --- a/libglusterfs/src/client_t.h +++ b/libglusterfs/src/client_t.h @@ -60,6 +60,7 @@ struct clienttable { gf_lock_t lock; cliententry_t *cliententries; int first_free; + client_t *local; }; typedef struct clienttable clienttable_t; diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index ed483d19c..6dc2fe6df 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -455,7 +455,6 @@ struct _glusterfs_ctx { int daemon_pipe[2]; - struct client_disconnect *client_disconnect; struct clienttable *clienttable; }; typedef struct _glusterfs_ctx glusterfs_ctx_t; -- cgit From 3af42583dd804371952d61e9d7ff4c640e67ba0d Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Sun, 12 Jan 2014 22:39:14 +0530 Subject: storage/posix: UNWIND right op_error and op_errno in *setxattr() 1. errno was being set after gf_log() in posix_{f}handle_pair, this would cause errno to be overwritten. 2. dht would expect -1 for indication of failure in setxattr callback (dht_err_cbk()). posix_{f}setxattr has been changed to set op_ret as -1 instead of -op_errno. 3. dict_foreach() has been changed to return an error if the invoked fn() returns < 0. Bug report and test case credits to Zorro Lang Change-Id: I96c15f12a5d7717b7584ba392f390a0b4f704a98 BUG: 1051896 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/6684 Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Anand Avati --- libglusterfs/src/dict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index f2df5a6d4..e9fc1222d 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -1121,8 +1121,8 @@ dict_foreach (dict_t *dict, while (pairs) { next = pairs->next; ret = fn (dict, pairs->key, pairs->value, data); - if (ret == -1) - return -1; + if (ret < 0) + return ret; pairs = next; } -- cgit From 54bf0ba4698a2d46db3485cc12ae04dd90349570 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Fri, 3 Jan 2014 11:59:43 +0530 Subject: consolidate code for #ifdef HAVE_LINKAT usage sys_link() now does ifdef HAVE_LINKAT linkat (...) else link (...) endif Use sys_link() in all places where we previously had the conditional behavior. Change-Id: I8bce5ac1175efd2ba7ab4bb5b372f6d1e0365d28 BUG: 764655 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/6633 Tested-by: Gluster Build System Reviewed-by: Xavier Hernandez Reviewed-by: Anand Avati --- libglusterfs/src/syscall.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c index 117fa209e..d1b9ef84c 100644 --- a/libglusterfs/src/syscall.c +++ b/libglusterfs/src/syscall.c @@ -121,7 +121,13 @@ int sys_link (const char *oldpath, const char *newpath) { #ifdef HAVE_LINKAT - /* see HAVE_LINKAT in xlators/storage/posix/src/posix.c */ + /* + * On most systems (Linux being the notable exception), link(2) + * first resolves symlinks. If the target is a directory or + * is nonexistent, it will fail. linkat(2) operates on the + * symlink instead of its target when the AT_SYMLINK_FOLLOW + * flag is not supplied. + */ return linkat (AT_FDCWD, oldpath, AT_FDCWD, newpath, 0); #else return link (oldpath, newpath); -- cgit