From ed9bcdc5177f0a50cb322357ea94908c16c5038f Mon Sep 17 00:00:00 2001 From: tappro Date: Thu, 9 Jul 2009 18:19:58 +0000 Subject: [PATCH] Branch HEAD b=19669 i=adilger i=rread Handle compat/incompat flags properly --- lustre/include/lustre_disk.h | 12 ++++++++---- lustre/mdt/mdt_internal.h | 3 ++- lustre/mdt/mdt_recovery.c | 45 ++++++++++++++++++++++++++++++-------------- lustre/obdfilter/filter.c | 9 ++++++++- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 841eeeb..228cb06 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -222,6 +222,8 @@ struct lustre_mount_data { #define OBD_COMPAT_OST 0x00000002 /** COMPAT_146: this is an MDT (temporary) */ #define OBD_COMPAT_MDT 0x00000004 +/** 2.0 server, interop flag to show server version is changed */ +#define OBD_COMPAT_20 0x00000008 /** MDS handles LOV_OBJID file */ #define OBD_ROCOMPAT_LOVOBJID 0x00000001 @@ -236,10 +238,12 @@ struct lustre_mount_data { #define OBD_INCOMPAT_COMMON_LR 0x00000008 /** FID is enabled */ #define OBD_INCOMPAT_FID 0x00000010 -/** lustre disk using iam format to store directory entries */ -#define OBD_INCOMPAT_IAM_DIR 0x00000020 -/** 2.0 server, interop flag to show server is changed */ -#define OBD_INCOMPAT_20 0x00000040 +/** Size-on-MDS is enabled */ +#define OBD_INCOMPAT_SOM 0x00000020 +/** filesystem using iam format to store directory entries */ +#define OBD_INCOMPAT_IAM_DIR 0x00000040 +/** LMA attribute contains per-inode incompatible flags */ +#define OBD_INCOMPAT_LMA 0x00000080 /* Data stored per server at the head of the last_rcvd file. In le32 order. diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 1195605..ef19cc5 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -178,7 +178,8 @@ struct mdt_device { #define MDT_SERVICE_WATCHDOG_FACTOR (2) #define MDT_ROCOMPAT_SUPP (OBD_ROCOMPAT_LOVOBJID) -#define MDT_INCOMPAT_SUPP (OBD_INCOMPAT_MDT | OBD_INCOMPAT_COMMON_LR) +#define MDT_INCOMPAT_SUPP (OBD_INCOMPAT_MDT | OBD_INCOMPAT_COMMON_LR | \ + OBD_INCOMPAT_FID | OBD_INCOMPAT_IAM_DIR) #define MDT_COS_DEFAULT (1) struct mdt_object { diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index 21fe440..f74b694 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -415,9 +415,10 @@ static int mdt_server_data_init(const struct lu_env *env, lsd->lsd_server_size = LR_SERVER_SIZE; lsd->lsd_client_start = LR_CLIENT_START; lsd->lsd_client_size = LR_CLIENT_SIZE; + lsd->lsd_feature_compat = OBD_COMPAT_MDT; lsd->lsd_feature_rocompat = OBD_ROCOMPAT_LOVOBJID; lsd->lsd_feature_incompat = OBD_INCOMPAT_MDT | - OBD_INCOMPAT_COMMON_LR; + OBD_INCOMPAT_COMMON_LR; } else { LCONSOLE_WARN("%s: used disk, loading\n", obd->obd_name); rc = mdt_last_rcvd_header_read(env, mdt); @@ -432,27 +433,43 @@ static int mdt_server_data_init(const struct lu_env *env, obd->obd_uuid.uuid, lsd->lsd_uuid); GOTO(out, rc = -EINVAL); } - - /** evict all clients as it is first boot with old last_rcvd */ - if (!(lsd->lsd_feature_incompat & OBD_INCOMPAT_20)) { - LCONSOLE_WARN("Mounting %s at first time on old FS, " - "remove all clients for interop needs\n", - obd->obd_name); - simple_truncate(lsi->lsi_srv_mnt->mnt_sb->s_root, - lsi->lsi_srv_mnt, LAST_RCVD, - lsd->lsd_client_start); - last_rcvd_size = lsd->lsd_client_start; - } + lsd->lsd_feature_compat |= OBD_COMPAT_MDT; + lsd->lsd_feature_incompat |= OBD_INCOMPAT_MDT | + OBD_INCOMPAT_COMMON_LR; } mount_count = lsd->lsd_mount_count; ldd = lsi->lsi_ldd; + if (lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP) { + CERROR("%s: unsupported incompat filesystem feature(s) %x\n", + obd->obd_name, + lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP); + GOTO(out, rc = -EINVAL); + } + if (lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP) { + CERROR("%s: unsupported read-only filesystem feature(s) %x\n", + obd->obd_name, + lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP); + /* XXX: Do something like remount filesystem read-only */ + GOTO(out, rc = -EINVAL); + } + /** Interop: evict all clients at first boot with 1.8 last_rcvd */ + if (!(lsd->lsd_feature_compat & OBD_COMPAT_20)) { + LCONSOLE_WARN("Mounting %s at first time on 1.8 FS, remove all" + " clients for interop needs\n", obd->obd_name); + simple_truncate(lsi->lsi_srv_mnt->mnt_sb->s_root, + lsi->lsi_srv_mnt, LAST_RCVD, + lsd->lsd_client_start); + last_rcvd_size = lsd->lsd_client_start; + /** set 2.0 flag to upgrade/downgrade between 1.8 and 2.0 */ + lsd->lsd_feature_compat |= OBD_COMPAT_20; + } + if (ldd->ldd_flags & LDD_F_IAM_DIR) lsd->lsd_feature_incompat |= OBD_INCOMPAT_IAM_DIR; - lsd->lsd_feature_compat = 0; - lsd->lsd_feature_incompat |= OBD_INCOMPAT_FID | OBD_INCOMPAT_20; + lsd->lsd_feature_incompat |= OBD_INCOMPAT_FID; spin_lock(&mdt->mdt_transno_lock); mdt->mdt_last_transno = lsd->lsd_last_transno; diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 570dc00..8fc2f31 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -754,7 +754,10 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp) fsd->lsd_client_size = cpu_to_le16(LR_CLIENT_SIZE); fsd->lsd_subdir_count = cpu_to_le16(FILTER_SUBDIR_COUNT); filter->fo_subdir_count = FILTER_SUBDIR_COUNT; - fsd->lsd_feature_incompat = cpu_to_le32(OBD_INCOMPAT_OST); + /* OBD_COMPAT_OST is set in filter_connect_internal when the + * MDS first connects and assigns the OST index number. */ + fsd->lsd_feature_incompat = cpu_to_le32(OBD_INCOMPAT_COMMON_LR| + OBD_INCOMPAT_OST); } else { rc = fsfilt_read_record(obd, filp, fsd, sizeof(*fsd), &off); if (rc) { @@ -777,6 +780,10 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp) cpu_to_le32(OBD_INCOMPAT_COMMON_LR))) fsd->lsd_last_transno = fsd->lsd_compat14; /* end COMPAT_146 */ + /* OBD_COMPAT_OST is set in filter_connect_internal when the + * MDS first connects and assigns the OST index number. */ + fsd->lsd_feature_incompat |= cpu_to_le32(OBD_INCOMPAT_COMMON_LR| + OBD_INCOMPAT_OST); } if (fsd->lsd_feature_incompat & ~cpu_to_le32(FILTER_INCOMPAT_SUPP)) { -- 1.8.3.1