rpc: split FOPs enum from glusterfs.h

Moving the enumeration of FOPs and some of the other parts that are
defining the network protocol to the rpc/xdr/ section. These structures
need some care when modifications are made, moving them out of the
common glusterfs.h header helps with that.

The protocol definition structures are generated in a new glusterfs-fops
header. This file is present in rpc/xdr/src/ and libglusterfs/src/, it
is a little ugly, but prevents the need to update all Makefile.am files
with the additional -I option for finding the new header file.

The generation of the .c and .h files from the .x descriptions needed
small modifications to accommodate these changes. The build/xdrgen
script was improved slightly for this. The .c and .h files are
incorrectly in the $(top_srcdir), instead of $(top_builddir). This is
an existing issue, and bug 1330604 has been filed to get that addressed.

Change-Id: I98fc8cf7e4b631082c7b203b5a0a77111bec1fb9
BUG: 1328502
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/14032
Smoke: Gluster Build System <jenkins@build.gluster.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
This commit is contained in:
Niels de Vos 2016-04-18 21:47:18 +02:00 committed by Jeff Darcy
parent 40e96c1764
commit 2f945b86d3
14 changed files with 236 additions and 205 deletions

1
.gitignore vendored
View File

@ -80,6 +80,7 @@ libglusterfs/src/graph.lex.c
libglusterfs/src/y.tab.c
libglusterfs/src/y.tab.h
libglusterfs/src/defaults.c
libglusterfs/src/glusterfs-fops.h
libtool
run-tests.sh
tests/env.rc

View File

@ -1,5 +1,8 @@
#!/bin/sh
# error out if an error occurs
set -e
append_licence_header ()
{
local src_file=$1;
@ -7,7 +10,7 @@ append_licence_header ()
cat >$dst_file <<EOF
/*
Copyright (c) 2007-2014 Red Hat, Inc. <http://www.redhat.com>
Copyright (c) 2007-2016 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
This file is licensed to you under your choice of the GNU Lesser
@ -17,8 +20,6 @@ append_licence_header ()
*/
#include "compat.h"
#include "xdr-common.h"
#include "xdr-nfs3.h"
#if defined(__GNUC__)
#if __GNUC__ >= 4
@ -74,7 +75,7 @@ gen_headers ()
rm -f $hfile;
rpcgen -h -o $hfile $xfile;
# the '#ifdef' part of file should be fixed
sed -e 's/-/_/g' $hfile > ${hfile}.new && mv ${hfile}.new $hfile;
sed -r -e '/#(ifdef|ifndef|define)/s/-/_/g' $hfile > ${hfile}.new && mv ${hfile}.new $hfile;
# Gen header to temp file and append generated file
append_licence_header $hfile $tmp_hfile;
# now move the destination file to actual original file

View File

@ -1276,7 +1276,7 @@ CONTRIBDIR='$(top_srcdir)/contrib'
AC_SUBST(CONTRIBDIR)
GF_CPPDEFINES='-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)'
GF_CPPINCLUDES='-include $(top_builddir)/config.h -I$(top_srcdir)/libglusterfs/src'
GF_CPPINCLUDES='-include $(top_builddir)/config.h -I$(top_srcdir)/libglusterfs/src -I$(top_builddir)/libglusterfs/src'
GF_CPPFLAGS="$GF_CPPFLAGS $GF_CPPDEFINES $GF_CPPINCLUDES"
AC_SUBST([GF_CPPFLAGS])

View File

@ -34,9 +34,9 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
$(CONTRIBDIR)/timer-wheel/find_last_bit.c tw.c default-args.c locking.c
nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c defaults.c
nodist_libglusterfs_la_HEADERS = y.tab.h
nodist_libglusterfs_la_HEADERS = y.tab.h glusterfs-fops.h
BUILT_SOURCES = graph.lex.c defaults.c
BUILT_SOURCES = graph.lex.c defaults.c glusterfs-fops.h
libglusterfs_la_HEADERS = common-utils.h defaults.h default-args.h \
dict.h glusterfs.h hashfn.h timespec.h logging.h xlator.h \
@ -84,6 +84,12 @@ y.tab.h: graph.y
defaults.c: defaults-tmpl.c generator.py gen-defaults.py
$(PYTHON) $(srcdir)/gen-defaults.py $(srcdir)/defaults-tmpl.c > $@
$(top_srcdir)/rpc/xdr/src/glusterfs-fops.h: $(top_srcdir)/rpc/xdr/src/glusterfs-fops.x
$(MAKE) -C $(top_builddir)/rpc/xdr/src/ `basename $@`
glusterfs-fops.h: $(top_srcdir)/rpc/xdr/src/glusterfs-fops.h
cp $(top_srcdir)/rpc/xdr/src/glusterfs-fops.h .
CLEANFILES = $(nodist_libglusterfs_la_SOURCES) $(nodist_libglusterfs_la_HEADERS)
if UNITTEST

View File

@ -29,6 +29,8 @@
#include <pthread.h>
#include <limits.h> /* For PATH_MAX */
#include "glusterfs-fops.h" /* generated XDR values for FOPs */
#include "list.h"
#include "logging.h"
#include "lkowner.h"
@ -266,162 +268,9 @@
#define GF_BACKTRACE_LEN 4096
#define GF_BACKTRACE_FRAME_COUNT 7
/* NOTE: add members ONLY at the end (just before _MAXVALUE) */
/*
* OTHER NOTE: fop_enum_to_str and fop_enum_to_pri_str (in common-utils.h)
* and gf_fop_list in globals.c also
* contain lists of fops, so if you update this list UPDATE THOSE TOO.
*/
typedef enum {
GF_FOP_NULL = 0,
GF_FOP_STAT,
GF_FOP_READLINK,
GF_FOP_MKNOD,
GF_FOP_MKDIR,
GF_FOP_UNLINK,
GF_FOP_RMDIR,
GF_FOP_SYMLINK,
GF_FOP_RENAME,
GF_FOP_LINK,
GF_FOP_TRUNCATE,
GF_FOP_OPEN,
GF_FOP_READ,
GF_FOP_WRITE,
GF_FOP_STATFS,
GF_FOP_FLUSH,
GF_FOP_FSYNC, /* 16 */
GF_FOP_SETXATTR,
GF_FOP_GETXATTR,
GF_FOP_REMOVEXATTR,
GF_FOP_OPENDIR,
GF_FOP_FSYNCDIR,
GF_FOP_ACCESS,
GF_FOP_CREATE,
GF_FOP_FTRUNCATE,
GF_FOP_FSTAT, /* 25 */
GF_FOP_LK,
GF_FOP_LOOKUP,
GF_FOP_READDIR,
GF_FOP_INODELK,
GF_FOP_FINODELK,
GF_FOP_ENTRYLK,
GF_FOP_FENTRYLK,
GF_FOP_XATTROP,
GF_FOP_FXATTROP,
GF_FOP_FGETXATTR,
GF_FOP_FSETXATTR,
GF_FOP_RCHECKSUM,
GF_FOP_SETATTR,
GF_FOP_FSETATTR,
GF_FOP_READDIRP,
GF_FOP_FORGET,
GF_FOP_RELEASE,
GF_FOP_RELEASEDIR,
GF_FOP_GETSPEC,
GF_FOP_FREMOVEXATTR,
GF_FOP_FALLOCATE,
GF_FOP_DISCARD,
GF_FOP_ZEROFILL,
GF_FOP_IPC,
GF_FOP_SEEK,
GF_FOP_LEASE,
GF_FOP_COMPOUND,
GF_FOP_MAXVALUE,
} glusterfs_fop_t;
const char *fop_enum_to_pri_string (glusterfs_fop_t fop);
const char *fop_enum_to_string (glusterfs_fop_t fop);
typedef enum {
GF_MGMT_NULL = 0,
GF_MGMT_MAXVALUE,
} glusterfs_mgmt_t;
typedef enum {
GF_OP_TYPE_NULL = 0,
GF_OP_TYPE_FOP,
GF_OP_TYPE_MGMT,
GF_OP_TYPE_MAX,
} gf_op_type_t;
/* NOTE: all the miscellaneous flags used by GlusterFS should be listed here */
typedef enum {
GF_LK_GETLK = 0,
GF_LK_SETLK,
GF_LK_SETLKW,
GF_LK_RESLK_LCK,
GF_LK_RESLK_LCKW,
GF_LK_RESLK_UNLCK,
GF_LK_GETLK_FD,
} glusterfs_lk_cmds_t;
typedef enum {
GF_LK_F_RDLCK = 0,
GF_LK_F_WRLCK,
GF_LK_F_UNLCK,
GF_LK_EOL,
} glusterfs_lk_types_t;
/* Lease Types */
enum gf_lease_types {
NONE = 0,
GF_RD_LEASE = 1,
GF_RW_LEASE = 2,
GF_LEASE_MAX_TYPE,
};
typedef enum gf_lease_types gf_lease_types_t;
/* Lease cmds */
enum gf_lease_cmds {
GF_GET_LEASE = 1,
GF_SET_LEASE = 2,
GF_UNLK_LEASE = 3,
};
typedef enum gf_lease_cmds gf_lease_cmds_t;
typedef enum {
F_RESLK_LCK = 200,
F_RESLK_LCKW,
F_RESLK_UNLCK,
F_GETLK_FD,
} glusterfs_lk_recovery_cmds_t;
typedef enum {
GF_LOCK_POSIX,
GF_LOCK_INTERNAL
} gf_lk_domain_t;
typedef enum {
ENTRYLK_LOCK,
ENTRYLK_UNLOCK,
ENTRYLK_LOCK_NB
} entrylk_cmd;
typedef enum {
ENTRYLK_RDLCK,
ENTRYLK_WRLCK
} entrylk_type;
typedef enum {
GF_XATTROP_ADD_ARRAY,
GF_XATTROP_ADD_ARRAY64,
GF_XATTROP_OR_ARRAY,
GF_XATTROP_AND_ARRAY,
GF_XATTROP_GET_AND_SET,
GF_XATTROP_ADD_ARRAY_WITH_DEFAULT,
GF_XATTROP_ADD_ARRAY64_WITH_DEFAULT
} gf_xattrop_flags_t;
typedef enum {
GF_SEEK_DATA,
GF_SEEK_HOLE
} gf_seek_what_t;
#define GF_SET_IF_NOT_PRESENT 0x1 /* default behaviour */
#define GF_SET_OVERWRITE 0x2 /* Overwrite with the buf given */
#define GF_SET_DIR_ONLY 0x4
@ -638,39 +487,6 @@ typedef struct _glusterfs_ctx glusterfs_ctx_t;
glusterfs_ctx_t *glusterfs_ctx_new (void);
typedef enum {
GF_EVENT_PARENT_UP = 1,
GF_EVENT_POLLIN,
GF_EVENT_POLLOUT,
GF_EVENT_POLLERR,
GF_EVENT_CHILD_UP,
GF_EVENT_CHILD_DOWN,
GF_EVENT_CHILD_CONNECTING,
GF_EVENT_CHILD_MODIFIED,
GF_EVENT_TRANSPORT_CLEANUP,
GF_EVENT_TRANSPORT_CONNECTED,
GF_EVENT_VOLFILE_MODIFIED,
GF_EVENT_GRAPH_NEW,
GF_EVENT_TRANSLATOR_INFO,
GF_EVENT_TRANSLATOR_OP,
GF_EVENT_AUTH_FAILED,
GF_EVENT_VOLUME_DEFRAG,
GF_EVENT_PARENT_DOWN,
GF_EVENT_VOLUME_BARRIER_OP,
GF_EVENT_UPCALL,
GF_EVENT_SCRUB_STATUS,
GF_EVENT_SOME_CHILD_DOWN,
GF_EVENT_MAXVAL,
} glusterfs_event_t;
#define LEASE_ID_SIZE 16 /* 128bits */
struct gf_lease {
gf_lease_cmds_t cmd;
gf_lease_types_t lease_type;
char lease_id[LEASE_ID_SIZE];
unsigned int lease_flags;
};
struct gf_flock {
short l_type;
short l_whence;

View File

@ -11,17 +11,7 @@
#ifndef _LK_OWNER_H
#define _LK_OWNER_H
#define GF_MAX_LOCK_OWNER_LEN 1024 /* 1kB as per NLM */
/* 16strings-16strings-... */
#define GF_LKOWNER_BUF_SIZE ((GF_MAX_LOCK_OWNER_LEN * 2) + \
(GF_MAX_LOCK_OWNER_LEN / 8))
typedef struct gf_lkowner_ {
int len;
char data[GF_MAX_LOCK_OWNER_LEN];
} gf_lkowner_t;
#include "glusterfs-fops.h"
/* LKOWNER to string functions */
static inline void

View File

@ -8,6 +8,8 @@ glusterd1-xdr.c
glusterd1-xdr.h
glusterfs3-xdr.c
glusterfs3-xdr.h
glusterfs-fops.h
glusterfs-fops.c
mount3udp.c
mount3udp.h
nlm4-xdr.c

View File

@ -1,6 +1,6 @@
XDRSOURCES = glusterfs3-xdr.c cli1-xdr.c nlm4-xdr.c nsm-xdr.c \
rpc-common-xdr.c glusterd1-xdr.c acl3-xdr.c portmap-xdr.c \
mount3udp.c changelog-xdr.c
mount3udp.c changelog-xdr.c glusterfs-fops.c
XDRHEADERS = $(XDRSOURCES:.c=.h)
XDRGENFILES = $(XDRSOURCES:.c=.x)
@ -30,6 +30,15 @@ EXTRA_DIST = $(XDRGENFILES)
CLEANFILES = $(XDRSOURCES) $(XDRHEADERS)
xdrsrc=$(top_srcdir)/rpc/xdr/src
glusterfs-fops.c: glusterfs-fops.x glusterfs-fops.h
$(top_srcdir)/build-aux/xdrgen source $(xdrsrc)/`basename ${@:.c=.x}`
glusterfs-fops.h: glusterfs-fops.x
$(top_srcdir)/build-aux/xdrgen header $(xdrsrc)/`basename ${@:.h=.x}`
$(top_srcdir)/libglusterfs/src/glusterfs-fops.h: glusterfs-fops.h
cp $(xdrsrc)/`basename $@` $(top_srcdir)/libglusterfs/src/
glusterfs3-xdr.c: glusterfs3-xdr.x glusterfs3-xdr.h
$(top_srcdir)/build-aux/xdrgen source $(xdrsrc)/`basename ${@:.c=.x}`

View File

@ -8,6 +8,7 @@
* cases as published by the Free Software Foundation.
*/
%#include "xdr-nfs3.h"
struct aclentry {
int type;

View File

@ -0,0 +1,196 @@
/* NOTE: add members ONLY at the end (just before _MAXVALUE) */
/*
* OTHER NOTE: fop_enum_to_str and fop_enum_to_pri_str (in common-utils.h) also
* contain lists of fops, so if you update this list UPDATE THOSE TOO.
*/
enum glusterfs_fop_t {
GF_FOP_NULL = 0,
GF_FOP_STAT,
GF_FOP_READLINK,
GF_FOP_MKNOD,
GF_FOP_MKDIR,
GF_FOP_UNLINK,
GF_FOP_RMDIR,
GF_FOP_SYMLINK,
GF_FOP_RENAME,
GF_FOP_LINK,
GF_FOP_TRUNCATE,
GF_FOP_OPEN,
GF_FOP_READ,
GF_FOP_WRITE,
GF_FOP_STATFS,
GF_FOP_FLUSH,
GF_FOP_FSYNC, /* 16 */
GF_FOP_SETXATTR,
GF_FOP_GETXATTR,
GF_FOP_REMOVEXATTR,
GF_FOP_OPENDIR,
GF_FOP_FSYNCDIR,
GF_FOP_ACCESS,
GF_FOP_CREATE,
GF_FOP_FTRUNCATE,
GF_FOP_FSTAT, /* 25 */
GF_FOP_LK,
GF_FOP_LOOKUP,
GF_FOP_READDIR,
GF_FOP_INODELK,
GF_FOP_FINODELK,
GF_FOP_ENTRYLK,
GF_FOP_FENTRYLK,
GF_FOP_XATTROP,
GF_FOP_FXATTROP,
GF_FOP_FGETXATTR,
GF_FOP_FSETXATTR,
GF_FOP_RCHECKSUM,
GF_FOP_SETATTR,
GF_FOP_FSETATTR,
GF_FOP_READDIRP,
GF_FOP_FORGET,
GF_FOP_RELEASE,
GF_FOP_RELEASEDIR,
GF_FOP_GETSPEC,
GF_FOP_FREMOVEXATTR,
GF_FOP_FALLOCATE,
GF_FOP_DISCARD,
GF_FOP_ZEROFILL,
GF_FOP_IPC,
GF_FOP_SEEK,
GF_FOP_LEASE,
GF_FOP_COMPOUND,
GF_FOP_MAXVALUE
};
enum glusterfs_event_t {
GF_EVENT_PARENT_UP = 1,
GF_EVENT_POLLIN,
GF_EVENT_POLLOUT,
GF_EVENT_POLLERR,
GF_EVENT_CHILD_UP,
GF_EVENT_CHILD_DOWN,
GF_EVENT_CHILD_CONNECTING,
GF_EVENT_CHILD_MODIFIED,
GF_EVENT_TRANSPORT_CLEANUP,
GF_EVENT_TRANSPORT_CONNECTED,
GF_EVENT_VOLFILE_MODIFIED,
GF_EVENT_GRAPH_NEW,
GF_EVENT_TRANSLATOR_INFO,
GF_EVENT_TRANSLATOR_OP,
GF_EVENT_AUTH_FAILED,
GF_EVENT_VOLUME_DEFRAG,
GF_EVENT_PARENT_DOWN,
GF_EVENT_VOLUME_BARRIER_OP,
GF_EVENT_UPCALL,
GF_EVENT_SCRUB_STATUS,
GF_EVENT_SOME_CHILD_DOWN,
GF_EVENT_MAXVAL
};
/* List of compound fops. Add fops at the end. */
enum glusterfs_compound_fop_t {
GF_CFOP_NON_PREDEFINED = 0, /* needs single FOP inspection */
GF_CFOP_XATTROP_WRITEV,
GF_CFOP_XATTROP_UNLOCK,
GF_CFOP_PUT, /* create+write+setxattr+fsync+close+rename */
GF_CFOP_MAXVALUE
};
enum glusterfs_mgmt_t {
GF_MGMT_NULL = 0,
GF_MGMT_MAXVALUE
};
enum gf_op_type_t {
GF_OP_TYPE_NULL = 0,
GF_OP_TYPE_FOP,
GF_OP_TYPE_MGMT,
GF_OP_TYPE_MAX
};
/* NOTE: all the miscellaneous flags used by GlusterFS should be listed here */
enum glusterfs_lk_cmds_t {
GF_LK_GETLK = 0,
GF_LK_SETLK,
GF_LK_SETLKW,
GF_LK_RESLK_LCK,
GF_LK_RESLK_LCKW,
GF_LK_RESLK_UNLCK,
GF_LK_GETLK_FD
};
enum glusterfs_lk_types_t {
GF_LK_F_RDLCK = 0,
GF_LK_F_WRLCK,
GF_LK_F_UNLCK,
GF_LK_EOL
};
/* Lease Types */
enum gf_lease_types_t {
NONE = 0,
GF_RD_LEASE = 1,
GF_RW_LEASE = 2,
GF_LEASE_MAX_TYPE
};
/* Lease cmds */
enum gf_lease_cmds_t {
GF_GET_LEASE = 1,
GF_SET_LEASE = 2,
GF_UNLK_LEASE = 3
};
%#define LEASE_ID_SIZE 16 /* 128bits */
struct gf_lease {
gf_lease_cmds_t cmd;
gf_lease_types_t lease_type;
char lease_id[LEASE_ID_SIZE];
unsigned int lease_flags;
};
enum glusterfs_lk_recovery_cmds_t {
F_RESLK_LCK = 200,
F_RESLK_LCKW,
F_RESLK_UNLCK,
F_GETLK_FD
};
enum gf_lk_domain_t {
GF_LOCK_POSIX,
GF_LOCK_INTERNAL
};
enum entrylk_cmd {
ENTRYLK_LOCK,
ENTRYLK_UNLOCK,
ENTRYLK_LOCK_NB
};
enum entrylk_type {
ENTRYLK_RDLCK,
ENTRYLK_WRLCK
};
%#define GF_MAX_LOCK_OWNER_LEN 1024 /* 1kB as per NLM */
/* 16strings-16strings-... */
%#define GF_LKOWNER_BUF_SIZE ((GF_MAX_LOCK_OWNER_LEN * 2) + (GF_MAX_LOCK_OWNER_LEN / 8))
struct gf_lkowner_t {
int len;
char data[GF_MAX_LOCK_OWNER_LEN];
};
enum gf_xattrop_flags_t {
GF_XATTROP_ADD_ARRAY,
GF_XATTROP_ADD_ARRAY64,
GF_XATTROP_OR_ARRAY,
GF_XATTROP_AND_ARRAY,
GF_XATTROP_GET_AND_SET,
GF_XATTROP_ADD_ARRAY_WITH_DEFAULT,
GF_XATTROP_ADD_ARRAY64_WITH_DEFAULT
};
enum gf_seek_what_t {
GF_SEEK_DATA,
GF_SEEK_HOLE
};

View File

@ -1,3 +1,6 @@
%#include "rpc-common-xdr.h"
%#include "glusterfs-fops.h"
#define GF_REQUEST_MAXGROUPS 16
struct gf_statfs {
u_quad_t bsize;

View File

@ -12,6 +12,8 @@
* mount3udp_svc.c is heavily modified though
*/
%#include "xdr-nfs3.h"
const MNTUDPPATHLEN = 1024;
typedef string mntudpdirpath<MNTPATHLEN>;

View File

@ -10,6 +10,8 @@
/* .x file defined as according to the RFC */
%#include "xdr-common.h"
const MAXNETOBJ_SZ = 1024;
const LM_MAXSTRLEN = 1024;
const MAXNAMELEN = 1025;

View File

@ -1,6 +1,8 @@
/* This file has definition of few XDR structures which are
* not captured in any section specific file */
%#include "xdr-common.h"
struct auth_glusterfs_parms_v2 {
int pid;
unsigned int uid;