summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-05-04 00:35:59 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-05-03 23:40:01 -0700
commit7504b0e623914d097933f0a613ba50e376131828 (patch)
tree70b29c4ec433a36a9e1a674a191ef1388ff34107
parent72ca9bdf90c45ff3f4bad3d2de934101dfaca4ff (diff)
structuring of protocol
* isolated 'protocol.h' and transport.h from libglusterfs/* and glusterfsd/* Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875
-rw-r--r--glusterfsd/src/fetch-spec.c1
-rw-r--r--glusterfsd/src/glusterfsd.c1
-rw-r--r--libglusterfs/src/gf-dirent.c96
-rw-r--r--libglusterfs/src/gf-dirent.h2
-rw-r--r--libglusterfs/src/globals.h6
-rw-r--r--libglusterfs/src/protocol.h101
-rw-r--r--libglusterfs/src/stack.h2
7 files changed, 101 insertions, 108 deletions
diff --git a/glusterfsd/src/fetch-spec.c b/glusterfsd/src/fetch-spec.c
index 0e293e087..6bf980dcc 100644
--- a/glusterfsd/src/fetch-spec.c
+++ b/glusterfsd/src/fetch-spec.c
@@ -30,7 +30,6 @@
#include "glusterfs.h"
#include "stack.h"
#include "dict.h"
-#include "transport.h"
#include "event.h"
#include "defaults.h"
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 570e7c195..f7140ad3b 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -59,7 +59,6 @@
#include "compat.h"
#include "logging.h"
#include "dict.h"
-#include "protocol.h"
#include "list.h"
#include "timer.h"
#include "glusterfsd.h"
diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c
index e3c1f1b90..5ae74f982 100644
--- a/libglusterfs/src/gf-dirent.c
+++ b/libglusterfs/src/gf-dirent.c
@@ -29,25 +29,6 @@
#include <stdint.h>
#include "compat.h"
#include "xlator.h"
-#include "byte-order.h"
-#include "protocol.h"
-
-
-struct gf_dirent_nb {
- uint64_t d_ino;
- uint64_t d_off;
- uint32_t d_len;
- uint32_t d_type;
- struct gf_stat d_stat;
- char d_name[0];
-} __attribute__((packed));
-
-
-int
-gf_dirent_nb_size (gf_dirent_t *entries)
-{
- return (sizeof (struct gf_dirent_nb) + strlen (entries->d_name) + 1);
-}
gf_dirent_t *
gf_dirent_for_namelen (int len)
@@ -111,80 +92,3 @@ gf_dirent_free (gf_dirent_t *entries)
}
-int
-gf_dirent_serialize (gf_dirent_t *entries, char *buf, size_t buf_size)
-{
- struct gf_dirent_nb *entry_nb = NULL;
- gf_dirent_t *entry = NULL;
- int size = 0;
- int entry_size = 0;
-
-
- list_for_each_entry (entry, &entries->list, list) {
- entry_size = gf_dirent_nb_size (entry);
-
- if (buf && (size + entry_size <= buf_size)) {
- entry_nb = (void *) (buf + size);
-
- entry_nb->d_ino = hton64 (entry->d_ino);
- entry_nb->d_off = hton64 (entry->d_off);
- entry_nb->d_len = hton32 (entry->d_len);
- entry_nb->d_type = hton32 (entry->d_type);
-
- gf_stat_from_iatt (&entry_nb->d_stat, &entry->d_stat);
-
- strcpy (entry_nb->d_name, entry->d_name);
- }
- size += entry_size;
- }
-
- return size;
-}
-
-
-int
-gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t buf_size)
-{
- struct gf_dirent_nb *entry_nb = NULL;
- int remaining_size = 0;
- int least_dirent_size = 0;
- int count = 0;
- gf_dirent_t *entry = NULL;
- int entry_strlen = 0;
- int entry_len = 0;
-
-
- remaining_size = buf_size;
- least_dirent_size = (sizeof (struct gf_dirent_nb) + 2);
-
- while (remaining_size >= least_dirent_size) {
- entry_nb = (void *)(buf + (buf_size - remaining_size));
-
- entry_strlen = strnlen (entry_nb->d_name, remaining_size);
- if (entry_strlen == remaining_size) {
- break;
- }
-
- entry_len = sizeof (gf_dirent_t) + entry_strlen + 1;
- entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t);
- if (!entry) {
- break;
- }
-
- entry->d_ino = ntoh64 (entry_nb->d_ino);
- entry->d_off = ntoh64 (entry_nb->d_off);
- entry->d_len = ntoh32 (entry_nb->d_len);
- entry->d_type = ntoh32 (entry_nb->d_type);
-
- gf_stat_to_iatt (&entry_nb->d_stat, &entry->d_stat);
-
- strcpy (entry->d_name, entry_nb->d_name);
-
- list_add_tail (&entry->list, &entries->list);
-
- remaining_size -= (sizeof (*entry_nb) + entry_strlen + 1);
- count++;
- }
-
- return count;
-}
diff --git a/libglusterfs/src/gf-dirent.h b/libglusterfs/src/gf-dirent.h
index 433f46aaa..abac13cf3 100644
--- a/libglusterfs/src/gf-dirent.h
+++ b/libglusterfs/src/gf-dirent.h
@@ -57,8 +57,6 @@ struct _gf_dirent_t {
gf_dirent_t *gf_dirent_for_name (const char *name);
void gf_dirent_free (gf_dirent_t *entries);
-int gf_dirent_serialize (gf_dirent_t *entries, char *buf, size_t size);
-int gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t size);
gf_dirent_t * gf_dirent_for_namelen (int len);
#endif /* _GF_DIRENT_H */
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h
index 89c8d7848..58f37d185 100644
--- a/libglusterfs/src/globals.h
+++ b/libglusterfs/src/globals.h
@@ -20,6 +20,12 @@
#ifndef _GLOBALS_H
#define _GLOBALS_H
+/* This corresponds to the max 16 number of group IDs that are sent through an
+ * RPC request. Since NFS is the only one going to set this, we can be safe
+ * in keeping this size hardcoded.
+ */
+#define GF_REQUEST_MAXGROUPS 16
+
#include "glusterfs.h"
#include "xlator.h"
diff --git a/libglusterfs/src/protocol.h b/libglusterfs/src/protocol.h
index 6e8a13067..6fd291bbe 100644
--- a/libglusterfs/src/protocol.h
+++ b/libglusterfs/src/protocol.h
@@ -952,12 +952,6 @@ typedef struct {
typedef struct { } __attribute__((packed)) gf_cbk_forget_rsp_t;
-/* This corresponds to the max 16 number of group IDs that are sent through an
- * RPC request. Since NFS is the only one going to set this, we can be safe
- * in keeping this size hardcoded.
- */
-#define GF_REQUEST_MAXGROUPS 16
-
typedef struct {
uint32_t pid;
uint32_t uid;
@@ -1022,4 +1016,99 @@ gf_param (gf_hdr_common_t *hdr)
return ((void *)hdr) + sizeof (*hdr);
}
+
+struct gf_dirent_nb {
+ uint64_t d_ino;
+ uint64_t d_off;
+ uint32_t d_len;
+ uint32_t d_type;
+ struct gf_stat d_stat;
+ char d_name[0];
+} __attribute__((packed));
+
+
+static inline int
+gf_dirent_nb_size (gf_dirent_t *entries)
+{
+ return (sizeof (struct gf_dirent_nb) + strlen (entries->d_name) + 1);
+}
+
+static inline int
+gf_dirent_serialize (gf_dirent_t *entries, char *buf, size_t buf_size)
+{
+ struct gf_dirent_nb *entry_nb = NULL;
+ gf_dirent_t *entry = NULL;
+ int size = 0;
+ int entry_size = 0;
+
+
+ list_for_each_entry (entry, &entries->list, list) {
+ entry_size = gf_dirent_nb_size (entry);
+
+ if (buf && (size + entry_size <= buf_size)) {
+ entry_nb = (void *) (buf + size);
+
+ entry_nb->d_ino = hton64 (entry->d_ino);
+ entry_nb->d_off = hton64 (entry->d_off);
+ entry_nb->d_len = hton32 (entry->d_len);
+ entry_nb->d_type = hton32 (entry->d_type);
+
+ gf_stat_from_iatt (&entry_nb->d_stat, &entry->d_stat);
+
+ strcpy (entry_nb->d_name, entry->d_name);
+ }
+ size += entry_size;
+ }
+
+ return size;
+}
+
+
+static inline int
+gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t buf_size)
+{
+ struct gf_dirent_nb *entry_nb = NULL;
+ int remaining_size = 0;
+ int least_dirent_size = 0;
+ int count = 0;
+ gf_dirent_t *entry = NULL;
+ int entry_strlen = 0;
+ int entry_len = 0;
+
+
+ remaining_size = buf_size;
+ least_dirent_size = (sizeof (struct gf_dirent_nb) + 2);
+
+ while (remaining_size >= least_dirent_size) {
+ entry_nb = (void *)(buf + (buf_size - remaining_size));
+
+ entry_strlen = strnlen (entry_nb->d_name, remaining_size);
+ if (entry_strlen == remaining_size) {
+ break;
+ }
+
+ entry_len = sizeof (gf_dirent_t) + entry_strlen + 1;
+ entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t);
+ if (!entry) {
+ break;
+ }
+
+ entry->d_ino = ntoh64 (entry_nb->d_ino);
+ entry->d_off = ntoh64 (entry_nb->d_off);
+ entry->d_len = ntoh32 (entry_nb->d_len);
+ entry->d_type = ntoh32 (entry_nb->d_type);
+
+ gf_stat_to_iatt (&entry_nb->d_stat, &entry->d_stat);
+
+ strcpy (entry->d_name, entry_nb->d_name);
+
+ list_add_tail (&entry->list, &entries->list);
+
+ remaining_size -= (sizeof (*entry_nb) + entry_strlen + 1);
+ count++;
+ }
+
+ return count;
+}
+
#endif
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index 645f633f5..c80ab9e9d 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -44,8 +44,6 @@ typedef struct _call_pool_t call_pool_t;
#include "list.h"
#include "common-utils.h"
#include "globals.h"
-#include "protocol.h"
-
typedef int32_t (*ret_fn_t) (call_frame_t *frame,
call_frame_t *prev_frame,