diff options
author | Raghavendra G <raghavendra@zresearch.com> | 2009-04-09 07:59:21 -0700 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-04-09 20:33:17 +0530 |
commit | bf7b4623821c8ffe8070297949e18dc6e3757e9c (patch) | |
tree | 4e29b5e4dd165bb8d87a0925bf83e6ef105300bf /xlators | |
parent | fb034ba3036fadc7cf35edc5cae7481149a67ca0 (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')
-rw-r--r-- | xlators/storage/posix/src/posix.c | 49 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.h | 8 |
2 files changed, 44 insertions, 13 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 9f4c42a1a..99c487983 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} } }; diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h index 88860a571..ed6b46430 100644 --- a/xlators/storage/posix/src/posix.h +++ b/xlators/storage/posix/src/posix.h @@ -93,6 +93,14 @@ struct posix_private { gf_boolean_t span_devices; +/* + decide whether posix_unlink does open (file), unlink (file), close (fd) + instead of just unlink (file). with the former approach there is no lockout + of access to parent directory during removal of very large files for the + entire duration of freeing of data blocks. +*/ + gf_boolean_t background_unlink; + int num_devices_to_span; dev_t *st_device; }; |