summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2016-05-03 14:29:45 +0530
committerNiels de Vos <ndevos@redhat.com>2016-05-24 01:34:45 -0700
commit842ec2af2cb0a0fecc9da018a51814946b89231e (patch)
tree24ed6089fea72b4f25b57b68a152d646e1fac281
parentb128a8983376c70b6f9f35ed60d54404da314624 (diff)
features/worm: When disabled, worm xlator must directly pass fops to its child xlator
Backport of http://review.gluster.org/#/c/14182/ > Change-Id: I56ea46c2743636ef7af5c85469cb2e186eadf21f > BUG: 1332460 > Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> > Reviewed-on: http://review.gluster.org/14182 > Smoke: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Joseph Fernandes > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Niels de Vos <ndevos@redhat.com> > Signed-off-by: Joseph Fernandes <josferna@redhat.com> Change-Id: Ic3995e8e81ae22a0c31167e356b203acfff4194d BUG: 1334836 Signed-off-by: Joseph Fernandes <josferna@redhat.com> Reviewed-on: http://review.gluster.org/14367 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Joseph Fernandes Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r--xlators/features/read-only/src/worm.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c
index 2f35f1fc9f1..8297e8d3b7a 100644
--- a/xlators/features/read-only/src/worm.c
+++ b/xlators/features/read-only/src/worm.c
@@ -52,9 +52,15 @@ worm_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
{
int ret = -1;
int label = -1;
+ read_only_priv_t *priv = NULL;
+ priv = this->private;
+ GF_ASSERT (priv);
if (is_readonly_or_worm_enabled (this))
goto unwind;
+ if (!priv->worm_file)
+ goto wind;
+
gf_uuid_copy (oldloc->gfid, oldloc->inode->gfid);
if (is_wormfile (this, _gf_false, oldloc))
goto wind;
@@ -90,9 +96,15 @@ worm_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
{
int ret = -1;
int label = -1;
+ read_only_priv_t *priv = NULL;
+ priv = this->private;
+ GF_ASSERT (priv);
if (is_readonly_or_worm_enabled (this))
goto unwind;
+ if (!priv->worm_file)
+ goto wind;
+
gf_uuid_copy (loc->gfid, loc->inode->gfid);
if (is_wormfile (this, _gf_false, loc))
goto wind;
@@ -127,9 +139,15 @@ worm_rename (call_frame_t *frame, xlator_t *this,
{
int ret = -1;
int label = -1;
+ read_only_priv_t *priv = NULL;
+ priv = this->private;
+ GF_ASSERT (priv);
if (is_readonly_or_worm_enabled (this))
goto unwind;
+ if (!priv->worm_file)
+ goto wind;
+
gf_uuid_copy (oldloc->gfid, oldloc->inode->gfid);
if (is_wormfile (this, _gf_false, oldloc))
goto wind;
@@ -166,9 +184,15 @@ worm_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
{
int ret = -1;
int label = -1;
+ read_only_priv_t *priv = NULL;
+ priv = this->private;
+ GF_ASSERT (priv);
if (is_readonly_or_worm_enabled (this))
goto unwind;
+ if (!priv->worm_file)
+ goto wind;
+
if (is_wormfile (this, _gf_false, loc))
goto wind;
label = state_transition (this, _gf_false, loc, GF_FOP_TRUNCATE,
@@ -207,8 +231,14 @@ worm_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
gf_boolean_t rd_only = _gf_false;
worm_reten_state_t reten_state = {0,};
struct iatt stpre = {0,};
+ read_only_priv_t *priv = NULL;
int ret = -1;
+ priv = this->private;
+ GF_ASSERT (priv);
+ if (!priv->worm_file)
+ goto wind;
+
if (is_wormfile (this, _gf_false, loc))
goto wind;
if (valid & GF_SET_ATTR_MODE) {
@@ -272,8 +302,14 @@ worm_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
gf_boolean_t rd_only = _gf_false;
worm_reten_state_t reten_state = {0,};
struct iatt stpre = {0,};
+ read_only_priv_t *priv = NULL;
int ret = -1;
+ priv = this->private;
+ GF_ASSERT (priv);
+ if (!priv->worm_file)
+ goto wind;
+
if (is_wormfile (this, _gf_true, fd))
goto wind;
if (valid & GF_SET_ATTR_MODE) {
@@ -336,17 +372,20 @@ worm_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
struct iobref *iobref, dict_t *xdata)
{
worm_reten_state_t reten_state = {0,};
+ read_only_priv_t *priv = NULL;
int ret = -1;
- if (is_readonly_or_worm_enabled (this))
- goto unwind;
+ priv = this->private;
+ GF_ASSERT (priv);
+ if (!priv->worm_file)
+ goto wind;
+
if (is_wormfile (this, _gf_true, fd))
goto wind;
ret = worm_get_state (this, _gf_true, fd, &reten_state);
if (!reten_state.worm)
goto wind;
-unwind:
STACK_UNWIND_STRICT (writev, frame, -1, EROFS, NULL, NULL, NULL);
goto out;
@@ -356,7 +395,6 @@ wind:
FIRST_CHILD (this)->fops->writev,
fd, vector, count, offset, flags,
iobref, xdata);
- gf_log (this->name, GF_LOG_INFO, "WORM writev");
ret = 0;
out: