diff options
author | Kotresh HR <khiremat@redhat.com> | 2015-04-14 14:42:46 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2015-05-04 08:10:12 -0700 |
commit | 21515b3331d8d72011fef79008bcaff8ca43647a (patch) | |
tree | 359d6da85746fa815f856d394e2a2e5cf160e2a1 /xlators/features/changelog/src/changelog.c | |
parent | 2aceadae902e6f45e02afa62ee7831479d23b4a5 (diff) |
feature/changelog: Capture path for deletes
PROBLEM:
There is no way to get the path of deleted file if we
have gfid from changelog since the file is already deleted.
SOLUTION:
Do a recursive readlink on parent gfid in backend .glusterfs
path to get the complete path in I/O callpath in changelog
translator and capture it in callback.
The path captured is relative from the brick root. The field
separator used is '\0'.
e.g.,
......\0<pgfid>/bname\0<relative-path>\0<next-record>
ADDITIONAL REQUIRED CHANGES:
1. The changelog translator option called "changelog.capture-del-path"
is introduced to enable or disable the capturing of deleted entry
path.
e.g.,
gluster vol set <vol-name> changelog.capture-del-path on/off
If capture-del-path is disabled, '\0' is captured instead of
relative path.
e.g.,
......\0<pgfid>/bname\0\0\0<next-record>
2. The minor number in the version of changelog is bumped up from v1.1
to v1.2.
3. If recursive readlink is failed for some reason, it will capture
\0 in place of <relative path>.
e.g.,
......\0<pgfid>/bname\0\0\0<next-record>
(same as when caputre-del-path option is disabled)
4. If bname argument passed to "resolve_pargfid_to_path" function
is NULL and pargfid is ROOT, "." is returned. This is not the
case with changelog, where bname is always passed. This is
applicable to other consumers of "resolve_pargfid_to_path"
routine.
NOTE:
Changelog parser should consider the above new changes
and should parse accordingly.
Change-Id: I040ed429b5aa7d391033fc6a540edbf07fc37827
BUG: 1214561
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/10288
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: NetBSD Build System
Diffstat (limited to 'xlators/features/changelog/src/changelog.c')
-rw-r--r-- | xlators/features/changelog/src/changelog.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index 7429fc5e891..53c0cf85728 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -110,8 +110,15 @@ changelog_rmdir (call_frame_t *frame, xlator_t *this, CHANGLOG_FILL_FOP_NUMBER (co, frame->root->op, fop_fn, xtra_len); co++; - CHANGELOG_FILL_ENTRY (co, loc->pargfid, loc->name, - entry_fn, entry_free_fn, xtra_len, wind); + if (priv->capture_del_path) { + CHANGELOG_FILL_ENTRY_DIR_PATH (co, loc->pargfid, loc->name, + del_entry_fn, del_entry_free_fn, + xtra_len, wind, _gf_true); + } else { + CHANGELOG_FILL_ENTRY_DIR_PATH (co, loc->pargfid, loc->name, + del_entry_fn, del_entry_free_fn, + xtra_len, wind, _gf_false); + } changelog_set_usable_record_and_length (frame->local, xtra_len, 2); @@ -227,8 +234,15 @@ changelog_unlink (call_frame_t *frame, xlator_t *this, CHANGLOG_FILL_FOP_NUMBER (co, frame->root->op, fop_fn, xtra_len); co++; - CHANGELOG_FILL_ENTRY (co, loc->pargfid, loc->name, - entry_fn, entry_free_fn, xtra_len, wind); + if (priv->capture_del_path) { + CHANGELOG_FILL_ENTRY_DIR_PATH (co, loc->pargfid, loc->name, + del_entry_fn, del_entry_free_fn, + xtra_len, wind, _gf_true); + } else { + CHANGELOG_FILL_ENTRY_DIR_PATH (co, loc->pargfid, loc->name, + del_entry_fn, del_entry_free_fn, + xtra_len, wind, _gf_false); + } changelog_set_usable_record_and_length (frame->local, xtra_len, 2); @@ -2339,6 +2353,9 @@ reconfigure (xlator_t *this, dict_t *options) timeout, options, time, out); changelog_assign_barrier_timeout (priv, timeout); + GF_OPTION_RECONF ("capture-del-path", priv->capture_del_path, options, + bool, out); + if (active_now || active_earlier) { ret = changelog_fill_rollover_data (&cld, !active_now); if (ret) @@ -2443,6 +2460,8 @@ changelog_init_options (xlator_t *this, changelog_priv_t *priv) goto dealloc_2; GF_OPTION_INIT ("changelog", priv->active, bool, dealloc_2); + GF_OPTION_INIT ("capture-del-path", priv->capture_del_path, + bool, dealloc_2); GF_OPTION_INIT ("op-mode", tmp, str, dealloc_2); changelog_assign_opmode (priv, tmp); @@ -2719,6 +2738,11 @@ struct volume_options options[] = { "operations are no longer blocked and previously " "blocked fops are allowed to go through" }, + {.key = {"capture-del-path"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "enable/disable capturing paths of deleted entries" + }, {.key = {NULL} }, }; |