summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glusterfsd/src/glusterfsd.c6
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c156
-rw-r--r--xlators/features/locks/src/common.c4
-rw-r--r--xlators/features/locks/src/internal.c18
-rw-r--r--xlators/features/locks/src/posix.c8
-rw-r--r--xlators/protocol/server/src/server-protocol.c12
6 files changed, 149 insertions, 55 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 2ad644e9fd4..3c9e77822d3 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -178,14 +178,14 @@ _gf_dump_details (int argc, char **argv)
mypid = getpid ();
uname_ret = uname (&uname_buf);
- /* Which TLA? What time? */
+ /* Which git? What time? */
strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm);
fprintf (gf_log_logfile,
"========================================"
"========================================\n");
- fprintf (gf_log_logfile, "Version : %s %s built on %s %s\n",
+ fprintf (gf_log_logfile, "Version : %s %s built on %s %s\n",
PACKAGE_NAME, PACKAGE_VERSION, __DATE__, __TIME__);
- fprintf (gf_log_logfile, "TLA Revision : %s\n",
+ fprintf (gf_log_logfile, "git: %s\n",
GLUSTERFS_REPOSITORY_REVISION);
fprintf (gf_log_logfile, "Starting Time: %s\n", timestr);
fprintf (gf_log_logfile, "Command line : ");
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 7ef55393d90..24e73a82703 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -1330,46 +1330,96 @@ libgf_free_vmp_entry (struct vmp_entry *entry)
FREE (entry);
}
-/* Returns the number of characters that match between an entry
- * and the path. Assumes string1 is vmp entry.
+int
+libgf_count_path_components (char *path)
+{
+ int compos = 0;
+ char *pathdup = NULL;
+ int len = 0;
+
+ if (!path)
+ return -1;
+
+ pathdup = strdup (path);
+ if (!pathdup)
+ return -1;
+
+ len = strlen (pathdup);
+ if (pathdup[len - 1] == '/')
+ pathdup[len - 1] = '\0';
+
+ path = pathdup;
+ while ((path = strchr (path, '/'))) {
+ compos++;
+ ++path;
+ }
+
+ free (pathdup);
+ return compos;
+}
+
+/* Returns the number of components that match between
+ * the VMP and the path. Assumes string1 is vmp entry.
* Assumes both are absolute paths.
*/
int
-libgf_strmatchcount (char *string1, int s1len, char *string2, int s2len)
+libgf_strmatchcount (char *string1, char *string2)
{
- int i = 0;
- int tosearch = 0;
int matchcount = 0;
+ char *s1dup = NULL, *s2dup = NULL;
+ char *tok1 = NULL, *saveptr1 = NULL;
+ char *tok2 = NULL, *saveptr2 = NULL;
- if (s1len <= s2len)
- tosearch = s1len;
- else
- tosearch = s2len;
+ if ((!string1) || (!string2))
+ return 0;
- for (;i < tosearch; i++) {
- if (string1[i] == string2[i])
- matchcount++;
- else
+ s1dup = strdup (string1);
+ if (!s1dup)
+ return 0;
+
+ s2dup = strdup (string2);
+ if (!s2dup)
+ goto free_s1;
+
+ string1 = s1dup;
+ string2 = s2dup;
+
+ tok1 = strtok_r(string1, "/", &saveptr1);
+ tok2 = strtok_r (string2, "/", &saveptr2);
+ while (tok1) {
+ if (!tok2)
break;
+
+ if (strcmp (tok1, tok2) != 0)
+ break;
+
+ matchcount++;
+ tok1 = strtok_r(NULL, "/", &saveptr1);
+ tok2 = strtok_r (NULL, "/", &saveptr2);
}
+ free (s2dup);
+free_s1:
+ free (s1dup);
return matchcount;
}
int
libgf_vmp_entry_match (struct vmp_entry *entry, char *path)
{
- return libgf_strmatchcount (entry->vmp, (entry->vmplen - 1), path,
- strlen(path));
+ return libgf_strmatchcount (entry->vmp, path);
}
+#define LIBGF_VMP_EXACT 1
+#define LIBGF_VMP_LONGESTPREFIX 0
struct vmp_entry *
-_libgf_vmp_search_entry (char *path)
+_libgf_vmp_search_entry (char *path, int searchtype)
{
struct vmp_entry *entry = NULL;
int matchcount = 0;
struct vmp_entry *maxentry = NULL;
int maxcount = 0;
+ int vmpcompcount = 0;
if (vmplist.entries == 0) {
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "Virtual Mount Point "
@@ -1379,17 +1429,56 @@ _libgf_vmp_search_entry (char *path)
list_for_each_entry(entry, &vmplist.list, list) {
matchcount = libgf_vmp_entry_match (entry, path);
- if ((matchcount == (entry->vmplen - 1)) &&
- (matchcount > maxcount)) {
+ if (matchcount > maxcount) {
maxcount = matchcount;
maxentry = entry;
}
}
+ /* To ensure that the longest prefix matched entry is also an exact
+ * match, this is used to check whether duplicate entries are present
+ * in the vmplist.
+ */
+ if ((searchtype == LIBGF_VMP_EXACT) && (maxentry)) {
+ vmpcompcount = libgf_count_path_components (maxentry->vmp);
+ if (vmpcompcount != matchcount)
+ maxentry = NULL;
+ }
+
out:
return maxentry;
}
+/* Used to search for a exactly matching VMP entry.
+ */
+struct vmp_entry *
+libgf_vmp_search_exact_entry (char *path)
+{
+ struct vmp_entry *entry = NULL;
+
+ if (!path)
+ goto out;
+
+ pthread_mutex_lock (&vmplock);
+ {
+ entry = _libgf_vmp_search_entry (path, LIBGF_VMP_EXACT);
+ }
+ pthread_mutex_unlock (&vmplock);
+
+out:
+ if (entry)
+ gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "VMP Entry found: path :%s"
+ " vmp: %s", path, entry->vmp);
+ else
+ gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "VMP Entry not found: path"
+ ": %s", path);
+
+ return entry;
+}
+
+
+/* Used to search for a longest prefix matching VMP entry.
+ */
struct vmp_entry *
libgf_vmp_search_entry (char *path)
{
@@ -1400,16 +1489,17 @@ libgf_vmp_search_entry (char *path)
pthread_mutex_lock (&vmplock);
{
- entry = _libgf_vmp_search_entry (path);
+ entry = _libgf_vmp_search_entry (path, LIBGF_VMP_LONGESTPREFIX);
}
pthread_mutex_unlock (&vmplock);
out:
if (entry)
- gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "VMP Entry found: %s: %s",
- path, entry->vmp);
+ gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "VMP Entry found: path :%s"
+ " vmp: %s", path, entry->vmp);
else
- gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "VMP Entry not found");
+ gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "VMP Entry not found: path"
+ ": %s", path);
return entry;
}
@@ -1424,16 +1514,16 @@ libgf_vmp_map_ghandle (char *vmp, glusterfs_handle_t *vmphandle)
if (!vmpentry)
goto out;
- /*
- FIXME: this is not thread-safe, but I couldn't find other place to
- do initialization.
- */
- if (vmplist.entries == 0) {
- INIT_LIST_HEAD (&vmplist.list);
- }
+ pthread_mutex_lock (&vmplock);
+ {
+ if (vmplist.entries == 0) {
+ INIT_LIST_HEAD (&vmplist.list);
+ }
- list_add_tail (&vmpentry->list, &vmplist.list);
- ++vmplist.entries;
+ list_add_tail (&vmpentry->list, &vmplist.list);
+ ++vmplist.entries;
+ }
+ pthread_mutex_unlock (&vmplock);
ret = 0;
out:
@@ -1473,7 +1563,7 @@ glusterfs_mount (char *vmp, glusterfs_init_params_t *ipars)
vmphash = (dev_t)ReallySimpleHash (vmp, strlen (vmp));
pthread_mutex_lock (&mountlock);
{
- vmp_entry = _libgf_vmp_search_entry (vmp);
+ vmp_entry = libgf_vmp_search_exact_entry (vmp);
if (vmp_entry) {
ret = 0;
goto unlock;
@@ -1506,7 +1596,7 @@ _libgf_umount (char *vmp)
struct vmp_entry *entry= NULL;
int ret = -1;
- entry = _libgf_vmp_search_entry (vmp);
+ entry = libgf_vmp_search_exact_entry (vmp);
if (entry == NULL) {
gf_log ("libglusterfsclient", GF_LOG_ERROR,
"path (%s) not mounted", vmp);
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index 92441bde0fe..1f10aa20cf1 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -139,8 +139,8 @@ posix_lock_to_flock (posix_lock_t *lock, struct flock *flock)
flock->l_type = lock->fl_type;
flock->l_start = lock->fl_start;
- if (lock->fl_end == 0)
- flock->l_len = LLONG_MAX;
+ if (lock->fl_end == LLONG_MAX)
+ flock->l_len = 0;
else
flock->l_len = lock->fl_end - lock->fl_start + 1;
}
diff --git a/xlators/features/locks/src/internal.c b/xlators/features/locks/src/internal.c
index 817dab4a17e..6524721b453 100644
--- a/xlators/features/locks/src/internal.c
+++ b/xlators/features/locks/src/internal.c
@@ -181,9 +181,9 @@ pl_inodelk (call_frame_t *frame, xlator_t *this,
default:
op_errno = ENOTSUP;
- gf_log (this->name, GF_LOG_DEBUG,
- "Lock command F_GETLK not supported for [f]inodelk "
- "(cmd=%d)",
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unexpected case in inodelk (cmd=%d). "
+ "Please file a bug report at http://bugs.gluster.com",
cmd);
goto unwind;
}
@@ -284,8 +284,8 @@ pl_finodelk (call_frame_t *frame, xlator_t *this,
default:
op_errno = ENOTSUP;
gf_log (this->name, GF_LOG_ERROR,
- "Lock command F_GETLK not supported for [f]inodelk "
- "(cmd=%d)",
+ "Unexpected case in finodelk (cmd=%d). "
+ "Please file a bug report at http://bugs.gluster.com",
cmd);
goto unwind;
}
@@ -775,8 +775,8 @@ pl_entrylk (call_frame_t *frame, xlator_t *this,
default:
gf_log (this->name, GF_LOG_ERROR,
- "Unexpected case in entrylk (cmd=%d). Please send"
- "a bug report to gluster-devel@nongnu.org", cmd);
+ "Unexpected case in entrylk (cmd=%d). Please file"
+ "a bug report at http://bugs.gluster.com", cmd);
goto out;
}
@@ -879,9 +879,9 @@ pl_fentrylk (call_frame_t *frame, xlator_t *this,
break;
default:
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_ERROR,
"Unexpected case in fentrylk (cmd=%d). "
- "Please send a bug report to gluster-devel@nongnu.org",
+ "Please file a bug report at http://bugs.gluster.com",
cmd);
goto out;
}
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 144c8fedffb..d672beaebc3 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -715,7 +715,7 @@ pl_forget (xlator_t *this,
pl_inode = pl_inode_get (this, inode);
if (!list_empty (&pl_inode->rw_list)) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_log (this->name, GF_LOG_DEBUG,
"Pending R/W requests found, releasing.");
list_for_each_entry_safe (rw_req, rw_tmp, &pl_inode->rw_list,
@@ -727,7 +727,7 @@ pl_forget (xlator_t *this,
}
if (!list_empty (&pl_inode->ext_list)) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_log (this->name, GF_LOG_DEBUG,
"Pending fcntl locks found, releasing.");
list_for_each_entry_safe (ext_l, ext_tmp, &pl_inode->ext_list,
@@ -739,7 +739,7 @@ pl_forget (xlator_t *this,
}
if (!list_empty (&pl_inode->int_list)) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_log (this->name, GF_LOG_DEBUG,
"Pending inode locks found, releasing.");
list_for_each_entry_safe (int_l, int_tmp, &pl_inode->int_list,
@@ -751,7 +751,7 @@ pl_forget (xlator_t *this,
}
if (!list_empty (&pl_inode->dir_list)) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_log (this->name, GF_LOG_DEBUG,
"Pending entry locks found, releasing.");
list_for_each_entry_safe (entry_l, entry_tmp,
diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c
index 86c8be962b6..220f5b3b466 100644
--- a/xlators/protocol/server/src/server-protocol.c
+++ b/xlators/protocol/server/src/server-protocol.c
@@ -51,6 +51,7 @@ protocol_server_reply (call_frame_t *frame, int type, int op,
server_state_t *state = NULL;
xlator_t *bound_xl = NULL;
transport_t *trans = NULL;
+ int ret = 0;
bound_xl = BOUND_XL (frame);
state = CALL_STATE (frame);
@@ -60,10 +61,13 @@ protocol_server_reply (call_frame_t *frame, int type, int op,
hdr->type = hton32 (type);
hdr->op = hton32 (op);
- transport_submit (trans, (char *)hdr, hdrlen, vector, count, iobref);
- /* TODO: If transport submit fails, there is no reply sent to client,
- * its bailed out as of now.. loggically, only this frame should fail.
- */
+ ret = transport_submit (trans, (char *)hdr, hdrlen, vector,
+ count, iobref);
+ if (ret < 0) {
+ gf_log ("protocol/server", GF_LOG_ERROR,
+ "frame %"PRId64": failed to submit. op= %d, type= %d",
+ frame->root->unique, op, type);
+ }
STACK_DESTROY (frame->root);