diff options
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/call-stub.c | 202 | ||||
-rw-r--r-- | libglusterfs/src/call-stub.h | 60 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.c | 2 | ||||
-rw-r--r-- | libglusterfs/src/defaults.c | 55 | ||||
-rw-r--r-- | libglusterfs/src/defaults.h | 12 | ||||
-rw-r--r-- | libglusterfs/src/glusterfs.h | 2 | ||||
-rw-r--r-- | libglusterfs/src/protocol.h | 21 | ||||
-rw-r--r-- | libglusterfs/src/xlator.c | 4 | ||||
-rw-r--r-- | libglusterfs/src/xlator.h | 42 |
9 files changed, 398 insertions, 2 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 701ee8872a0..89a212807d0 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -2322,6 +2322,131 @@ fop_lock_fnotify_stub (call_frame_t *frame, fop_lock_fnotify_t fn, return stub; } +call_stub_t * +fop_setattr_cbk_stub (call_frame_t *frame, + fop_setattr_cbk_t fn, + int32_t op_ret, + int32_t op_errno, + struct stat *statpre, + struct stat *statpost) +{ + call_stub_t *stub = NULL; + + if (frame == NULL) + goto out; + + stub = stub_new (frame, 1, GF_FOP_SETATTR); + if (stub == NULL) + goto out; + + stub->args.setattr_cbk.fn = fn; + + stub->args.setattr_cbk.op_ret = op_ret; + stub->args.setattr_cbk.op_errno = op_errno; + + if (statpre) + stub->args.setattr_cbk.statpre = *statpre; + if (statpost) + stub->args.setattr_cbk.statpost = *statpost; + +out: + return stub; +} + +call_stub_t * +fop_fsetattr_cbk_stub (call_frame_t *frame, + fop_setattr_cbk_t fn, + int32_t op_ret, + int32_t op_errno, + struct stat *statpre, + struct stat *statpost) +{ + call_stub_t *stub = NULL; + + if (frame == NULL) + goto out; + + stub = stub_new (frame, 1, GF_FOP_FSETATTR); + if (stub == NULL) + goto out; + + stub->args.fsetattr_cbk.fn = fn; + + stub->args.fsetattr_cbk.op_ret = op_ret; + stub->args.fsetattr_cbk.op_errno = op_errno; + + if (statpre) + stub->args.setattr_cbk.statpre = *statpre; + if (statpost) + stub->args.fsetattr_cbk.statpost = *statpost; +out: + return stub; +} + +call_stub_t * +fop_setattr_stub (call_frame_t *frame, + fop_setattr_t fn, + loc_t *loc, + struct stat *stbuf, + int32_t valid) +{ + call_stub_t *stub = NULL; + + if (frame == NULL) + goto out; + + if (fn == NULL) + goto out; + + stub = stub_new (frame, 1, GF_FOP_SETATTR); + if (stub == NULL) + goto out; + + stub->args.setattr.fn = fn; + + loc_copy (&stub->args.setattr.loc, loc); + + if (stbuf) + stub->args.setattr.stbuf = *stbuf; + + stub->args.setattr.valid = valid; + +out: + return stub; +} + +call_stub_t * +fop_fsetattr_stub (call_frame_t *frame, + fop_fsetattr_t fn, + fd_t *fd, + struct stat *stbuf, + int32_t valid) +{ + call_stub_t *stub = NULL; + + if (frame == NULL) + goto out; + + if (fn == NULL) + goto out; + + stub = stub_new (frame, 1, GF_FOP_FSETATTR); + if (stub == NULL) + goto out; + + stub->args.fsetattr.fn = fn; + + if (fd) + stub->args.fsetattr.fd = fd_ref (fd); + + if (stbuf) + stub->args.fsetattr.stbuf = *stbuf; + + stub->args.fsetattr.valid = valid; + +out: + return stub; +} static void call_resume_wind (call_stub_t *stub) @@ -2770,6 +2895,24 @@ call_resume_wind (call_stub_t *stub) stub->args.lock_fnotify.timeout); break; } + case GF_FOP_SETATTR: + { + stub->args.setattr.fn (stub->frame, + stub->frame->this, + &stub->args.setattr.loc, + &stub->args.setattr.stbuf, + stub->args.setattr.valid); + break; + } + case GF_FOP_FSETATTR: + { + stub->args.fsetattr.fn (stub->frame, + stub->frame->this, + stub->args.fsetattr.fd, + &stub->args.fsetattr.stbuf, + stub->args.fsetattr.valid); + break; + } default: { gf_log ("call-stub", @@ -3632,6 +3775,44 @@ call_resume_unwind (call_stub_t *stub) stub->args.lock_fnotify_cbk.op_errno); break; } + case GF_FOP_SETATTR: + { + if (!stub->args.setattr_cbk.fn) + STACK_UNWIND (stub->frame, + stub->args.setattr_cbk.op_ret, + stub->args.setattr_cbk.op_errno, + &stub->args.setattr_cbk.statpre, + &stub->args.setattr_cbk.statpost); + else + stub->args.setattr_cbk.fn ( + stub->frame, + stub->frame->cookie, + stub->frame->this, + stub->args.setattr_cbk.op_ret, + stub->args.setattr_cbk.op_errno, + &stub->args.setattr_cbk.statpre, + &stub->args.setattr_cbk.statpost); + break; + } + case GF_FOP_FSETATTR: + { + if (!stub->args.fsetattr_cbk.fn) + STACK_UNWIND (stub->frame, + stub->args.fsetattr_cbk.op_ret, + stub->args.fsetattr_cbk.op_errno, + &stub->args.fsetattr_cbk.statpre, + &stub->args.fsetattr_cbk.statpost); + else + stub->args.fsetattr_cbk.fn ( + stub->frame, + stub->frame->cookie, + stub->frame->this, + stub->args.fsetattr_cbk.op_ret, + stub->args.fsetattr_cbk.op_errno, + &stub->args.fsetattr_cbk.statpre, + &stub->args.fsetattr_cbk.statpost); + break; + } case GF_FOP_MAXVALUE: { gf_log ("call-stub", @@ -3986,6 +4167,17 @@ call_stub_destroy_wind (call_stub_t *stub) fd_unref (stub->args.lock_fnotify.fd); break; } + case GF_FOP_SETATTR: + { + loc_wipe (&stub->args.setattr.loc); + break; + } + case GF_FOP_FSETATTR: + { + if (stub->args.fsetattr.fd) + fd_unref (stub->args.fsetattr.fd); + break; + } case GF_FOP_MAXVALUE: { gf_log ("call-stub", @@ -4234,6 +4426,16 @@ call_stub_destroy_unwind (call_stub_t *stub) dict_unref (stub->args.fxattrop_cbk.xattr); } break; + + case GF_FOP_SETATTR: + { + break; + } + + case GF_FOP_FSETATTR: + { + break; + } case GF_FOP_MAXVALUE: { diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h index 07bc92c3107..63439478cc4 100644 --- a/libglusterfs/src/call-stub.h +++ b/libglusterfs/src/call-stub.h @@ -631,6 +631,36 @@ typedef struct { int32_t op_ret; int32_t op_errno; } lock_fnotify_cbk; + + /* setattr */ + struct { + fop_setattr_t fn; + loc_t loc; + struct stat stbuf; + int32_t valid; + } setattr; + struct { + fop_setattr_cbk_t fn; + int32_t op_ret; + int32_t op_errno; + struct stat statpre; + struct stat statpost; + } setattr_cbk; + + /* fsetattr */ + struct { + fop_fsetattr_t fn; + fd_t *fd; + struct stat stbuf; + int32_t valid; + } fsetattr; + struct { + fop_fsetattr_cbk_t fn; + int32_t op_ret; + int32_t op_errno; + struct stat statpre; + struct stat statpost; + } fsetattr_cbk; } args; } call_stub_t; @@ -1232,6 +1262,36 @@ fop_lock_fnotify_stub (call_frame_t *frame, fd_t *fd, int32_t timeout); +call_stub_t * +fop_setattr_stub (call_frame_t *frame, + fop_setattr_t fn, + loc_t *loc, + struct stat *stbuf, + int32_t valid); + +call_stub_t * +fop_setattr_cbk_stub (call_frame_t *frame, + fop_setattr_cbk_t fn, + int32_t op_ret, + int32_t op_errno, + struct stat *statpre, + struct stat *statpost); + +call_stub_t * +fop_fsetattr_stub (call_frame_t *frame, + fop_fsetattr_t fn, + fd_t *fd, + struct stat *stbuf, + int32_t valid); + +call_stub_t * +fop_fsetattr_cbk_stub (call_frame_t *frame, + fop_setattr_cbk_t fn, + int32_t op_ret, + int32_t op_errno, + struct stat *statpre, + struct stat *statpost); + void call_resume (call_stub_t *stub); void call_stub_destroy (call_stub_t *stub); #endif diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 2f0dec9b4f0..49ea724b2e2 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -217,6 +217,8 @@ gf_global_variable_init() gf_fop_list[GF_FOP_FSETXATTR] = "FSETXATTR"; gf_fop_list[GF_FOP_FGETXATTR] = "FGETXATTR"; gf_fop_list[GF_FOP_RCHECKSUM] = "RCHECKSUM"; + gf_fop_list[GF_FOP_SETATTR] = "SETATTR"; + gf_fop_list[GF_FOP_FSETATTR] = "FSETATTR"; gf_mop_list[GF_MOP_SETVOLUME] = "SETVOLUME"; /* 0 */ gf_mop_list[GF_MOP_GETVOLUME] = "GETVOLUME"; /* 1 */ diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c index e48fd315165..f72eca1f819 100644 --- a/libglusterfs/src/defaults.c +++ b/libglusterfs/src/defaults.c @@ -1557,3 +1557,58 @@ default_release (xlator_t *this, return 0; } +int32_t +default_setattr_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *statpre, + struct stat *statpost) +{ + STACK_UNWIND (frame, op_ret, op_errno, statpre, statpost); + return 0; +} + +int32_t +default_setattr (call_frame_t *frame, + xlator_t *this, + loc_t *loc, + struct stat *stbuf, + int32_t valid) +{ + STACK_WIND (frame, + default_setattr_cbk, + FIRST_CHILD (this), + FIRST_CHILD (this)->fops->setattr, + loc, stbuf, valid); + return 0; +} + +int32_t +default_fsetattr_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *statpre, + struct stat *statpost) +{ + STACK_UNWIND (frame, op_ret, op_errno, statpre, statpost); + return 0; +} + +int32_t +default_fsetattr (call_frame_t *frame, + xlator_t *this, + fd_t *fd, + struct stat *stbuf, + int32_t valid) +{ + STACK_WIND (frame, + default_fsetattr_cbk, + FIRST_CHILD (this), + FIRST_CHILD (this)->fops->fsetattr, + fd, stbuf, valid); + return 0; +} diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h index 7b3b2cf5804..d8b99848683 100644 --- a/libglusterfs/src/defaults.h +++ b/libglusterfs/src/defaults.h @@ -302,4 +302,16 @@ int32_t default_release (xlator_t *this, int32_t default_releasedir (xlator_t *this, fd_t *fd); +int32_t default_setattr (call_frame_t *frame, + xlator_t *this, + loc_t *loc, + struct stat *stbuf, + int32_t valid); + +int32_t default_fsetattr (call_frame_t *frame, + xlator_t *this, + fd_t *fd, + struct stat *stbuf, + int32_t valid); + #endif /* _DEFAULTS_H */ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index df21d40a5c2..d1d30a492f1 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -124,6 +124,8 @@ typedef enum { GF_FOP_FGETXATTR, GF_FOP_FSETXATTR, /* 45 */ GF_FOP_RCHECKSUM, + GF_FOP_SETATTR, + GF_FOP_FSETATTR, GF_FOP_MAXVALUE, } glusterfs_fop_t; diff --git a/libglusterfs/src/protocol.h b/libglusterfs/src/protocol.h index c0fee420e99..91b876a6ff3 100644 --- a/libglusterfs/src/protocol.h +++ b/libglusterfs/src/protocol.h @@ -771,7 +771,6 @@ typedef struct { } __attribute__((packed)) gf_fop_setdents_req_t; typedef struct { } __attribute__((packed)) gf_fop_setdents_rsp_t; - typedef struct { uint64_t ino; int64_t fd; @@ -795,6 +794,26 @@ typedef struct { unsigned char dchecksum[0]; } __attribute__((packed)) gf_fop_checksum_rsp_t; +typedef struct { + uint64_t ino; + struct gf_stat stbuf; + int32_t valid; + char path[0]; +} __attribute__((packed)) gf_fop_setattr_req_t; +typedef struct { + struct gf_stat statpre; + struct gf_stat statpost; +} __attribute__((packed)) gf_fop_setattr_rsp_t; + +typedef struct { + int64_t fd; + struct gf_stat stbuf; + int32_t valid; +} __attribute__((packed)) gf_fop_fsetattr_req_t; +typedef struct { + struct gf_stat statpre; + struct gf_stat statpost; +} __attribute__((packed)) gf_fop_fsetattr_rsp_t; typedef struct { int64_t fd; diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 5d677ac188e..90c9d5cdcb6 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -102,7 +102,9 @@ fill_defaults (xlator_t *xl) SET_DEFAULT_FOP (fxattrop); SET_DEFAULT_FOP (lock_notify); SET_DEFAULT_FOP (lock_fnotify); - + SET_DEFAULT_FOP (setattr); + SET_DEFAULT_FOP (fsetattr); + SET_DEFAULT_MOP (log); SET_DEFAULT_MOP (stats); diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index ff6768035fd..afaaed4a4d8 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -37,8 +37,17 @@ #include "compat.h" #include "list.h" +#include <fuse/fuse_lowlevel.h> + #define FIRST_CHILD(xl) (xl->children->xlator) +#define GF_SET_ATTR_MODE 0x1 +#define GF_SET_ATTR_UID 0x2 +#define GF_SET_ATTR_GID 0x4 +#define GF_SET_ATTR_SIZE 0x8 +#define GF_SET_ATTR_ATIME 0x10 +#define GF_SET_ATTR_MTIME 0x20 + struct _xlator; typedef struct _xlator xlator_t; struct _dir_entry_t; @@ -467,6 +476,22 @@ typedef int32_t (*fop_lock_fnotify_cbk_t) (call_frame_t *frame, int32_t op_ret, int32_t op_errno); +typedef int32_t (*fop_setattr_cbk_t) (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *preop_stbuf, + struct stat *postop_stbuf); + +typedef int32_t (*fop_fsetattr_cbk_t) (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *preop_stbuf, + struct stat *postop_stbuf); + typedef int32_t (*fop_lookup_t) (call_frame_t *frame, xlator_t *this, loc_t *loc, @@ -710,6 +735,19 @@ typedef int32_t (*fop_lock_fnotify_t) (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t timeout); +typedef int32_t (*fop_setattr_t) (call_frame_t *frame, + xlator_t *this, + loc_t *loc, + struct stat *stbuf, + int32_t valid); + +typedef int32_t (*fop_fsetattr_t) (call_frame_t *frame, + xlator_t *this, + fd_t *fd, + struct stat *stbuf, + int32_t valid); + + struct xlator_fops { fop_lookup_t lookup; fop_stat_t stat; @@ -758,6 +796,8 @@ struct xlator_fops { fop_fxattrop_t fxattrop; fop_lock_notify_t lock_notify; fop_lock_fnotify_t lock_fnotify; + fop_setattr_t setattr; + fop_fsetattr_t fsetattr; /* these entries are used for a typechecking hack in STACK_WIND _only_ */ fop_lookup_cbk_t lookup_cbk; @@ -807,6 +847,8 @@ struct xlator_fops { fop_fxattrop_cbk_t fxattrop_cbk; fop_lock_notify_cbk_t lock_notify_cbk; fop_lock_fnotify_cbk_t lock_fnotify_cbk; + fop_setattr_cbk_t setattr_cbk; + fop_fsetattr_cbk_t fsetattr_cbk; }; typedef int32_t (*cbk_forget_t) (xlator_t *this, |