diff options
| -rwxr-xr-x | tests/features/worm.t | 9 | ||||
| -rw-r--r-- | xlators/features/read-only/src/worm.c | 18 | 
2 files changed, 25 insertions, 2 deletions
diff --git a/tests/features/worm.t b/tests/features/worm.t index 407b49a79ce..f8f05065918 100755 --- a/tests/features/worm.t +++ b/tests/features/worm.t @@ -48,6 +48,15 @@ TEST ! link $M0/file1 $M0/file2  sleep 5  TEST rm -f $M0/file1 +## Test for mv over WORM/Reatined state +TEST `echo "worm 1" > $M0/file1` +TEST chmod 0444 $M0/file1 +TEST `echo "worm 2" > $M0/file2` +TEST ! mv $M0/file2 $M0/file1 +TEST rm -f $M0/file2 +sleep 10 +TEST rm -f $M0/file1 +  TEST $CLI volume stop $V0  EXPECT 'Stopped' volinfo_field $V0 'Status' diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c index c7f9b9288dd..24ae5f6be8b 100644 --- a/xlators/features/read-only/src/worm.c +++ b/xlators/features/read-only/src/worm.c @@ -137,10 +137,24 @@ worm_rename (call_frame_t *frame, xlator_t *this,          gf_uuid_copy (oldloc->gfid, oldloc->inode->gfid);          if (is_wormfile (this, _gf_false, oldloc)) {                  op_errno = 0; -                goto out; +                goto check_newloc;          }          op_errno = gf_worm_state_transition (this, _gf_false, oldloc, -                                           GF_FOP_RENAME); +                                             GF_FOP_RENAME); + +        if (op_errno == 0) { +check_newloc: +                if (newloc->inode != NULL) { +                        gf_uuid_copy (newloc->gfid, newloc->inode->gfid); +                        if (is_wormfile (this, _gf_false, newloc)) { +                                op_errno = 0; +                                goto out; +                        } +                        op_errno = gf_worm_state_transition (this, _gf_false, +                                                             newloc, +                                                             GF_FOP_RENAME); +                } +        }  out:          if (op_errno)  | 
