summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/stub/bit-rot-stub.c
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2015-05-15 14:10:48 +0530
committerVenky Shankar <vshankar@redhat.com>2015-05-31 08:00:16 -0700
commit37cc99fc3a991241df49133902928bd789d95066 (patch)
tree5e53e9bc48000517637b399fb99b791f72841d48 /xlators/features/bit-rot/src/stub/bit-rot-stub.c
parentd76e9b83454786e6845d0cad3c2c0695815fae1b (diff)
features/bit-rot-stub: implement mknod fop
With the absence of mknod() fop implementation in bitrot stub, further operations that trigger versioning resulted in crashes as they expect the inode context to be valid. Therefore, this patch implements mknod() following similar simantics to fops such as create(). Furthermore, bitrot stub test C program is fixed to stop lying and validate obj versions according to the versioning protocol. Change-Id: If76f252577445d1851d6c13c7e969e864e2183ef BUG: 1221914 Original-Author: Raghavendra Bhat <raghavendra@redhat.com> Signed-off-by: Venky Shankar <vshankar@redhat.com> Reviewed-on: http://review.gluster.org/10790 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/bit-rot/src/stub/bit-rot-stub.c')
-rw-r--r--xlators/features/bit-rot/src/stub/bit-rot-stub.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
index b9a527681ab..d48a3f751f3 100644
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
@@ -1642,6 +1642,10 @@ br_stub_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (ret < 0) {
ret = br_stub_init_inode_versions (this, fd, inode, version,
_gf_true);
+ if (ret) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ }
} else {
ctx = (br_stub_inode_ctx_t *)(long)ctx_addr;
ret = br_stub_add_fd_to_inode (this, fd, ctx);
@@ -1674,6 +1678,52 @@ unwind:
return 0;
}
+int
+br_stub_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno, inode_t *inode,
+ struct iatt *stbuf, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
+{
+ int32_t ret = -1;
+ unsigned long version = BITROT_DEFAULT_CURRENT_VERSION;
+
+ if (op_ret < 0)
+ goto unwind;
+
+ ret = br_stub_init_inode_versions (this, NULL, inode, version,
+ _gf_true);
+ /**
+ * Like lookup, if init_inode_versions fail, return EINVAL
+ */
+ if (ret) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ }
+
+unwind:
+ STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno,
+ inode, stbuf, preparent, postparent, xdata);
+ return 0;
+}
+
+int
+br_stub_mknod (call_frame_t *frame, xlator_t *this,
+ loc_t *loc, mode_t mode, dev_t dev, mode_t umask, dict_t *xdata)
+{
+ GF_VALIDATE_OR_GOTO ("bit-rot-stub", this, unwind);
+ GF_VALIDATE_OR_GOTO (this->name, loc, unwind);
+ GF_VALIDATE_OR_GOTO (this->name, loc->inode, unwind);
+
+ STACK_WIND (frame, br_stub_mknod_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->mknod,
+ loc, mode, dev, umask, xdata);
+ return 0;
+unwind:
+ STACK_UNWIND_STRICT (mknod, frame, -1, EINVAL, NULL, NULL, NULL,
+ NULL, NULL);
+ return 0;
+}
+
/** }}} */
static inline int32_t
@@ -2139,6 +2189,7 @@ struct xlator_fops fops = {
.writev = br_stub_writev,
.truncate = br_stub_truncate,
.ftruncate = br_stub_ftruncate,
+ .mknod = br_stub_mknod,
};
struct xlator_cbks cbks = {