diff options
Diffstat (limited to 'libglusterfs/src')
| -rw-r--r-- | libglusterfs/src/call-stub.c | 57 | ||||
| -rw-r--r-- | libglusterfs/src/call-stub.h | 12 | ||||
| -rw-r--r-- | libglusterfs/src/common-utils.c | 1 | ||||
| -rw-r--r-- | libglusterfs/src/default-args.c | 13 | ||||
| -rw-r--r-- | libglusterfs/src/default-args.h | 4 | ||||
| -rw-r--r-- | libglusterfs/src/defaults-tmpl.c | 1 | ||||
| -rw-r--r-- | libglusterfs/src/defaults.h | 14 | ||||
| -rw-r--r-- | libglusterfs/src/generator.py | 9 | ||||
| -rw-r--r-- | libglusterfs/src/globals.c | 1 | ||||
| -rw-r--r-- | libglusterfs/src/glusterfs.h | 6 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.c | 1 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.h | 11 | 
12 files changed, 130 insertions, 0 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 610277820d6..e48e6c3651c 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -2042,6 +2042,54 @@ out:  } +call_stub_t * +fop_seek_cbk_stub (call_frame_t *frame, fop_seek_cbk_t fn, +                   int32_t op_ret, int32_t op_errno, off_t offset, +                   dict_t *xdata) +{ +        call_stub_t *stub = NULL; + +        GF_VALIDATE_OR_GOTO ("call-stub", frame, out); + +        stub = stub_new (frame, 0, GF_FOP_SEEK); +        GF_VALIDATE_OR_GOTO ("call-stub", stub, out); + +        stub->fn_cbk.seek = fn; + +        args_seek_cbk_store (&stub->args_cbk, op_ret, op_errno, offset, xdata); +out: +        return stub; +} + + +call_stub_t * +fop_seek_stub (call_frame_t *frame, fop_seek_t fn, fd_t *fd, +               off_t offset, gf_seek_what_t what, dict_t *xdata) +{ +        call_stub_t *stub = NULL; + +        GF_VALIDATE_OR_GOTO ("call-stub", frame, out); +        GF_VALIDATE_OR_GOTO ("call-stub", fn, out); + +        stub = stub_new (frame, 1, GF_FOP_SEEK); +        GF_VALIDATE_OR_GOTO ("call-stub", stub, out); + +        stub->fn.seek = fn; + +        if (fd) +                stub->args.fd = fd_ref (fd); + +        stub->args.offset = offset; +        stub->args.what = what; + +        if (xdata) +                stub->args.xdata = dict_ref (xdata); +out: +        return stub; + +} + +  void  call_resume_wind (call_stub_t *stub)  { @@ -2278,6 +2326,11 @@ call_resume_wind (call_stub_t *stub)                  stub->fn.ipc (stub->frame, stub->frame->this,                                stub->args.cmd, stub->args.xdata);                  break; +        case GF_FOP_SEEK: +                stub->fn.seek (stub->frame, stub->frame->this, +                               stub->args.fd, stub->args.offset, +                               stub->args.what, stub->args.xdata); +                break;          default:                  gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL, @@ -2488,6 +2541,10 @@ call_resume_unwind (call_stub_t *stub)          case GF_FOP_IPC:                  STUB_UNWIND (stub, ipc, stub->args_cbk.xdata);                  break; +        case GF_FOP_SEEK: +                STUB_UNWIND (stub, seek, stub->args_cbk.offset, +                             stub->args_cbk.xdata); +                break;          default:                  gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL, diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h index 547fc87e5ba..f34073977e4 100644 --- a/libglusterfs/src/call-stub.h +++ b/libglusterfs/src/call-stub.h @@ -70,6 +70,7 @@ typedef struct {  		fop_discard_t discard;                  fop_zerofill_t zerofill;                  fop_ipc_t ipc; +                fop_seek_t seek;  	} fn;  	union { @@ -118,6 +119,7 @@ typedef struct {  		fop_discard_cbk_t discard;                  fop_zerofill_cbk_t zerofill;                  fop_ipc_cbk_t ipc; +                fop_seek_cbk_t seek;  	} fn_cbk;  	struct { @@ -147,6 +149,7 @@ typedef struct {  		gf_xattrop_flags_t optype;  		int valid;  		struct iatt stat; +                gf_seek_what_t what;  		dict_t *xdata;  	} args; @@ -744,6 +747,15 @@ call_stub_t *  fop_ipc_cbk_stub (call_frame_t *frame, fop_ipc_cbk_t fn,                    int32_t op_ret, int32_t op_errno, dict_t *xdata); +call_stub_t * +fop_seek_stub (call_frame_t *frame, fop_seek_t fn, fd_t *fd, off_t offset, +               gf_seek_what_t what, dict_t *xdata); + +call_stub_t * +fop_seek_cbk_stub (call_frame_t *frame, fop_seek_cbk_t fn, +                  int32_t op_ret, int32_t op_errno, off_t offset, +                  dict_t *xdata); +  void call_resume (call_stub_t *stub);  void call_stub_destroy (call_stub_t *stub); diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 5852ae29c8a..a9e74cb895a 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4196,6 +4196,7 @@ fop_enum_to_pri_string (glusterfs_fop_t fop)          case GF_FOP_RCHECKSUM:          case GF_FOP_ZEROFILL:          case GF_FOP_FALLOCATE: +        case GF_FOP_SEEK:                  return "LOW";          case GF_FOP_NULL: diff --git a/libglusterfs/src/default-args.c b/libglusterfs/src/default-args.c index 216e2b6c9a3..3563332e827 100644 --- a/libglusterfs/src/default-args.c +++ b/libglusterfs/src/default-args.c @@ -794,6 +794,19 @@ args_ipc_cbk_store (default_args_cbk_t *args,          return 0;  } +int +args_seek_cbk_store (default_args_cbk_t *args, int32_t op_ret, +                     int32_t op_errno, off_t offset, dict_t *xdata) +{ +        args->op_ret = op_ret; +        args->op_errno = op_errno; +        args->offset = offset; +        if (xdata) +                args->xdata = dict_ref (xdata); + +        return 0; +} +  void  args_cbk_wipe (default_args_cbk_t *args_cbk)  { diff --git a/libglusterfs/src/default-args.h b/libglusterfs/src/default-args.h index 9524e9b0677..80e0d3c2421 100644 --- a/libglusterfs/src/default-args.h +++ b/libglusterfs/src/default-args.h @@ -264,6 +264,10 @@ int  args_ipc_cbk_store (default_args_cbk_t *args,                    int32_t op_ret, int32_t op_errno, dict_t *xdata); +int +args_seek_cbk_store (default_args_cbk_t *args, int32_t op_ret, +                     int32_t op_errno, off_t offset, dict_t *xdata); +  void  args_cbk_wipe (default_args_cbk_t *args_cbk); diff --git a/libglusterfs/src/defaults-tmpl.c b/libglusterfs/src/defaults-tmpl.c index dc20917cb56..8a05ca8b6fb 100644 --- a/libglusterfs/src/defaults-tmpl.c +++ b/libglusterfs/src/defaults-tmpl.c @@ -76,6 +76,7 @@ struct xlator_fops _default_fops = {  	.discard = default_discard,          .zerofill = default_zerofill,          .ipc = default_ipc, +        .seek = default_seek,          .getspec = default_getspec,  }; diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h index 4680cac8112..31df5dd0f6a 100644 --- a/libglusterfs/src/defaults.h +++ b/libglusterfs/src/defaults.h @@ -40,6 +40,7 @@ typedef struct {          uint8_t *strong_checksum;          dict_t *xdata;          gf_dirent_t entries; +        off_t offset;            /* seek hole/data */          int valid; /* If the response is valid or not. For call-stub it is                        always valid irrespective of this */  } default_args_cbk_t; @@ -288,6 +289,9 @@ int32_t default_zerofill(call_frame_t *frame,  int32_t default_ipc (call_frame_t *frame, xlator_t *this, int32_t op,                       dict_t *xdata); +int32_t default_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, +                      off_t offset, gf_seek_what_t what, dict_t *xdata); +  /* Resume */  int32_t default_getspec_resume (call_frame_t *frame, @@ -520,6 +524,9 @@ int32_t default_zerofill_resume(call_frame_t *frame,  int32_t default_ipc_resume (call_frame_t *frame, xlator_t *this,                              int32_t op, dict_t *xdata); +int32_t default_seek_resume (call_frame_t *frame, xlator_t *this, fd_t *fd, +                             off_t offset, gf_seek_what_t what, dict_t *xdata); +  /* _cbk_resume */ @@ -1016,6 +1023,10 @@ int32_t default_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,  int32_t default_ipc_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                           int32_t op_ret, int32_t op_errno, dict_t *xdata); +int32_t default_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +                          int32_t op_ret, int32_t op_errno, off_t offset, +                          dict_t *xdata); +  int32_t  default_getspec_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                       int32_t op_ret, int32_t op_errno, char *spec_data); @@ -1158,5 +1169,8 @@ int32_t  default_getspec_failure_cbk (call_frame_t *frame, int32_t op_errno);  int32_t +default_seek_failure_cbk (call_frame_t *frame, int32_t op_errno); + +int32_t  default_mem_acct_init (xlator_t *this);  #endif /* _DEFAULTS_H */ diff --git a/libglusterfs/src/generator.py b/libglusterfs/src/generator.py index 436c314578a..5e8f6c29cd4 100644 --- a/libglusterfs/src/generator.py +++ b/libglusterfs/src/generator.py @@ -425,6 +425,15 @@ ops['ipc'] = (  	('cbk-arg',	'xdata',		'dict_t *'),  ) +ops['seek'] = ( +	('fop-arg',	'fd',			'fd_t *'), +	('fop-arg',	'offset',		'off_t'), +	('fop-arg',	'what',			'gf_seek_what_t'), +	('fop-arg',	'xdata',		'dict_t *'), +	('cbk-arg',	'offset',		'off_t'), +	('cbk-arg',	'xdata',		'dict_t *'), +) +  ops['getspec'] = (  	('fop-arg',	'key',			'const char *'),  	('fop-arg',	'flags',		'int32_t'), diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 4f48cd169b5..3cc29c5491c 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -68,6 +68,7 @@ const char *gf_fop_list[GF_FOP_MAXVALUE] = {  	[GF_FOP_DISCARD]     = "DISCARD",          [GF_FOP_ZEROFILL]    = "ZEROFILL",          [GF_FOP_IPC]         = "IPC", +        [GF_FOP_SEEK]        = "SEEK",  };  /* THIS */ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 6fda458347a..2eba9d19232 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -318,6 +318,7 @@ typedef enum {  	GF_FOP_DISCARD,          GF_FOP_ZEROFILL,          GF_FOP_IPC, +        GF_FOP_SEEK,          GF_FOP_MAXVALUE,  } glusterfs_fop_t; @@ -391,6 +392,11 @@ typedef enum {          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 diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 0712742360a..c060cedfddb 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -80,6 +80,7 @@ fill_defaults (xlator_t *xl)  	SET_DEFAULT_FOP (discard);          SET_DEFAULT_FOP (zerofill);          SET_DEFAULT_FOP (ipc); +        SET_DEFAULT_FOP (seek);          SET_DEFAULT_FOP (getspec); diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 27b598d7e60..bc539254f29 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -443,6 +443,11 @@ typedef int32_t (*fop_ipc_cbk_t) (call_frame_t *frame, void *cookie,                                   xlator_t *this, int32_t op_ret,                                   int32_t op_errno, dict_t *xdata); +typedef int32_t (*fop_seek_cbk_t) (call_frame_t *frame, void *cookie, +                                   xlator_t *this, int32_t op_ret, +                                   int32_t op_errno, off_t offset, +                                   dict_t *xdata); +  typedef int32_t (*fop_lookup_t) (call_frame_t *frame,                                   xlator_t *this,                                   loc_t *loc, @@ -685,6 +690,10 @@ typedef int32_t (*fop_zerofill_t) (call_frame_t *frame,  typedef int32_t (*fop_ipc_t) (call_frame_t *frame, xlator_t *this, int32_t op,                                dict_t *xdata); +typedef int32_t (*fop_seek_t) (call_frame_t *frame, xlator_t *this, fd_t *fd, +                               off_t offset, gf_seek_what_t what, +                               dict_t *xdata); +  struct xlator_fops {          fop_lookup_t         lookup;          fop_stat_t           stat; @@ -732,6 +741,7 @@ struct xlator_fops {  	fop_discard_t	     discard;          fop_zerofill_t       zerofill;          fop_ipc_t            ipc; +        fop_seek_t           seek;          /* these entries are used for a typechecking hack in STACK_WIND _only_ */          fop_lookup_cbk_t         lookup_cbk; @@ -780,6 +790,7 @@ struct xlator_fops {  	fop_discard_cbk_t	 discard_cbk;          fop_zerofill_cbk_t       zerofill_cbk;          fop_ipc_cbk_t            ipc_cbk; +        fop_seek_cbk_t           seek_cbk;  };  typedef int32_t (*cbk_forget_t) (xlator_t *this,  | 
