diff options
author | Vikas Gorur <vikas@gluster.com> | 2009-09-17 05:56:25 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-09-22 06:13:32 -0700 |
commit | faf97734112ebe11d8a411351d9f23b528b9d616 (patch) | |
tree | d8b898e842c1be3c3b760d41188f7a4b0078232b /libglusterfs/src/call-stub.c | |
parent | 239d2cbdb0a4c32df9f21de8385e2c466b934178 (diff) |
libglusterfs: Add RCHECKSUM fop.
rchecksum (fd, offset, len): Calculates both the weak and strong
checksums for a block of {len} bytes at {offset} in {fd}.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'libglusterfs/src/call-stub.c')
-rw-r--r-- | libglusterfs/src/call-stub.c | 110 |
1 files changed, 109 insertions, 1 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 05f58a700b7..701ee8872a0 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -22,6 +22,9 @@ #include "config.h" #endif +#include <inttypes.h> + +#include "md5.h" #include "call-stub.h" @@ -2084,6 +2087,61 @@ out: call_stub_t * +fop_rchecksum_stub (call_frame_t *frame, + fop_rchecksum_t fn, + fd_t *fd, off_t offset, + int32_t len) +{ + call_stub_t *stub = NULL; + + GF_VALIDATE_OR_GOTO ("call-stub", frame, out); + GF_VALIDATE_OR_GOTO ("call-stub", fd, out); + + stub = stub_new (frame, 1, GF_FOP_RCHECKSUM); + GF_VALIDATE_OR_GOTO ("call-stub", stub, out); + + stub->args.rchecksum.fn = fn; + stub->args.rchecksum.fd = fd_ref (fd); + stub->args.rchecksum.offset = offset; + stub->args.rchecksum.len = len; +out: + return stub; +} + + +call_stub_t * +fop_rchecksum_cbk_stub (call_frame_t *frame, + fop_rchecksum_cbk_t fn, + int32_t op_ret, + int32_t op_errno, + uint32_t weak_checksum, + uint8_t *strong_checksum) +{ + call_stub_t *stub = NULL; + + GF_VALIDATE_OR_GOTO ("call-stub", frame, out); + + stub = stub_new (frame, 0, GF_FOP_RCHECKSUM); + GF_VALIDATE_OR_GOTO ("call-stub", stub, out); + + stub->args.rchecksum_cbk.fn = fn; + stub->args.rchecksum_cbk.op_ret = op_ret; + stub->args.rchecksum_cbk.op_errno = op_errno; + + if (op_ret >= 0) + { + stub->args.rchecksum_cbk.weak_checksum = + weak_checksum; + + stub->args.rchecksum_cbk.strong_checksum = + memdup (strong_checksum, MD5_DIGEST_LEN); + } +out: + return stub; +} + + +call_stub_t * fop_xattrop_cbk_stub (call_frame_t *frame, fop_xattrop_cbk_t fn, int32_t op_ret, @@ -2656,6 +2714,17 @@ call_resume_wind (call_stub_t *stub) stub->args.checksum.flags); break; } + + case GF_FOP_RCHECKSUM: + { + stub->args.rchecksum.fn (stub->frame, + stub->frame->this, + stub->args.rchecksum.fd, + stub->args.rchecksum.offset, + stub->args.rchecksum.len); + break; + } + case GF_FOP_READDIR: { stub->args.readdir.fn (stub->frame, @@ -3452,6 +3521,30 @@ call_resume_unwind (call_stub_t *stub) break; } + case GF_FOP_RCHECKSUM: + { + if (!stub->args.rchecksum_cbk.fn) + STACK_UNWIND (stub->frame, + stub->args.rchecksum_cbk.op_ret, + stub->args.rchecksum_cbk.op_errno, + stub->args.rchecksum_cbk.weak_checksum, + stub->args.rchecksum_cbk.strong_checksum); + else + stub->args.rchecksum_cbk.fn (stub->frame, + stub->frame->cookie, + stub->frame->this, + stub->args.rchecksum_cbk.op_ret, + stub->args.rchecksum_cbk.op_errno, + stub->args.rchecksum_cbk.weak_checksum, + stub->args.rchecksum_cbk.strong_checksum); + if (stub->args.rchecksum_cbk.op_ret >= 0) + { + FREE (stub->args.rchecksum_cbk.strong_checksum); + } + + break; + } + case GF_FOP_READDIR: { if (!stub->args.readdir_cbk.fn) @@ -3855,7 +3948,14 @@ call_stub_destroy_wind (call_stub_t *stub) loc_wipe (&stub->args.checksum.loc); break; } - break; + + case GF_FOP_RCHECKSUM: + { + if (stub->args.rchecksum.fd) + fd_unref (stub->args.rchecksum.fd); + break; + } + case GF_FOP_READDIR: { if (stub->args.readdir.fd) @@ -4105,6 +4205,14 @@ call_stub_destroy_unwind (call_stub_t *stub) } break; + case GF_FOP_RCHECKSUM: + { + if (stub->args.rchecksum_cbk.op_ret >= 0) { + FREE (stub->args.rchecksum_cbk.strong_checksum); + } + } + break; + case GF_FOP_READDIR: { if (stub->args.readdir_cbk.op_ret > 0) { |