diff options
| author | Ajeet Jha <ajha@redhat.com> | 2013-12-02 13:04:51 +0530 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2013-12-12 00:15:45 -0800 | 
| commit | 8f2fc6fb3a63ca87d82b6fa933f94fb1e3283a26 (patch) | |
| tree | c0efe5adc7fa78b5b11e4929999d8f9e459d39e1 /xlators/features/changelog/lib | |
| parent | 493008a299cd1197df0caee72eacd12c1a54606b (diff) | |
features/changelog: more changelog fixes.
-> log additional records.
-> include FOP number for metadata.
-> prevent crash if inode is not found in a fop.
Change-Id: I9edd4b71819ebd68c6a2b4150ae279c471d129da
BUG: 1036536
Signed-off-by: Ajeet Jha <ajha@redhat.com>
Reviewed-on: http://review.gluster.org/6403
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@gmail.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/changelog/lib')
| -rw-r--r-- | xlators/features/changelog/lib/examples/c/get-changes.c | 2 | ||||
| -rw-r--r-- | xlators/features/changelog/lib/src/gf-changelog-process.c | 79 | 
2 files changed, 64 insertions, 17 deletions
diff --git a/xlators/features/changelog/lib/examples/c/get-changes.c b/xlators/features/changelog/lib/examples/c/get-changes.c index 14562585aa9..6d0d0357db9 100644 --- a/xlators/features/changelog/lib/examples/c/get-changes.c +++ b/xlators/features/changelog/lib/examples/c/get-changes.c @@ -40,7 +40,7 @@ main (int argc, char ** argv)          char fbuf[PATH_MAX] = {0,};          /* get changes for brick "/home/vshankar/export/yow/yow-1" */ -        ret = gf_changelog_register ("/home/vshankar/export/yow/yow-1", +        ret = gf_changelog_register ("/home/vshankar/exports/yow/yow-1",                                       "/tmp/scratch", "/tmp/change.log", 9, 5);          if (ret) {                  handle_error ("register failed"); diff --git a/xlators/features/changelog/lib/src/gf-changelog-process.c b/xlators/features/changelog/lib/src/gf-changelog-process.c index df7204931a8..3ea2700c62b 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;                  }  | 
