summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2014-01-14 17:00:14 +0000
committerJeff Darcy <jdarcy@redhat.com>2014-01-14 17:00:14 +0000
commit455791f265e6e581fa4ebddd5dc4642b2201f8ce (patch)
treeebd5cad9534291822f8c47dbbc8162525f8fe92e /libglusterfs
parent92eaa72ea4cd0d06c2161842c548008db0eee01c (diff)
parent7d89ec77763dc5076379753c736f7fce2bedd9ec (diff)
Merge branch 'upstream' into merge
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/client_t.h1
-rw-r--r--libglusterfs/src/dict.c4
-rw-r--r--libglusterfs/src/event-history.c1
-rw-r--r--libglusterfs/src/glusterfs.h10
-rw-r--r--libglusterfs/src/logging.c35
-rw-r--r--libglusterfs/src/logging.h2
-rw-r--r--libglusterfs/src/mem-types.h3
-rw-r--r--libglusterfs/src/store.c16
-rw-r--r--libglusterfs/src/syscall.c11
9 files changed, 67 insertions, 16 deletions
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/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;
}
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;
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 33d2087fc..8f3a2e6fa 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, \
@@ -452,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;
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...) \
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
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;
}
diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c
index e8954cc23..d1b9ef84c 100644
--- a/libglusterfs/src/syscall.c
+++ b/libglusterfs/src/syscall.c
@@ -120,7 +120,18 @@ sys_rename (const char *oldpath, const char *newpath)
int
sys_link (const char *oldpath, const char *newpath)
{
+#ifdef HAVE_LINKAT
+ /*
+ * 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);
+#endif
}