diff options
author | Harshavardhana <harsha@harshavardhana.net> | 2014-06-21 02:00:23 -0700 |
---|---|---|
committer | Harshavardhana <harsha@harshavardhana.net> | 2014-07-02 17:20:34 -0700 |
commit | 1b74cf992986287a510fe3b28a8ee7554e8b0992 (patch) | |
tree | a5fad911274080947f5874b4d90cc4f67b6f4473 /xlators | |
parent | e4a3566681acbadfe0f7bd879443116885ada4eb (diff) |
porting: Port for FreeBSD rebased from Mike Ma's efforts
- Provides a working Gluster Management Daemon, CLI
- Provides a working GlusterFS server, GlusterNFS server
- Provides a working GlusterFS client
- execinfo port from FreeBSD is moved into ./contrib/libexecinfo
for ease of portability on NetBSD. (FreeBSD 10 and OSX provide
execinfo natively)
- More portability cleanups for Darwin, FreeBSD and NetBSD
- Provides a new rc script for FreeBSD
Change-Id: I8dff336f97479ca5a7f9b8c6b730051c0f8ac46f
BUG: 1111774
Original-Author: Mike Ma <mikemandarine@gmail.com>
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/8141
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 1 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 1 | ||||
-rw-r--r-- | xlators/encryption/crypt/src/crypt.h | 2 | ||||
-rw-r--r-- | xlators/features/protect/src/Makefile.am | 6 | ||||
-rw-r--r-- | xlators/features/protect/src/prot_client.c | 44 | ||||
-rw-r--r-- | xlators/meta/src/meta-defaults.c | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-quota.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 11 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 9 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 2 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 2 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.h | 4 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-helpers.c | 33 | ||||
-rw-r--r-- | xlators/mount/fuse/utils/Makefile.am | 9 | ||||
-rw-r--r-- | xlators/performance/md-cache/src/md-cache.c | 1 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix-handle.c | 2 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 12 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.c | 4 |
19 files changed, 87 insertions, 61 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index e172569f3e1..45450d5f383 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -26,6 +26,7 @@ #include <sys/time.h> #include <libgen.h> +#include <signal.h> int dht_aggregate (dict_t *this, char *key, data_t *value, void *data) diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 9cdb4453820..eca1d52b62b 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -18,6 +18,7 @@ #include "xlator.h" #include <signal.h> #include <fnmatch.h> +#include <signal.h> #define GF_DISK_SECTOR_SIZE 512 #define DHT_REBALANCE_PID 4242 /* Change it if required */ diff --git a/xlators/encryption/crypt/src/crypt.h b/xlators/encryption/crypt/src/crypt.h index eb7291f13c5..b7aefc3d2c5 100644 --- a/xlators/encryption/crypt/src/crypt.h +++ b/xlators/encryption/crypt/src/crypt.h @@ -39,7 +39,7 @@ #define MASTER_VOL_KEY_SIZE (32) #define NMTD_VOL_KEY_SIZE (16) -#if defined(__NetBSD__) +#if defined(GF_BSD_HOST_OS) typedef off_t loff_t; #endif diff --git a/xlators/features/protect/src/Makefile.am b/xlators/features/protect/src/Makefile.am index 968e88c457a..fdfed4b219e 100644 --- a/xlators/features/protect/src/Makefile.am +++ b/xlators/features/protect/src/Makefile.am @@ -14,8 +14,8 @@ prot_server_la_LDFLAGS = -module -avoid-version prot_server_la_SOURCES = prot_server.c prot_server_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la -AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src +AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -I$(CONTRIBDIR)/libexecinfo AM_CFLAGS = -Wall $(GF_CFLAGS) -CLEANFILES = - +CLEANFILES = diff --git a/xlators/features/protect/src/prot_client.c b/xlators/features/protect/src/prot_client.c index d09715067bd..500c772bedd 100644 --- a/xlators/features/protect/src/prot_client.c +++ b/xlators/features/protect/src/prot_client.c @@ -15,8 +15,10 @@ #include "xlator.h" #include "defaults.h" -#ifndef __NetBSD__ +#ifdef HAVE_BACKTRACE #include <execinfo.h> +#else +#include "execinfo_compat.h" #endif #define NUM_FRAMES 20 @@ -44,20 +46,20 @@ pcli_print_trace (char *name, call_frame_t *frame) frame = frame->next; } - size = backtrace(frames,NUM_FRAMES); + size = backtrace (frames, NUM_FRAMES); if (size <= 0) { return; } - symbols = backtrace_symbols(frames,size); + symbols = backtrace_symbols (frames, size); if (!symbols) { return; } - gf_log(name, GF_LOG_INFO, "Processor stack:"); + gf_log (name, GF_LOG_INFO, "Processor stack:"); for (i = 0; i < size; ++i) { gf_log (name, GF_LOG_INFO, "%s", symbols[i]); } - free(symbols); + free (symbols); } int32_t @@ -73,14 +75,14 @@ pcli_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, if (!oldloc->parent) { goto simple_unwind; } - if (inode_ctx_get(oldloc->parent,this,&value) != 0) { + if (inode_ctx_get (oldloc->parent, this, &value) != 0) { goto simple_unwind; } if (value != PROT_ACT_NONE) { gf_log (this->name, GF_LOG_WARNING, "got rename for protected %s", oldloc->path); - pcli_print_trace(this->name,frame->next); + pcli_print_trace (this->name, frame->next); if (value == PROT_ACT_REJECT) { STACK_UNWIND_STRICT (rename, frame, -1, EPERM, NULL, NULL, NULL, NULL, NULL, @@ -181,25 +183,25 @@ simple_unwind: int32_t init (xlator_t *this) { - if (!this->children || this->children->next) { - gf_log (this->name, GF_LOG_ERROR, - "translator not configured with exactly one child"); - return -1; - } - - if (!this->parents) { - gf_log (this->name, GF_LOG_WARNING, - "dangling volume. check volfile "); - } - - return 0; + if (!this->children || this->children->next) { + gf_log (this->name, GF_LOG_ERROR, + "translator not configured with exactly one child"); + return -1; + } + + if (!this->parents) { + gf_log (this->name, GF_LOG_WARNING, + "dangling volume. check volfile "); + } + + return 0; } void fini (xlator_t *this) { - return; + return; } @@ -213,5 +215,5 @@ struct xlator_cbks cbks = { }; struct volume_options options[] = { - { .key = {NULL} }, + { .key = {NULL} }, }; diff --git a/xlators/meta/src/meta-defaults.c b/xlators/meta/src/meta-defaults.c index 0f439c3ab4b..c34055bb221 100644 --- a/xlators/meta/src/meta-defaults.c +++ b/xlators/meta/src/meta-defaults.c @@ -19,6 +19,7 @@ #include "meta-mem-types.h" #include "meta.h" +#include "compat-errno.h" int meta_default_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c index 3e29a9601bc..e4a48439812 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quota.c +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c @@ -482,7 +482,7 @@ glusterd_set_quota_limit (char *volname, char *path, char *hard_limit, ret = sys_lsetxattr (abspath, "trusted.glusterfs.quota.limit-set", (char *)(void *)&new_limit, sizeof (new_limit), 0); - if (ret) { + if (ret == -1) { gf_asprintf (op_errstr, "setxattr of " "'trusted.glusterfs.quota.limit-set' failed on %s." " Reason : %s", abspath, strerror (errno)); diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 3095414b88e..c1ddc0849cc 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -20,7 +20,7 @@ #include <sys/mount.h> #include <signal.h> -#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS) +#if defined(GF_LINUX_HOST_OS) #include <mntent.h> #else #include "mntent_compat.h" @@ -30,7 +30,7 @@ #define umount2(dir, flags) unmount(dir, ((flags) != 0) ? MNT_FORCE : 0) #endif -#ifdef GF_DARWIN_HOST_OS +#if defined(GF_DARWIN_HOST_OS) || defined(__FreeBSD__) #include <sys/param.h> #include <sys/mount.h> #define umount2(dir, flags) unmount(dir, ((flags) != 0) ? MNT_FORCE : 0) @@ -3743,7 +3743,7 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo, GF_XATTR_VOL_ID_KEY, snap_volinfo->volume_id, 16, XATTR_REPLACE); - if (ret) { + if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, "Failed to set " "extended attribute %s on %s. Reason: " "%s, snap: %s", GF_XATTR_VOL_ID_KEY, @@ -4043,8 +4043,13 @@ glusterd_update_fs_uuid (glusterd_brickinfo_t *brickinfo) * file-system which is sharing the UUID with any other * file-system on the system. */ +#ifdef GF_LINUX_HOST_OS ret = mount (brickinfo->device_path, mount_path, brickinfo->fstype, 0, "nouuid"); +#else + ret = -1; +#endif + if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to mount " "%s at %s", brickinfo->device_path, diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 0177ed169fc..e03ec7af9f5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -45,7 +45,7 @@ #include <inttypes.h> #include <dirent.h> -#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS) +#if defined(GF_LINUX_HOST_OS) #include <mntent.h> #else #include "mntent_compat.h" diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index fb677200a7e..6b973a3638d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -13,7 +13,7 @@ #endif #include <inttypes.h> -#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS) +#if defined(GF_LINUX_HOST_OS) #include <mntent.h> #else #include "mntent_compat.h" @@ -722,7 +722,7 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict, new_volinfo->volume_id, sizeof (new_volinfo->volume_id), XATTR_REPLACE); - if (ret) { + if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, "Failed to " "set extended attribute %s on %s. " "Reason: %s, snap: %s", @@ -7438,7 +7438,6 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, xlator_t *this = NULL; glusterd_conf_t *priv = NULL; - GF_ASSERT (volinfo); GF_ASSERT (brickinfo); GF_ASSERT (dict); @@ -8109,7 +8108,7 @@ glusterd_check_and_set_brick_xattr (char *host, char *path, uuid_t uuid, /* Check for xattr support in backend fs */ ret = sys_lsetxattr (path, "trusted.glusterfs.test", "working", 8, 0); - if (ret) { + if (ret == -1) { snprintf (msg, sizeof (msg), "Glusterfs is not" " supported on brick: %s:%s.\nSetting" " extended attributes failed, reason:" @@ -8135,7 +8134,7 @@ glusterd_check_and_set_brick_xattr (char *host, char *path, uuid_t uuid, ret = sys_lsetxattr (path, GF_XATTR_VOL_ID_KEY, uuid, 16, flags); - if (ret) { + if (ret == -1) { snprintf (msg, sizeof (msg), "Failed to set extended " "attributes %s, reason: %s", GF_XATTR_VOL_ID_KEY, strerror (errno)); diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index aa9805092fa..53beebe0555 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -1055,7 +1055,7 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, GF_XATTR_VOL_ID_KEY, volinfo->volume_id, 16, XATTR_CREATE); - if (ret) { + if (ret == -1) { snprintf (msg, sizeof (msg), "Failed to set " "extended attribute %s on %s. Reason: " "%s", GF_XATTR_VOL_ID_KEY, diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index d5ca4d146aa..473911a2cb0 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -12,6 +12,8 @@ #include "fuse-bridge.h" #include "mount-gluster-compat.h" #include "glusterfs.h" +#include "byte-order.h" +#include "compat-errno.h" #include "glusterfs-acl.h" #ifdef __NetBSD__ diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index f1c4cb3f0d8..c08d55daf4b 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -32,8 +32,6 @@ #include "statedump.h" #ifdef GF_DARWIN_HOST_OS -/* This is MacFUSE's marker for MacFUSE-specific code */ -#define __FreeBSD__ 10 #include "fuse_kernel_macfuse.h" #else #include "fuse_kernel.h" @@ -47,7 +45,7 @@ #include "syncop.h" #include "gidcache.h" -#if defined(GF_LINUX_HOST_OS) || defined(__NetBSD__) +#if defined(GF_LINUX_HOST_OS) || defined(__FreeBSD__) || defined(__NetBSD__) #define FUSE_OP_HIGH (FUSE_READDIRPLUS + 1) #endif #ifdef GF_DARWIN_HOST_OS diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c index 0936d63111a..ef9bcd4e43e 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -11,13 +11,17 @@ #define _KMEMUSER #endif -#include "fuse-bridge.h" #if defined(GF_SOLARIS_HOST_OS) #include <sys/procfs.h> +#elif defined(__FreeBSD__) +#include <sys/types.h> +#include <libutil.h> +#include <sys/user.h> #else #include <sys/sysctl.h> #endif +#include "fuse-bridge.h" static void fuse_resolve_wipe (fuse_resolve_t *resolve) @@ -154,7 +158,8 @@ frame_fill_groups (call_frame_t *frame) char *endptr = NULL; int ret = 0; - ret = snprintf (filename, sizeof filename, "/proc/%d/status", frame->root->pid); + ret = snprintf (filename, sizeof filename, "/proc/%d/status", + frame->root->pid); if (ret >= sizeof filename) goto out; @@ -162,8 +167,8 @@ frame_fill_groups (call_frame_t *frame) if (!fp) goto out; - if (call_stack_alloc_groups (frame->root, FUSE_MAX_AUX_GROUPS) != 0) - goto out; + if (call_stack_alloc_groups (frame->root, FUSE_MAX_AUX_GROUPS) != 0) + goto out; while ((ptr = fgets (line, sizeof line, fp))) { if (strncmp (ptr, "Groups:", 7) != 0) @@ -197,7 +202,7 @@ out: prcred_t *prcred = (prcred_t *) scratch; FILE *fp = NULL; int ret = 0; - int ngrps; + int ngrps; ret = snprintf (filename, sizeof filename, "/proc/%d/cred", frame->root->pid); @@ -207,21 +212,21 @@ out: if (fp != NULL) { if (fgets (scratch, sizeof scratch, fp) != NULL) { ngrps = MIN(prcred->pr_ngroups, - GF_MAX_AUX_GROUPS); - if (call_stack_alloc_groups (frame->root, - ngrps) != 0) - return; + FUSE_MAX_AUX_GROUPS); + if (call_stack_alloc_groups (frame->root, + ngrps) != 0) + return; } fclose (fp); } } #elif defined(CTL_KERN) /* DARWIN and *BSD */ - /* + /* N.B. CTL_KERN is an enum on Linux. (Meaning, if it's not - obvious, that it's not subject to preprocessor directives + obvious, that it's not subject to preprocessor directives like '#if defined'.) Unlike Linux, on Mac OS and the BSDs it is a #define. We - could test to see that KERN_PROC is defined, but, barring any + could test to see that KERN_PROC is defined, but, barring any evidence to the contrary, I think that's overkill. We might also test that GF_DARWIN_HOST_OS is defined, why limit this to just Mac OS. It's equally valid for the BSDs @@ -236,8 +241,8 @@ out: if (sysctl(name, namelen, &kp, &kplen, NULL, 0) != 0) return; ngroups = MIN(kp.kp_eproc.e_ucred.cr_ngroups, NGROUPS_MAX); - if (call_stack_alloc_groups (frame->root, ngroups) != 0) - return; + if (call_stack_alloc_groups (frame->root, ngroups) != 0) + return; for (i = 0; i < ngroups; i++) frame->root->groups[i] = kp.kp_eproc.e_ucred.cr_groups[i]; frame->root->ngrps = ngroups; diff --git a/xlators/mount/fuse/utils/Makefile.am b/xlators/mount/fuse/utils/Makefile.am index c626e2769fe..fdad27ad103 100644 --- a/xlators/mount/fuse/utils/Makefile.am +++ b/xlators/mount/fuse/utils/Makefile.am @@ -1,10 +1,9 @@ utildir = @mountutildir@ -if GF_DARWIN_HOST_OS -util_SCRIPTS = mount_glusterfs -else +if GF_LINUX_HOST_OS util_SCRIPTS = mount.glusterfs +else +util_SCRIPTS = mount_glusterfs endif -CLEANFILES = - +CLEANFILES = diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index 5de84cdc4d5..7588463b891 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -18,6 +18,7 @@ #include "dict.h" #include "xlator.h" #include "md-cache-mem-types.h" +#include "compat-errno.h" #include "glusterfs-acl.h" #include <assert.h> #include <sys/time.h> diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c index 78aba988e31..b6cfbd081ea 100644 --- a/xlators/storage/posix/src/posix-handle.c +++ b/xlators/storage/posix/src/posix-handle.c @@ -26,6 +26,8 @@ #include "xlator.h" #include "syscall.h" +#include "compat-errno.h" + inode_t * posix_resolve (xlator_t *this, inode_table_t *itable, inode_t *parent, char *bname, struct iatt *iabuf) diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 143267637b5..c2f87c893d3 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -686,7 +686,7 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req) } ret = sys_lsetxattr (path, GFID_XATTR_KEY, uuid_req, 16, XATTR_CREATE); - if (ret != 0) { + if (ret == -1) { gf_log (this->name, GF_LOG_WARNING, "setting GFID on %s failed (%s)", path, strerror (errno)); @@ -1268,6 +1268,11 @@ posix_acl_xattr_set (xlator_t *this, const char *path, dict_t *xattr_req) if (data) { ret = sys_lsetxattr (path, POSIX_ACL_ACCESS_XATTR, data->data, data->len, 0); +#ifdef __FreeBSD__ + if (ret != -1) { + ret = 0; + } +#endif /* __FreeBSD__ */ if (ret != 0) goto out; } @@ -1276,6 +1281,11 @@ posix_acl_xattr_set (xlator_t *this, const char *path, dict_t *xattr_req) if (data) { ret = sys_lsetxattr (path, POSIX_ACL_DEFAULT_XATTR, data->data, data->len, 0); +#ifdef __FreeBSD__ + if (ret != -1) { + ret = 0; + } +#endif /* __FreeBSD__ */ if (ret != 0) goto out; } diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 35e34c4bec6..ef98939c46d 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -5344,7 +5344,7 @@ init (xlator_t *this) /* Check for Extended attribute support, if not present, log it */ op_ret = sys_lsetxattr (dir_data->data, "trusted.glusterfs.test", "working", 8, 0); - if (op_ret == 0) { + if (op_ret != -1) { sys_lremovexattr (dir_data->data, "trusted.glusterfs.test"); } else { tmp_data = dict_get (this->options, @@ -5451,7 +5451,7 @@ init (xlator_t *this) /* First time volume, set the GFID */ size = sys_lsetxattr (dir_data->data, "trusted.gfid", rootgfid, 16, XATTR_CREATE); - if (size) { + if (size == -1) { gf_log (this->name, GF_LOG_ERROR, "%s: failed to set gfid (%s)", dir_data->data, strerror (errno)); |