From 92eaa72ea4cd0d06c2161842c548008db0eee01c Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Tue, 14 Jan 2014 16:59:00 +0000 Subject: Temporarily revert NSR-specific changelog patches. This is necessary so that patches from upstream can merge cleanly. Otherwise there are some nasty conflicts, and resolving them by hand gets even uglier than this approach. Change-Id: I4235f8ba0ad63563c2e7dec1a1e8eeb636657574 Signed-off-by: Jeff Darcy --- .../changelog/lib/src/gf-changelog-helpers.h | 1 - .../changelog/lib/src/gf-changelog-process.c | 79 +++++++++++++++++----- 2 files changed, 63 insertions(+), 17 deletions(-) (limited to 'xlators/features/changelog/lib/src') diff --git a/xlators/features/changelog/lib/src/gf-changelog-helpers.h b/xlators/features/changelog/lib/src/gf-changelog-helpers.h index f35220ccb..3aa6ed7b8 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-helpers.h +++ b/xlators/features/changelog/lib/src/gf-changelog-helpers.h @@ -94,5 +94,4 @@ gf_ftruncate (int fd, off_t length); off_t gf_lseek (int fd, off_t offset, int whence); - #endif diff --git a/xlators/features/changelog/lib/src/gf-changelog-process.c b/xlators/features/changelog/lib/src/gf-changelog-process.c index df7204931..3ea2700c6 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-process.c +++ b/xlators/features/changelog/lib/src/gf-changelog-process.c @@ -36,6 +36,17 @@ int nr_gfids[] = { [GF_FOP_CREATE] = 1, }; +int nr_extra_recs[] = { + [GF_FOP_MKNOD] = 3, + [GF_FOP_MKDIR] = 3, + [GF_FOP_UNLINK] = 0, + [GF_FOP_RMDIR] = 0, + [GF_FOP_SYMLINK] = 0, + [GF_FOP_RENAME] = 0, + [GF_FOP_LINK] = 0, + [GF_FOP_CREATE] = 3, +}; + static char * binary_to_ascii (uuid_t uuid) { @@ -211,20 +222,20 @@ gf_changelog_parse_ascii (xlator_t *this, gf_changelog_t *gfc, int from_fd, int to_fd, size_t start_offset, struct stat *stbuf) { - int ng = 0; - int ret = -1; - int fop = 0; - int len = 0; - off_t off = 0; - off_t nleft = 0; - char *ptr = NULL; - char *eptr = NULL; - char *start = NULL; - char *mover = NULL; - int parse_err = 0; - char current_mover = ' '; - char ascii[LINE_BUFSIZE] = {0,}; - const char *fopname = NULL; + int ng = 0; + int ret = -1; + int fop = 0; + int len = 0; + off_t off = 0; + off_t nleft = 0; + char *ptr = NULL; + char *eptr = NULL; + char *start = NULL; + char *mover = NULL; + int parse_err = 0; + char current_mover = ' '; + char ascii[LINE_BUFSIZE] = {0,}; + const char *fopname = NULL; nleft = stbuf->st_size; @@ -249,7 +260,6 @@ gf_changelog_parse_ascii (xlator_t *this, switch (current_mover) { case 'D': - case 'M': MOVER_MOVE (mover, nleft, 1); /* target gfid */ @@ -258,6 +268,32 @@ gf_changelog_parse_ascii (xlator_t *this, FILL_AND_MOVE(ptr, ascii, off, mover, nleft, UUID_CANONICAL_FORM_LEN); break; + case 'M': + MOVER_MOVE (mover, nleft, 1); + + /* target gfid */ + PARSE_GFID (mover, ptr, UUID_CANONICAL_FORM_LEN, + conv_noop, parse_err); + FILL_AND_MOVE (ptr, ascii, off, + mover, nleft, UUID_CANONICAL_FORM_LEN); + FILL_AND_MOVE (" ", ascii, off, mover, nleft, 1); + + /* fop */ + len = strlen (mover); + VERIFY_SEPARATOR (mover, len, parse_err); + + fop = atoi (mover); + if ( (fopname = gf_fop_list[fop]) == NULL) { + parse_err = 1; + break; + } + + MOVER_MOVE (mover, nleft, len); + + len = strlen (fopname); + GF_CHANGELOG_FILL_BUFFER (fopname, ascii, off, len); + + break; case 'E': MOVER_MOVE (mover, nleft, 1); @@ -285,6 +321,17 @@ gf_changelog_parse_ascii (xlator_t *this, len = strlen (fopname); GF_CHANGELOG_FILL_BUFFER (fopname, ascii, off, len); + ng = nr_extra_recs[fop]; + for (;ng > 0; ng--) { + MOVER_MOVE (mover, nleft, 1); + len = strlen (mover); + VERIFY_SEPARATOR (mover, len, parse_err); + + GF_CHANGELOG_FILL_BUFFER (" ", ascii, off, 1); + FILL_AND_MOVE (mover, ascii, + off, mover, nleft, len); + } + /* pargfid + bname */ ng = nr_gfids[fop]; while (ng-- > 0) { @@ -320,7 +367,7 @@ gf_changelog_parse_ascii (xlator_t *this, if (gf_changelog_write (to_fd, ascii, off) != off) { gf_log (this->name, GF_LOG_ERROR, "processing ascii changelog failed due to " - " wrror in writing change (reason: %s)", + " error in writing change (reason: %s)", strerror (errno)); break; } -- cgit