gfid-access: virtual access to filesystem through gfid path
BUG: 952029 Change-Id: I7405d473d369a4a951836eceda4faccbad19ce0e Signed-off-by: Amar Tumballi <amarts@redhat.com> Reviewed-on: http://review.gluster.org/5497 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
This commit is contained in:
parent
df9bfff8ea
commit
9cef281090
@ -119,6 +119,8 @@ AC_CONFIG_FILES([Makefile
|
||||
xlators/features/index/src/Makefile
|
||||
xlators/features/protect/Makefile
|
||||
xlators/features/protect/src/Makefile
|
||||
xlators/features/gfid-access/Makefile
|
||||
xlators/features/gfid-access/src/Makefile
|
||||
xlators/playground/Makefile
|
||||
xlators/playground/template/Makefile
|
||||
xlators/playground/template/src/Makefile
|
||||
|
@ -1,4 +1,4 @@
|
||||
SUBDIRS = locks quota read-only mac-compat quiesce marker index \
|
||||
protect changelog $(GLUPY_SUBDIR) # trash path-converter # filter
|
||||
protect changelog gfid-access $(GLUPY_SUBDIR) # trash path-converter # filter
|
||||
|
||||
CLEANFILES =
|
||||
|
1
xlators/features/gfid-access/Makefile.am
Normal file
1
xlators/features/gfid-access/Makefile.am
Normal file
@ -0,0 +1 @@
|
||||
SUBDIRS = src
|
15
xlators/features/gfid-access/src/Makefile.am
Normal file
15
xlators/features/gfid-access/src/Makefile.am
Normal file
@ -0,0 +1,15 @@
|
||||
xlator_LTLIBRARIES = gfid-access.la
|
||||
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features
|
||||
|
||||
gfid_access_la_LDFLAGS = -module -avoid-version
|
||||
|
||||
gfid_access_la_SOURCES = gfid-access.c
|
||||
gfid_access_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
|
||||
|
||||
noinst_HEADERS = gfid-access.h gfid-access-mem-types.h
|
||||
|
||||
AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src
|
||||
|
||||
AM_CFLAGS = -Wall $(GF_CFLAGS)
|
||||
|
||||
CLEANFILES =
|
23
xlators/features/gfid-access/src/gfid-access-mem-types.h
Normal file
23
xlators/features/gfid-access/src/gfid-access-mem-types.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright (c) 2013 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
|
||||
General Public License, version 3 or any later version (LGPLv3 or
|
||||
later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
cases as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef _GFID_ACCESS_MEM_TYPES_H
|
||||
#define _GFID_ACCESS_MEM_TYPES_H
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_changelog_mem_types {
|
||||
gf_gfid_access_mt_priv_t = gf_common_mt_end + 1,
|
||||
gf_gfid_access_mt_gfid_t,
|
||||
gf_gfid_access_mt_end
|
||||
};
|
||||
|
||||
#endif
|
||||
|
1145
xlators/features/gfid-access/src/gfid-access.c
Normal file
1145
xlators/features/gfid-access/src/gfid-access.c
Normal file
File diff suppressed because it is too large
Load Diff
128
xlators/features/gfid-access/src/gfid-access.h
Normal file
128
xlators/features/gfid-access/src/gfid-access.h
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
Copyright (c) 2013 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
|
||||
General Public License, version 3 or any later version (LGPLv3 or
|
||||
later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
cases as published by the Free Software Foundation.
|
||||
*/
|
||||
#ifndef __GFID_ACCESS_H__
|
||||
#define __GFID_ACCESS_H__
|
||||
|
||||
#ifndef _CONFIG_H
|
||||
#define _CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "glusterfs.h"
|
||||
#include "logging.h"
|
||||
#include "dict.h"
|
||||
#include "xlator.h"
|
||||
#include "defaults.h"
|
||||
#include "gfid-access-mem-types.h"
|
||||
|
||||
#define UUID_CANONICAL_FORM_LEN 36
|
||||
|
||||
#define GF_FUSE_AUX_GFID_NEWFILE "glusterfs.gfid.newfile"
|
||||
#define GF_FUSE_AUX_GFID_HEAL "glusterfs.gfid.heal"
|
||||
|
||||
#define GF_GFID_KEY "GLUSTERFS_GFID"
|
||||
#define GF_GFID_DIR ".gfid"
|
||||
#define GF_AUX_GFID 0xd
|
||||
|
||||
#define GFID_ACCESS_GET_VALID_DIR_INODE(x,l,unref,lbl) do { \
|
||||
int ret = 0; \
|
||||
uint64_t value = 0; \
|
||||
inode_t *tmp_inode = NULL; \
|
||||
\
|
||||
/* if its an entry operation, on the virtual */ \
|
||||
/* directory inode as parent, we need to handle */ \
|
||||
/* it properly */ \
|
||||
if (l->parent) { \
|
||||
ret = inode_ctx_get (l->parent, x, &value); \
|
||||
if (ret) \
|
||||
goto lbl; \
|
||||
tmp_inode = (inode_t *)value; \
|
||||
unref = inode_ref (tmp_inode); \
|
||||
l->parent = tmp_inode; \
|
||||
/* if parent is virtual, no need to handle */ \
|
||||
/* loc->inode */ \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
/* if its an inode operation, on the virtual */ \
|
||||
/* directory inode itself, we need to handle */ \
|
||||
/* it properly */ \
|
||||
if (l->inode) { \
|
||||
ret = inode_ctx_get (l->inode, x, &value); \
|
||||
if (ret) \
|
||||
goto lbl; \
|
||||
tmp_inode = (inode_t *)value; \
|
||||
unref = inode_ref (tmp_inode); \
|
||||
l->inode = tmp_inode; \
|
||||
} \
|
||||
\
|
||||
} while (0)
|
||||
|
||||
#define GFID_ACCESS_ENTRY_OP_CHECK(loc,err,lbl) do { \
|
||||
/* need to check if the lookup is on virtual dir */ \
|
||||
if ((loc->name && !strcmp (GF_GFID_DIR, loc->name)) && \
|
||||
((loc->parent && \
|
||||
__is_root_gfid (loc->parent->gfid)) || \
|
||||
__is_root_gfid (loc->pargfid))) { \
|
||||
err = EEXIST; \
|
||||
goto lbl; \
|
||||
} \
|
||||
\
|
||||
/* now, check if the lookup() is on an existing */ \
|
||||
/* entry, but on gfid-path */ \
|
||||
if ((loc->parent && \
|
||||
__is_gfid_access_dir (loc->parent->gfid)) || \
|
||||
__is_gfid_access_dir (loc->pargfid)) { \
|
||||
err = EPERM; \
|
||||
goto lbl; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
typedef struct {
|
||||
unsigned int uid;
|
||||
unsigned int gid;
|
||||
char gfid[UUID_CANONICAL_FORM_LEN + 1];
|
||||
unsigned int st_mode;
|
||||
char *bname;
|
||||
|
||||
union {
|
||||
struct _symlink_in {
|
||||
char *linkpath;
|
||||
} __attribute__ ((__packed__)) symlink;
|
||||
|
||||
struct _mknod_in {
|
||||
unsigned int mode;
|
||||
unsigned int rdev;
|
||||
unsigned int umask;
|
||||
} __attribute__ ((__packed__)) mknod;
|
||||
|
||||
struct _mkdir_in {
|
||||
unsigned int mode;
|
||||
unsigned int umask;
|
||||
} __attribute__ ((__packed__)) mkdir;
|
||||
} __attribute__ ((__packed__)) args;
|
||||
} __attribute__((__packed__)) ga_newfile_args_t;
|
||||
|
||||
typedef struct {
|
||||
char gfid[UUID_CANONICAL_FORM_LEN + 1];
|
||||
char *bname; /* a null terminated basename */
|
||||
} __attribute__((__packed__)) ga_heal_args_t;
|
||||
|
||||
struct ga_private {
|
||||
/* root inode's stbuf */
|
||||
struct iatt root_stbuf;
|
||||
struct iatt gfiddir_stbuf;
|
||||
struct mem_pool *newfile_args_pool;
|
||||
struct mem_pool *heal_args_pool;
|
||||
};
|
||||
typedef struct ga_private ga_private_t;
|
||||
|
||||
#endif /* __GFID_ACCESS_H__ */
|
Loading…
x
Reference in New Issue
Block a user