From 5cdc35aa8411c5369b4018748aaaabdf7b1952e4 Mon Sep 17 00:00:00 2001 From: zhanghc Date: Thu, 19 Nov 2009 04:08:03 +0000 Subject: [PATCH] b=20354 the client_uuid(lcd_uuid) stored in last_rcvd on server(MDT or OST) could be corrupted, so it is needed to check during loading from disk i=johann@sun.com i=tappro@sun.com --- lustre/include/lustre_disk.h | 14 ++++++++++++++ lustre/mdt/mdt_recovery.c | 12 +++++++----- lustre/obdfilter/filter.c | 2 ++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 69baf77..336045b 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -295,6 +295,20 @@ struct lsd_client_data { __u8 lcd_padding[LR_CLIENT_SIZE - 128]; }; +/* bug20354: the lcd_uuid for export of clients may be wrong */ +static inline void check_lcd(char *obd_name, int index, + struct lsd_client_data *lcd) +{ + int length = sizeof(lcd->lcd_uuid); + if (strnlen((char*)lcd->lcd_uuid, length) == length) { + lcd->lcd_uuid[length - 1] = '\0'; + + LCONSOLE_ERROR("the client UUID (%s) on %s for exports" + "stored in last_rcvd(index = %d) is bad!\n", + lcd->lcd_uuid, obd_name, index); + } +} + /* last_rcvd handling */ static inline void lsd_le_to_cpu(struct lr_server_data *buf, struct lr_server_data *lsd) diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index 74bd70c..1709333 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -179,9 +179,9 @@ static int mdt_last_rcvd_header_write(const struct lu_env *env, RETURN(rc); } -static int mdt_last_rcvd_read(const struct lu_env *env, - struct mdt_device *mdt, - struct lsd_client_data *lcd, loff_t *off) +static int mdt_last_rcvd_read(const struct lu_env *env, struct mdt_device *mdt, + struct lsd_client_data *lcd, loff_t *off, + int index) { struct mdt_thread_info *mti; struct lsd_client_data *tmp; @@ -191,8 +191,10 @@ static int mdt_last_rcvd_read(const struct lu_env *env, tmp = &mti->mti_lcd; rc = dt_record_read(env, mdt->mdt_last_rcvd, mdt_buf(env, tmp, sizeof(*tmp)), off); - if (rc == 0) + if (rc == 0) { + check_lcd(mdt2obd_dev(mdt)->obd_name, index, tmp); lcd_le_to_cpu(tmp, lcd); + } CDEBUG(D_INFO, "read lcd @%d rc = %d, uuid = %s, last_transno = "LPU64 ", last_xid = "LPU64", last_result = %u, last_data = %u, " @@ -264,7 +266,7 @@ static int mdt_clients_data_init(const struct lu_env *env, off = lsd->lsd_client_start + cl_idx * lsd->lsd_client_size; - rc = mdt_last_rcvd_read(env, mdt, lcd, &off); + rc = mdt_last_rcvd_read(env, mdt, lcd, &off, cl_idx); if (rc) { CERROR("error reading MDS %s idx %d, off %llu: rc %d\n", LAST_RCVD, cl_idx, off, rc); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 929bac8..d5a4837 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -864,6 +864,8 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp) continue; } + check_lcd(obd->obd_name, cl_idx, lcd); + last_rcvd = le64_to_cpu(lcd->lcd_last_transno); /* These exports are cleaned up by filter_disconnect(), so they -- 1.8.3.1