summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushal M <kaushal@gluster.com>2011-09-27 12:37:22 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-27 05:40:57 -0700
commit2e00396e04f261af45c33b55b9b73157a2e8fc72 (patch)
treec9a1b1bfe700616744d63ff256c4bf16b7afa21b
parent9dc9fb48f1790a76c499b105687cee82b2840865 (diff)
storage/posix : prevent unmount of underlying fs
posix xlator now performs opendir () on the brick directory during init (). This will prevent the underlying filesystem mounted to that directory from being unmounted. Change-Id: I02c190ab8a91abc4ab06959b36f50e0a3fa527ae BUG: 3578 Reviewed-on: http://review.gluster.com/509 Reviewed-by: Amar Tumballi <amar@gluster.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--xlators/storage/posix/src/posix.c14
-rw-r--r--xlators/storage/posix/src/posix.h2
2 files changed, 15 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 1a5a52336e0..aad8a7350b1 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -4058,7 +4058,16 @@ init (xlator_t *this)
_private->janitor_sleep_duration = janitor_sleep;
}
-
+ /* performing open dir on brick dir locks the brick dir
+ * and prevents it from being unmounted
+ */
+ _private->mount_lock = opendir (dir_data->data);
+ if (!_private->mount_lock) {
+ ret = -1;
+ gf_log (this->name, GF_LOG_ERROR,
+ "Could not lock brick directory");
+ goto out;
+ }
#ifndef GF_DARWIN_HOST_OS
{
struct rlimit lim;
@@ -4104,6 +4113,9 @@ fini (xlator_t *this)
if (!priv)
return;
this->private = NULL;
+ /*unlock brick dir*/
+ if (priv->mount_lock)
+ closedir (priv->mount_lock);
GF_FREE (priv);
return;
}
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 21170ea59f1..1733eadd1a8 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -114,6 +114,8 @@ struct posix_private {
pthread_t janitor;
gf_boolean_t janitor_present;
char * trash_path;
+/* lock for brick dir */
+ DIR *mount_lock;
};
#define POSIX_BASE_PATH(this) (((struct posix_private *)this->private)->base_path)