summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/basic/uss.t22
-rw-r--r--xlators/features/snapview-client/src/snapview-client.c34
-rw-r--r--xlators/features/snapview-server/src/snapview-server-helpers.c19
-rw-r--r--xlators/features/snapview-server/src/snapview-server.c5
-rw-r--r--xlators/features/snapview-server/src/snapview-server.h6
5 files changed, 51 insertions, 35 deletions
diff --git a/tests/basic/uss.t b/tests/basic/uss.t
index 56cb757514d..f86c19d981e 100644
--- a/tests/basic/uss.t
+++ b/tests/basic/uss.t
@@ -6,6 +6,12 @@
. $(dirname $0)/../fileio.rc
. $(dirname $0)/../nfs.rc
+function check_readonly()
+{
+ $@ 2>&1 | grep -q 'Read-only file system'
+ return $?
+}
+
cleanup;
TEST init_n_bricks 3;
@@ -86,8 +92,8 @@ TEST ! fd_open $fd1 'w' $M0/.snaps/snap1/file2;
TEST ! stat $M0/.snaps/snap1/.snaps
# creating new entries in snapshots should fail
-TEST ! mkdir $M0/.snaps/new
-TEST ! touch $M0/.snaps/snap2/other;
+TEST check_readonly mkdir $M0/.snaps/new
+TEST check_readonly touch $M0/.snaps/snap2/other;
TEST fd3=`fd_available`
TEST fd_open $fd3 'r' $M0/dir1/.snaps/snap3/foo1
@@ -148,9 +154,9 @@ TEST ! fd_open $fd1 'w' $N0/.snaps/snap1/file2;
TEST ! stat $N0/.snaps/snap1/.stat
-TEST ! mkdir $N0/.snaps/new
+TEST check_readonly mkdir $N0/.snaps/new
-TEST ! touch $N0/.snaps/snap2/other;
+TEST check_readonly touch $N0/.snaps/snap2/other;
TEST fd3=`fd_available`
TEST fd_open $fd3 'r' $N0/dir1/.snaps/snap3/foo1
@@ -200,8 +206,8 @@ TEST ! fd_open $fd1 'w' $M0/.history/snap1/file2;
TEST ! stat $M0/.history/snap1/.history
# creating new entries in snapshots should fail
-TEST ! mkdir $M0/.history/new
-TEST ! touch $M0/.history/snap2/other;
+TEST check_readonly mkdir $M0/.history/new
+TEST check_readonly touch $M0/.history/snap2/other;
TEST fd3=`fd_available`
TEST fd_open $fd3 'r' $M0/dir1/.history/snap3/foo1
@@ -246,9 +252,9 @@ TEST ! fd_open $fd1 'w' $N0/.history/snap1/file2;
TEST ! stat $N0/.history/snap1/.stat
-TEST ! mkdir $N0/.history/new
+TEST check_readonly mkdir $N0/.history/new
-TEST ! touch $N0/.history/snap2/other;
+TEST check_readonly touch $N0/.history/snap2/other;
TEST fd3=`fd_available`
TEST fd_open $fd3 'r' $N0/dir1/.history/snap3/foo1
diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c
index 608081b1c30..5bb60d66dd6 100644
--- a/xlators/features/snapview-client/src/snapview-client.c
+++ b/xlators/features/snapview-client/src/snapview-client.c
@@ -489,7 +489,7 @@ svc_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
valid, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -532,7 +532,7 @@ svc_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
valid, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -639,7 +639,7 @@ svc_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
flags, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -683,7 +683,7 @@ svc_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
flags, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -728,7 +728,7 @@ svc_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -800,7 +800,7 @@ svc_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
umask, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -871,7 +871,7 @@ svc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
rdev, umask, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -885,7 +885,7 @@ out:
}
/* If the flags of the open call contain O_WRONLY or O_RDWR and the inode is
- a virtual inode, then unwind the call back with EPERM. Otherwise simply
+ a virtual inode, then unwind the call back with EROFS. Otherwise simply
STACK_WIND the call to the first child of svc xlator.
*/
int32_t
@@ -994,7 +994,7 @@ svc_create (call_frame_t *frame, xlator_t *this,
mode, umask, fd, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -1066,7 +1066,7 @@ svc_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
umask, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -1109,7 +1109,7 @@ svc_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -1368,7 +1368,7 @@ svc_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
gf_log (this->name, GF_LOG_ERROR, "rename happening on a entry"
" %s residing in snapshot", oldloc->name);
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -1379,7 +1379,7 @@ svc_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
"happening to a entry %s residing in snapshot",
oldloc->name, newloc->name);
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
}
@@ -1392,7 +1392,7 @@ svc_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
"happening to a entry %s residing in snapshot",
oldloc->name, newloc->name);
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
}
@@ -1436,7 +1436,7 @@ svc_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
gf_log (this->name, GF_LOG_ERROR, "rename happening on a entry"
" %s residing in snapshot", oldloc->name);
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -1446,7 +1446,7 @@ svc_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
"happening to a entry %s residing in snapshot",
oldloc->name, newloc->name);
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
@@ -1493,7 +1493,7 @@ svc_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
name, xdata);
} else {
op_ret = -1;
- op_errno = EPERM;
+ op_errno = EROFS;
goto out;
}
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c
index fdabc00a9b5..a8183e35d01 100644
--- a/xlators/features/snapview-server/src/snapview-server-helpers.c
+++ b/xlators/features/snapview-server/src/snapview-server-helpers.c
@@ -426,10 +426,12 @@ __svs_get_snap_dirent (xlator_t *this, const char *name)
}
glfs_t *
-__svs_initialise_snapshot_volume (xlator_t *this, const char *name)
+__svs_initialise_snapshot_volume (xlator_t *this, const char *name,
+ int32_t *op_errno)
{
svs_private_t *priv = NULL;
int32_t ret = -1;
+ int32_t local_errno = ESTALE;
snap_dirent_t *dirent = NULL;
char volname[PATH_MAX] = {0, };
glfs_t *fs = NULL;
@@ -446,6 +448,7 @@ __svs_initialise_snapshot_volume (xlator_t *this, const char *name)
if (!dirent) {
gf_log (this->name, GF_LOG_ERROR, "snap entry for "
"name %s not found", name);
+ local_errno = ENOENT;
goto out;
}
@@ -464,6 +467,7 @@ __svs_initialise_snapshot_volume (xlator_t *this, const char *name)
gf_log (this->name, GF_LOG_ERROR,
"glfs instance for snap volume %s "
"failed", dirent->name);
+ local_errno = ENOMEM;
goto out;
}
@@ -497,8 +501,12 @@ __svs_initialise_snapshot_volume (xlator_t *this, const char *name)
ret = 0;
out:
- if (ret && fs) {
- glfs_fini (fs);
+ if (ret) {
+ if (op_errno)
+ *op_errno = local_errno;
+
+ if (fs)
+ glfs_fini (fs);
fs = NULL;
}
@@ -510,7 +518,8 @@ out:
}
glfs_t *
-svs_initialise_snapshot_volume (xlator_t *this, const char *name)
+svs_initialise_snapshot_volume (xlator_t *this, const char *name,
+ int32_t *op_errno)
{
glfs_t *fs = NULL;
svs_private_t *priv = NULL;
@@ -523,7 +532,7 @@ svs_initialise_snapshot_volume (xlator_t *this, const char *name)
LOCK (&priv->snaplist_lock);
{
- fs = __svs_initialise_snapshot_volume (this, name);
+ fs = __svs_initialise_snapshot_volume (this, name, op_errno);
}
UNLOCK (&priv->snaplist_lock);
diff --git a/xlators/features/snapview-server/src/snapview-server.c b/xlators/features/snapview-server/src/snapview-server.c
index 8921909d7ee..2f15f5ef264 100644
--- a/xlators/features/snapview-server/src/snapview-server.c
+++ b/xlators/features/snapview-server/src/snapview-server.c
@@ -211,13 +211,12 @@ svs_lookup_snapshot (xlator_t *this, loc_t *loc, struct iatt *buf,
GF_VALIDATE_OR_GOTO (this->name, parent_ctx, out);
GF_VALIDATE_OR_GOTO (this->name, parent, out);
- fs = svs_initialise_snapshot_volume (this, loc->name);
+ fs = svs_initialise_snapshot_volume (this, loc->name, op_errno);
if (!fs) {
gf_log (this->name, GF_LOG_ERROR, "failed to "
"create the fs instance for snap %s",
loc->name);
op_ret = -1;
- *op_errno = ESTALE;
goto out;
}
@@ -534,7 +533,7 @@ svs_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
dirent = svs_get_latest_snap_entry (this);
if (dirent && !dirent->fs) {
- fs = svs_initialise_snapshot_volume (this, dirent->name);
+ fs = svs_initialise_snapshot_volume (this, dirent->name, NULL);
}
/* lookup is on the entry point to the snapshot world */
diff --git a/xlators/features/snapview-server/src/snapview-server.h b/xlators/features/snapview-server/src/snapview-server.h
index 6033c0e250f..9c13cf74610 100644
--- a/xlators/features/snapview-server/src/snapview-server.h
+++ b/xlators/features/snapview-server/src/snapview-server.h
@@ -212,10 +212,12 @@ glfs_t *
svs_get_latest_snapshot (xlator_t *this);
glfs_t *
-svs_initialise_snapshot_volume (xlator_t *this, const char *name);
+svs_initialise_snapshot_volume (xlator_t *this, const char *name,
+ int32_t *op_errno);
glfs_t *
-__svs_initialise_snapshot_volume (xlator_t *this, const char *name);
+__svs_initialise_snapshot_volume (xlator_t *this, const char *name,
+ int32_t *op_errno);
snap_dirent_t *
__svs_get_snap_dirent (xlator_t *this, const char *name);