summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2012-01-17 05:57:24 +0530
committerAnand Avati <avati@gluster.com>2012-01-25 02:24:20 -0800
commitd7ecaaa1ed0f88869812ea17cb64a102a74c8c1c (patch)
tree4293106362bf9dec2e6260a4062239a9b7340cc0 /libglusterfs
parent6c54022f1b1c7f5f458f6a7e783203d11e7f89b5 (diff)
core: add 'fremovexattr()' fop
so operations can be done on fd for extended attribute removal Change-Id: Ie026f1b53793aeb4ae33e96ea5408c7a97f34bf6 Signed-off-by: Amar Tumballi <amar@gluster.com> BUG: 766571 Reviewed-on: http://review.gluster.com/778 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/call-stub.c76
-rw-r--r--libglusterfs/src/call-stub.h26
-rw-r--r--libglusterfs/src/defaults.c27
-rw-r--r--libglusterfs/src/defaults.h14
-rw-r--r--libglusterfs/src/glusterfs.h1
-rw-r--r--libglusterfs/src/syncop.c28
-rw-r--r--libglusterfs/src/syncop.h1
-rw-r--r--libglusterfs/src/syscall.c26
-rw-r--r--libglusterfs/src/syscall.h3
-rw-r--r--libglusterfs/src/xlator.c1
-rw-r--r--libglusterfs/src/xlator.h13
11 files changed, 216 insertions, 0 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c
index 8b28dc9..24ca382 100644
--- a/libglusterfs/src/call-stub.c
+++ b/libglusterfs/src/call-stub.c
@@ -1463,6 +1463,48 @@ out:
return stub;
}
+call_stub_t *
+fop_fremovexattr_stub (call_frame_t *frame,
+ fop_fremovexattr_t fn,
+ fd_t *fd,
+ const char *name)
+{
+ call_stub_t *stub = NULL;
+
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", fd, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", name, out);
+
+ stub = stub_new (frame, 1, GF_FOP_FREMOVEXATTR);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
+ stub->args.fremovexattr.fn = fn;
+ stub->args.fremovexattr.fd = fd_ref (fd);
+ stub->args.fremovexattr.name = gf_strdup (name);
+out:
+ return stub;
+}
+
+
+call_stub_t *
+fop_fremovexattr_cbk_stub (call_frame_t *frame,
+ fop_fremovexattr_cbk_t fn,
+ int32_t op_ret,
+ int32_t op_errno)
+{
+ call_stub_t *stub = NULL;
+
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+
+ stub = stub_new (frame, 0, GF_FOP_FREMOVEXATTR);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
+ stub->args.fremovexattr_cbk.fn = fn;
+ stub->args.fremovexattr_cbk.op_ret = op_ret;
+ stub->args.fremovexattr_cbk.op_errno = op_errno;
+out:
+ return stub;
+}
call_stub_t *
fop_lk_stub (call_frame_t *frame,
@@ -2303,6 +2345,15 @@ call_resume_wind (call_stub_t *stub)
break;
}
+ case GF_FOP_FREMOVEXATTR:
+ {
+ stub->args.fremovexattr.fn (stub->frame,
+ stub->frame->this,
+ stub->args.fremovexattr.fd,
+ stub->args.fremovexattr.name);
+ break;
+ }
+
case GF_FOP_OPENDIR:
{
stub->args.opendir.fn (stub->frame,
@@ -2939,6 +2990,22 @@ call_resume_unwind (call_stub_t *stub)
break;
}
+ case GF_FOP_FREMOVEXATTR:
+ {
+ if (!stub->args.fremovexattr_cbk.fn)
+ STACK_UNWIND (stub->frame,
+ stub->args.fremovexattr_cbk.op_ret,
+ stub->args.fremovexattr_cbk.op_errno);
+ else
+ stub->args.fremovexattr_cbk.fn (stub->frame,
+ stub->frame->cookie,
+ stub->frame->this,
+ stub->args.fremovexattr_cbk.op_ret,
+ stub->args.fremovexattr_cbk.op_errno);
+
+ break;
+ }
+
case GF_FOP_OPENDIR:
{
if (!stub->args.opendir_cbk.fn)
@@ -3454,6 +3521,13 @@ call_stub_destroy_wind (call_stub_t *stub)
break;
}
+ case GF_FOP_FREMOVEXATTR:
+ {
+ fd_unref (stub->args.fremovexattr.fd);
+ GF_FREE ((char *)stub->args.fremovexattr.name);
+ break;
+ }
+
case GF_FOP_OPENDIR:
{
loc_wipe (&stub->args.opendir.loc);
@@ -3718,6 +3792,8 @@ call_stub_destroy_unwind (call_stub_t *stub)
case GF_FOP_REMOVEXATTR:
break;
+ case GF_FOP_FREMOVEXATTR:
+ break;
case GF_FOP_OPENDIR:
{
diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h
index 4b03dbf..5e6c0a1 100644
--- a/libglusterfs/src/call-stub.h
+++ b/libglusterfs/src/call-stub.h
@@ -412,6 +412,18 @@ typedef struct {
int32_t op_ret, op_errno;
} removexattr_cbk;
+
+ /* fremovexattr */
+ struct {
+ fop_fremovexattr_t fn;
+ fd_t *fd;
+ const char *name;
+ } fremovexattr;
+ struct {
+ fop_fremovexattr_cbk_t fn;
+ int32_t op_ret, op_errno;
+ } fremovexattr_cbk;
+
/* lk */
struct {
fop_lk_t fn;
@@ -964,6 +976,20 @@ fop_removexattr_cbk_stub (call_frame_t *frame,
fop_removexattr_cbk_t fn,
int32_t op_ret,
int32_t op_errno);
+
+
+call_stub_t *
+fop_fremovexattr_stub (call_frame_t *frame,
+ fop_fremovexattr_t fn,
+ fd_t *fd,
+ const char *name);
+
+call_stub_t *
+fop_fremovexattr_cbk_stub (call_frame_t *frame,
+ fop_fremovexattr_cbk_t fn,
+ int32_t op_ret,
+ int32_t op_errno);
+
call_stub_t *
fop_lk_stub (call_frame_t *frame,
fop_lk_t fn,
diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c
index 828f266..df208c8 100644
--- a/libglusterfs/src/defaults.c
+++ b/libglusterfs/src/defaults.c
@@ -327,6 +327,15 @@ default_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
return 0;
}
+
+int32_t
+default_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno)
+{
+ STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno);
+ return 0;
+}
+
int32_t
default_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct gf_flock *lock)
@@ -675,6 +684,15 @@ default_removexattr_resume (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
int32_t
+default_fremovexattr_resume (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ const char *name)
+{
+ STACK_WIND (frame, default_fremovexattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fremovexattr, fd, name);
+ return 0;
+}
+
+int32_t
default_lk_resume (call_frame_t *frame, xlator_t *this, fd_t *fd,
int32_t cmd, struct gf_flock *lock)
{
@@ -1043,6 +1061,15 @@ default_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
int32_t
+default_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ const char *name)
+{
+ STACK_WIND (frame, default_fremovexattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fremovexattr, fd, name);
+ return 0;
+}
+
+int32_t
default_lk (call_frame_t *frame, xlator_t *this, fd_t *fd,
int32_t cmd, struct gf_flock *lock)
{
diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h
index fe04cbf..deba155 100644
--- a/libglusterfs/src/defaults.h
+++ b/libglusterfs/src/defaults.h
@@ -176,6 +176,11 @@ int32_t default_removexattr (call_frame_t *frame,
loc_t *loc,
const char *name);
+int32_t default_fremovexattr (call_frame_t *frame,
+ xlator_t *this,
+ fd_t *fd,
+ const char *name);
+
int32_t default_lk (call_frame_t *frame,
xlator_t *this,
fd_t *fd,
@@ -390,6 +395,11 @@ int32_t default_removexattr_resume (call_frame_t *frame,
loc_t *loc,
const char *name);
+int32_t default_fremovexattr_resume (call_frame_t *frame,
+ xlator_t *this,
+ fd_t *fd,
+ const char *name);
+
int32_t default_lk_resume (call_frame_t *frame,
xlator_t *this,
fd_t *fd,
@@ -624,6 +634,10 @@ default_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno);
int32_t
+default_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno);
+
+int32_t
default_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct gf_flock *lock);
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 2f68ab7..0642973 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -166,6 +166,7 @@ typedef enum {
GF_FOP_RELEASE,
GF_FOP_RELEASEDIR,
GF_FOP_GETSPEC,
+ GF_FOP_FREMOVEXATTR,
GF_FOP_MAXVALUE,
} glusterfs_fop_t;
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index 2771bde..cb3b67c 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -475,6 +475,34 @@ syncop_removexattr (xlator_t *subvol, loc_t *loc, const char *name)
}
int
+syncop_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno)
+{
+ struct syncargs *args = NULL;
+
+ args = cookie;
+
+ args->op_ret = op_ret;
+ args->op_errno = op_errno;
+
+ __wake (args);
+
+ return 0;
+}
+
+int
+syncop_fremovexattr (xlator_t *subvol, fd_t *fd, const char *name)
+{
+ struct syncargs args = {0, };
+
+ SYNCOP (subvol, (&args), syncop_fremovexattr_cbk,
+ subvol->fops->fremovexattr, fd, name);
+
+ errno = args.op_errno;
+ return args.op_ret;
+}
+
+int
syncop_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno)
{
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index b4cdafd..5756742 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -186,6 +186,7 @@ int syncop_listxattr (xlator_t *subvol, loc_t *loc, dict_t **dict);
int syncop_getxattr (xlator_t *xl, loc_t *loc, dict_t **dict, const char *key);
int syncop_fgetxattr (xlator_t *xl, fd_t *fd, dict_t **dict, const char *key);
int syncop_removexattr (xlator_t *subvol, loc_t *loc, const char *name);
+int syncop_fremovexattr (xlator_t *subvol, fd_t *fd, const char *name);
int syncop_create (xlator_t *subvol, loc_t *loc, int32_t flags, mode_t mode,
fd_t *fd, dict_t *dict);
diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c
index 5819218..8e2d56b 100644
--- a/libglusterfs/src/syscall.c
+++ b/libglusterfs/src/syscall.c
@@ -361,6 +361,32 @@ sys_fgetxattr (int filedes, const char *name, void *value, size_t size)
int
+sys_fremovexattr (int filedes, const char *name)
+{
+
+#if defined(GF_LINUX_HOST_OS) || defined(__NetBSD__)
+ return fremovexattr (filedes, name);
+#endif
+
+ errno = ENOSYS;
+ return -1;
+#if 0 /* TODO: to port to other OSes, fill in each of below */
+#ifdef GF_BSD_HOST_OS
+ return extattr_remove_fd (filedes, EXTATTR_NAMESPACE_USER, name);
+#endif
+
+#ifdef GF_SOLARIS_HOST_OS
+ return solaris_fremovexattr (filedes, name);
+#endif
+
+#ifdef GF_DARWIN_HOST_OS
+ return fremovexattr (filedes, name, 0);
+#endif
+#endif
+}
+
+
+int
sys_fsetxattr (int filedes, const char *name, const void *value,
size_t size, int flags)
{
diff --git a/libglusterfs/src/syscall.h b/libglusterfs/src/syscall.h
index b8a1c28..f5325b4 100644
--- a/libglusterfs/src/syscall.h
+++ b/libglusterfs/src/syscall.h
@@ -140,6 +140,9 @@ int
sys_lremovexattr (const char *path, const char *name);
int
+sys_fremovexattr (int filedes, const char *name);
+
+int
sys_access (const char *pathname, int mode);
int
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 160ac2d..4283576 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -69,6 +69,7 @@ fill_defaults (xlator_t *xl)
SET_DEFAULT_FOP (fsetxattr);
SET_DEFAULT_FOP (fgetxattr);
SET_DEFAULT_FOP (removexattr);
+ SET_DEFAULT_FOP (fremovexattr);
SET_DEFAULT_FOP (opendir);
SET_DEFAULT_FOP (readdir);
SET_DEFAULT_FOP (readdirp);
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index fab3b44..bc3d7a6 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -343,6 +343,12 @@ typedef int32_t (*fop_removexattr_cbk_t) (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno);
+typedef int32_t (*fop_fremovexattr_cbk_t) (call_frame_t *frame,
+ void *cookie,
+ xlator_t *this,
+ int32_t op_ret,
+ int32_t op_errno);
+
typedef int32_t (*fop_lk_cbk_t) (call_frame_t *frame,
void *cookie,
xlator_t *this,
@@ -564,6 +570,11 @@ typedef int32_t (*fop_removexattr_t) (call_frame_t *frame,
loc_t *loc,
const char *name);
+typedef int32_t (*fop_fremovexattr_t) (call_frame_t *frame,
+ xlator_t *this,
+ fd_t *fd,
+ const char *name);
+
typedef int32_t (*fop_lk_t) (call_frame_t *frame,
xlator_t *this,
fd_t *fd,
@@ -665,6 +676,7 @@ struct xlator_fops {
fop_fsetxattr_t fsetxattr;
fop_fgetxattr_t fgetxattr;
fop_removexattr_t removexattr;
+ fop_fremovexattr_t fremovexattr;
fop_lk_t lk;
fop_inodelk_t inodelk;
fop_finodelk_t finodelk;
@@ -708,6 +720,7 @@ struct xlator_fops {
fop_fsetxattr_cbk_t fsetxattr_cbk;
fop_fgetxattr_cbk_t fgetxattr_cbk;
fop_removexattr_cbk_t removexattr_cbk;
+ fop_fremovexattr_cbk_t fremovexattr_cbk;
fop_lk_cbk_t lk_cbk;
fop_inodelk_cbk_t inodelk_cbk;
fop_finodelk_cbk_t finodelk_cbk;