summaryrefslogtreecommitdiffstats
path: root/xlators/features/read-only/src/worm.c
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-10 09:33:28 -0700
commite3fd1c1b7d9357161fd0ffe05e2617db1b9ffcd7 (patch)
treee468e614768891ed2fe70f9be568a902a077105a /xlators/features/read-only/src/worm.c
parent176724cdec7061ead0bd7497bb56d0ac09a668a7 (diff)
features/worm: When disabled, worm xl must directly pass fops to its child xl
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>
Diffstat (limited to 'xlators/features/read-only/src/worm.c')
-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: