Whamcloud - gitweb
LU-3279 changelog: fix CL_LAYOUT, accept all types
authorAndreas Dilger <andreas.dilger@intel.com>
Fri, 10 May 2013 06:07:31 +0000 (00:07 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 14 May 2013 17:31:17 +0000 (13:31 -0400)
In order to avoid compatibility issues with older ChangeLog consumers,
change the new CL_LAYOUT record to use the value previously assigned
to CL_IOCTL.  The CL_IOCTL type was never used anywhere, and it didn't
really make any sense as a ChangeLog record, since it could really
mean anything at all.

The changelog_show_cb() function is renamed to changelog_kkuc_cb(),
since it is really about consuming the ChangeLog and passing it up to
the kernel-user-coms interface.  At some point we should consider to
implement a DBUS-based ChangeLog interface as well.

The changelog_kkuc_cb() "sanity check" on cr_type was removed, since
there is no reason the client kernel needs to know every record type
that is being passed to userspace.  It is up to the client tool to
determine what records that it can process.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Id8e6471827a89d8c62808e6b3cfd9693d6026431
Reviewed-on: http://review.whamcloud.com/6308
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Tested-by: Hudson
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre/lustre_user.h
lustre/mdc/mdc_request.c
lustre/utils/lustre_rsync.c

index a8c8514..1de22e4 100644 (file)
@@ -647,23 +647,22 @@ enum changelog_rec_type {
         CL_EXT      = 9,  /* namespace extended record (2nd half of rename) */
         CL_OPEN     = 10, /* not currently used */
         CL_CLOSE    = 11, /* may be written to log only with mtime change */
-        CL_IOCTL    = 12,
-        CL_TRUNC    = 13,
-        CL_SETATTR  = 14,
-        CL_XATTR    = 15,
-        CL_HSM      = 16, /* HSM specific events, see flags */
-        CL_MTIME    = 17, /* Precedence: setattr > mtime > ctime > atime */
-        CL_CTIME    = 18,
-        CL_ATIME    = 19,
-       CL_LAYOUT   = 20,
-        CL_LAST
+       CL_LAYOUT   = 12, /* file layout/striping modified, no data changed */
+       CL_TRUNC    = 13,
+       CL_SETATTR  = 14,
+       CL_XATTR    = 15,
+       CL_HSM      = 16, /* HSM specific events, see flags */
+       CL_MTIME    = 17, /* Precedence: setattr > mtime > ctime > atime */
+       CL_CTIME    = 18,
+       CL_ATIME    = 19,
+       CL_LAST
 };
 
 static inline const char *changelog_type2str(int type) {
        static const char *changelog_str[] = {
                "MARK",  "CREAT", "MKDIR", "HLINK", "SLINK", "MKNOD", "UNLNK",
-               "RMDIR", "RENME", "RNMTO", "OPEN",  "CLOSE", "IOCTL", "TRUNC",
-               "SATTR", "XATTR", "HSM",   "MTIME", "CTIME", "ATIME", "LAYOUT"
+               "RMDIR", "RENME", "RNMTO", "OPEN",  "CLOSE", "LAYOUT", "TRUNC",
+               "SATTR", "XATTR", "HSM",   "MTIME", "CTIME", "ATIME",
        };
 
        if (type >= 0 && type < CL_LAST)
index 3ea8996..393a5f1 100644 (file)
@@ -1517,28 +1517,29 @@ struct changelog_show {
        struct obd_device *cs_obd;
 };
 
-static int changelog_show_cb(const struct lu_env *env, struct llog_handle *llh,
+static int changelog_kkuc_cb(const struct lu_env *env, struct llog_handle *llh,
                             struct llog_rec_hdr *hdr, void *data)
 {
-        struct changelog_show *cs = data;
-        struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
-        struct kuc_hdr *lh;
-        int len, rc;
-        ENTRY;
+       struct changelog_show *cs = data;
+       struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
+       struct kuc_hdr *lh;
+       int len, rc;
+       ENTRY;
 
-        if ((rec->cr_hdr.lrh_type != CHANGELOG_REC) ||
-            (rec->cr.cr_type >= CL_LAST)) {
-                CERROR("Not a changelog rec %d/%d\n", rec->cr_hdr.lrh_type,
-                       rec->cr.cr_type);
-                RETURN(-EINVAL);
-        }
+       if (rec->cr_hdr.lrh_type != CHANGELOG_REC) {
+               rc = -EINVAL;
+               CERROR("%s: not a changelog rec %x/%d: rc = %d\n",
+                      cs->cs_obd->obd_name, rec->cr_hdr.lrh_type,
+                      rec->cr.cr_type, rc);
+               RETURN(rc);
+       }
 
-        if (rec->cr.cr_index < cs->cs_startrec) {
-                /* Skip entries earlier than what we are interested in */
-                CDEBUG(D_CHANGELOG, "rec="LPU64" start="LPU64"\n",
-                       rec->cr.cr_index, cs->cs_startrec);
-                RETURN(0);
-        }
+       if (rec->cr.cr_index < cs->cs_startrec) {
+               /* Skip entries earlier than what we are interested in */
+               CDEBUG(D_CHANGELOG, "rec="LPU64" start="LPU64"\n",
+                      rec->cr.cr_index, cs->cs_startrec);
+               RETURN(0);
+       }
 
        CDEBUG(D_CHANGELOG, LPU64" %02d%-5s "LPU64" 0x%x t="DFID" p="DFID
                " %.*s\n", rec->cr.cr_index, rec->cr.cr_type,
@@ -1598,7 +1599,7 @@ static int mdc_changelog_send_thread(void *csdata)
                GOTO(out, rc);
        }
 
-       rc = llog_cat_process(NULL, llh, changelog_show_cb, cs, 0, 0);
+       rc = llog_cat_process(NULL, llh, changelog_kkuc_cb, cs, 0, 0);
 
         /* Send EOF no matter what our result */
         if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch),
index 8a6f255..0947551 100644 (file)
@@ -1519,15 +1519,16 @@ int lr_replicate()
                 case CL_XATTR:
                         rc = lr_setxattr(info);
                         break;
-                case CL_CLOSE:
-                case CL_EXT:
-                case CL_OPEN:
-                case CL_IOCTL:
-                case CL_MARK:
-                        /* Nothing needs to be done for these entries */
-                default:
-                        break;
-                }
+               case CL_CLOSE:
+               case CL_EXT:
+               case CL_OPEN:
+               case CL_LAYOUT:
+               case CL_MARK:
+                       /* Nothing needs to be done for these entries */
+                       /* fallthrough */
+               default:
+                       break;
+               }
                DEBUG_EXIT(info, rc);
                 if (rc && rc != -ENOENT) {
                         lr_print_failure(info, rc);