From 0387ed387892fec445e45305f6f70c1d194d3b03 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 10 May 2013 00:07:31 -0600 Subject: [PATCH] LU-3279 changelog: fix CL_LAYOUT, accept all types 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 Change-Id: Id8e6471827a89d8c62808e6b3cfd9693d63ebbe5 Reviewed-on: http://review.whamcloud.com/6335 Tested-by: Hudson Tested-by: Maloo Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_user.h | 13 ++++++++----- lustre/mdc/mdc_request.c | 18 ++++++++++-------- lustre/utils/lustre_rsync.c | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index a40ea46..a06d160 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -490,7 +490,7 @@ 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_LAYOUT = 12, /* file layout/striping modified */ CL_TRUNC = 13, CL_SETATTR = 14, CL_XATTR = 15, @@ -501,11 +501,14 @@ enum changelog_rec_type { CL_LAST }; -static inline const char *changelog_type2str(int type) { - static const char *changelog_str[] = { +static inline const char *changelog_type2str(int type) +{ + static const char const *changelog_str[] = { "MARK", "CREAT", "MKDIR", "HLINK", "SLINK", "MKNOD", "UNLNK", - "RMDIR", "RENME", "RNMTO", "OPEN", "CLOSE", "IOCTL", "TRUNC", - "SATTR", "XATTR", "HSM", "MTIME", "CTIME", "ATIME" }; + "RMDIR", "RENME", "RNMTO", "OPEN", "CLOSE", "LYOUT", "TRUNC", + "SATTR", "XATTR", "HSM", "MTIME", "CTIME", "ATIME", + }; + if (type >= 0 && type < CL_LAST) return changelog_str[type]; return NULL; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 21ef468..a048f7b 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1227,7 +1227,7 @@ struct changelog_show { struct obd_device *cs_obd; }; -static int changelog_show_cb(struct llog_handle *llh, struct llog_rec_hdr *hdr, +static int changelog_kkuc_cb(struct llog_handle *llh, struct llog_rec_hdr *hdr, void *data) { struct changelog_show *cs = data; @@ -1236,11 +1236,12 @@ static int changelog_show_cb(struct llog_handle *llh, struct llog_rec_hdr *hdr, 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) { @@ -1297,7 +1298,8 @@ static int mdc_changelog_send_thread(void *csdata) GOTO(out, rc = -ENOENT); rc = llog_create(ctxt, &llh, NULL, CHANGELOG_CATALOG); if (rc) { - CERROR("llog_create() failed %d\n", rc); + CERROR("%s: fail to open changelog catalog: rc = %d\n", + cs->cs_obd->obd_name, rc); GOTO(out, rc); } rc = llog_init_handle(llh, LLOG_F_IS_CAT, NULL); @@ -1306,7 +1308,7 @@ static int mdc_changelog_send_thread(void *csdata) GOTO(out, rc); } - rc = llog_cat_process_flags(llh, changelog_show_cb, cs, 0, 0, 0); + rc = llog_cat_process_flags(llh, changelog_kkuc_cb, cs, 0, 0, 0); /* Send EOF no matter what our result */ if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch), diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index e654369..fbc4896 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -1495,7 +1495,7 @@ int lr_replicate() case CL_CLOSE: case CL_EXT: case CL_OPEN: - case CL_IOCTL: + case CL_LAYOUT: case CL_MARK: /* Nothing needs to be done for these entries */ default: -- 1.8.3.1