summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix.c
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-04-09 07:59:21 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-09 20:33:17 +0530
commitbf7b4623821c8ffe8070297949e18dc6e3757e9c (patch)
tree4e29b5e4dd165bb8d87a0925bf83e6ef105300bf /xlators/storage/posix/src/posix.c
parentfb034ba3036fadc7cf35edc5cae7481149a67ca0 (diff)
posix_unlink: make unlinking in background configurable through volume spec file
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/storage/posix/src/posix.c')
-rw-r--r--xlators/storage/posix/src/posix.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 9f4c42a..99c4879 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -850,10 +850,11 @@ int32_t
posix_unlink (call_frame_t *frame, xlator_t *this,
loc_t *loc)
{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- char * real_path = NULL;
- int32_t fd = -1;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ char *real_path = NULL;
+ int32_t fd = -1;
+ struct posix_private *priv = NULL;
DECLARE_OLD_FS_ID_VAR;
@@ -864,15 +865,18 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
SET_FS_ID (frame->root->uid, frame->root->gid);
MAKE_REAL_PATH (real_path, this, loc->path);
- if (S_ISREG (loc->inode->st_mode)) {
- fd = open (real_path, O_RDONLY);
- if (fd == -1) {
- op_ret = -1;
- op_errno = errno;
- gf_log (this->name, GF_LOG_WARNING,
- "open of %s failed: %s", loc->path,
- strerror (op_errno));
- goto out;
+ priv = this->private;
+ if (priv->background_unlink) {
+ if (S_ISREG (loc->inode->st_mode)) {
+ fd = open (real_path, O_RDONLY);
+ if (fd == -1) {
+ op_ret = -1;
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_WARNING,
+ "open of %s failed: %s", loc->path,
+ strerror (op_errno));
+ goto out;
+ }
}
}
@@ -3937,6 +3941,23 @@ init (xlator_t *this)
"'statfs()' returns dummy size");
}
+ _private->background_unlink = 0;
+ tmp_data = dict_get (this->options, "background-unlink");
+ if (tmp_data) {
+ if (gf_string2boolean (tmp_data->data,
+ &_private->background_unlink) == -1) {
+ ret = -1;
+ gf_log (this->name, GF_LOG_ERROR,
+ "'export-statfs-size' takes only boolean "
+ "options");
+ goto out;
+ }
+
+ if (_private->background_unlink)
+ gf_log (this->name, GF_LOG_DEBUG,
+ "unlinks will be performed in background");
+ }
+
tmp_data = dict_get (this->options, "o-direct");
if (tmp_data) {
if (gf_string2boolean (tmp_data->data,
@@ -4087,5 +4108,7 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_BOOL },
{ .key = {"span-devices"},
.type = GF_OPTION_TYPE_INT },
+ { .key = {"background-unlink"},
+ .type = GF_OPTION_TYPE_BOOL },
{ .key = {NULL} }
};