summaryrefslogtreecommitdiffstats
path: root/xlators/features/snapview-server/src/snapview-server-helpers.c
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2018-06-08 09:54:00 -0400
committerAmar Tumballi <amarts@redhat.com>2018-08-24 04:18:55 +0000
commitf191bb7bc1abd250bdf0a5a6972ce95fcbd3314b (patch)
tree761211f59a43a954dc3312b570080faa68027be8 /xlators/features/snapview-server/src/snapview-server-helpers.c
parent11a9f9f0dcca58446f306ef2060a345348ed91c1 (diff)
features/snapview-server: validate the fs instance before doing fop there
PROBLEM: ======== USS design depends on snapview-server translator communicating with each individual snapshot via gfapi. So, the snapview-server xlator maintains the glfs instance (thus the snapshot) to which a inode belongs to by storing it inside the inode context. Suppose, a file from a snapshot is opened by a application, and the fd is still valid from application's point of view (i.e. application has not yet closed fd). Now, if the snapshot to which the opened file belongs to is deleted, then the glfs_t instance corresponding to the snapshot is destroyed by snapview-server as part of snap deletion. But now, if the application does IO on the fd it has kept open, then snapview server tries to send that request to the corresponding snap via glfs instance for that snapshot stored in the inode context for the file on which the application is sending the fop. And this results in freed up glfs_t pointer being accessed and causes a segfault. FIX: === For fd based operations, check whether the glfs instance that the inode contains in its context, is still valid or not. For non fd based operations, usually lookup should guarantee that. But if the file was already looked up, and the client accessing the snap data (either NFS, or native glusterfs fuse) does not bother to send a lookup and directly sends a path based fop, then that path based fop should ensure that the fs instance is valid. Change-Id: I881be15ec46ecb51aa844d7fd41d5630f0d644fb updates: bz#1602070 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/features/snapview-server/src/snapview-server-helpers.c')
-rw-r--r--xlators/features/snapview-server/src/snapview-server-helpers.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c
index 6f305dbc2fb..091feb59180 100644
--- a/xlators/features/snapview-server/src/snapview-server-helpers.c
+++ b/xlators/features/snapview-server/src/snapview-server-helpers.c
@@ -595,3 +595,38 @@ svs_get_latest_snapshot (xlator_t *this)
out:
return fs;
}
+
+glfs_t *
+svs_inode_ctx_glfs_mapping (xlator_t *this, svs_inode_t *inode_ctx)
+{
+ glfs_t *fs = NULL;
+
+ GF_VALIDATE_OR_GOTO ("svs", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, inode_ctx, out);
+
+ fs = inode_ctx->fs;
+
+ SVS_CHECK_VALID_SNAPSHOT_HANDLE (fs, this);
+
+out:
+ return fs;
+}
+
+glfs_t *
+svs_inode_glfs_mapping (xlator_t *this, inode_t *inode)
+{
+ svs_inode_t *inode_ctx = NULL;
+ glfs_t *fs = NULL;
+
+ inode_ctx = svs_inode_ctx_get (this, inode);
+ if (!inode_ctx) {
+ gf_log (this->name, GF_LOG_ERROR, "inode context not found for"
+ " the inode %s", uuid_utoa (inode->gfid));
+ goto out;
+ }
+
+ fs = svs_inode_ctx_glfs_mapping (this, inode_ctx);
+
+out:
+ return fs;
+}