From 8c29d626f49a15114aa3e5a4dcbcd79ec2c310ba Mon Sep 17 00:00:00 2001
From: bobijam <bobijam>
Date: Mon, 26 Mar 2007 04:25:10 +0000
Subject: [PATCH] Branch HEAD b=11090 Description: Be more lenient with linux
 clients before warning (by Andreas) Details: This fixes Linux clients so they
 allow one major Lustre release update          before they warn.  It also
 makes the setting of the version a lot          easier by using
 OBD_OCD_VERSION(0,0,1,32) instead of having to calculate          it
 directly.

---
 lustre/autoconf/lustre-version.ac | 17 +++++++----
 lustre/include/lustre_ver.h.in    | 25 +++++++++++-----
 lustre/ptlrpc/import.c            | 48 +++++++++++++++----------------
 3 files changed, 53 insertions(+), 37 deletions(-)

diff --git a/lustre/autoconf/lustre-version.ac b/lustre/autoconf/lustre-version.ac
index 527dadc79d..72efbd612d 100644
--- a/lustre/autoconf/lustre-version.ac
+++ b/lustre/autoconf/lustre-version.ac
@@ -3,10 +3,13 @@ m4_define([LUSTRE_MINOR],[6])
 m4_define([LUSTRE_PATCH],[0])
 m4_define([LUSTRE_FIX],[0])
 
-dnl # 288 stands for 0.0.1.32 , next version with fixes is ok, but next after
-dnl # next release candidate/beta would spill this warning already.
-m4_define([LUSTRE_VER_ALLOWED_OFFSET],[288])
-m4_define([LUSTRE_VER_OFFSET_WARN],[288])
+dnl # liblustre delta is 0.0.1.32 , next version with fixes is ok, but
+dnl # after following release candidate/beta would spill this warning already.
+m4_define([LUSTRE_VER_ALLOWED_OFFSET],["OBD_OCD_VERSION(0,0,1,32)"])
+m4_define([LUSTRE_LIB_VER_OFFSET_WARN],["OBD_OCD_VERSION(0,0,1,32)"])
+
+dnl # linux lustre delta is 0.2.0.0 , next major release version is ok
+m4_define([LUSTRE_CLI_VER_OFFSET_WARN],["OBD_OCD_VERSION(0,2,0,0)"])
 
 dnl # User editable part ends here. -----------------------------------------
 
@@ -19,7 +22,8 @@ m4_define([LUSTRE_VERSION],m4_if(LUSTRE_FIX,[0],LUSTRE_MAJOR.LUSTRE_MINOR.LUSTRE
 [AC_LUSTRE_FIX]=LUSTRE_FIX
 [AC_LUSTRE_VERSION_STRING]=LUSTRE_VERSION
 [AC_LUSTRE_VER_ALLOWED_OFFSET]=LUSTRE_VER_ALLOWED_OFFSET
-[AC_LUSTRE_VER_OFFSET_WARN]=LUSTRE_VER_OFFSET_WARN
+[AC_LUSTRE_LIB_VER_OFFSET_WARN]=LUSTRE_LIB_VER_OFFSET_WARN
+[AC_LUSTRE_CLI_VER_OFFSET_WARN]=LUSTRE_CLI_VER_OFFSET_WARN
 
 AC_SUBST([AC_LUSTRE_MAJOR])
 AC_SUBST([AC_LUSTRE_MINOR])
@@ -27,4 +31,5 @@ AC_SUBST([AC_LUSTRE_PATCH])
 AC_SUBST([AC_LUSTRE_FIX])
 AC_SUBST([AC_LUSTRE_VERSION_STRING])
 AC_SUBST([AC_LUSTRE_VER_ALLOWED_OFFSET])
-AC_SUBST([AC_LUSTRE_VER_OFFSET_WARN])
+AC_SUBST([AC_LUSTRE_LIB_VER_OFFSET_WARN])
+AC_SUBST([AC_LUSTRE_CLI_VER_OFFSET_WARN])
diff --git a/lustre/include/lustre_ver.h.in b/lustre/include/lustre_ver.h.in
index 5881c4f95d..1c63510944 100644
--- a/lustre/include/lustre_ver.h.in
+++ b/lustre/include/lustre_ver.h.in
@@ -1,5 +1,8 @@
 #ifndef _LUSTRE_VER_H_
 #define _LUSTRE_VER_H_
+/* This file automatically generated from lustre/include/lustre_ver.h.in,
+ * based on parameters in lustre/autoconf/lustre-version.ac.
+ * Changes made directly to this file will be lost. */
 
 #define LUSTRE_MAJOR @AC_LUSTRE_MAJOR@
 #define LUSTRE_MINOR @AC_LUSTRE_MINOR@
@@ -7,15 +10,23 @@
 #define LUSTRE_FIX @AC_LUSTRE_FIX@
 #define LUSTRE_VERSION_STRING "@AC_LUSTRE_VERSION_STRING@"
 
-// liblustre clients are only allowed to connect if their LUSTRE_FIX mismatches
-// by this amount (set in lustre/autoconf/lustre-version.ac)
+#define LUSTRE_VERSION_CODE OBD_OCD_VERSION(LUSTRE_MAJOR,LUSTRE_MINOR,LUSTRE_PATCH,LUSTRE_FIX)
+
+/* liblustre clients are only allowed to connect if their LUSTRE_FIX mismatches
+ * by this amount (set in lustre/autoconf/lustre-version.ac). */
 #define LUSTRE_VERSION_ALLOWED_OFFSET @AC_LUSTRE_VER_ALLOWED_OFFSET@
 
-// if lustre version of client and servers it connects to differs by more than
-// this amount, client would issue a warning
-// (set in lustre/autoconf/lustre-version.ac)
-#define LUSTRE_VERSION_OFFSET_WARN @AC_LUSTRE_VER_OFFSET_WARN@
+#ifdef __KERNEL__
+/* If lustre version of client and servers it connects to differs by more
+ * than this amount, client would issue a warning.
+ * (set in lustre/autoconf/lustre-version.ac) */
+#define LUSTRE_VERSION_OFFSET_WARN @AC_LUSTRE_CLI_VER_OFFSET_WARN@
+#else
+/* If liblustre version of client and servers it connects to differs by more
+ * than this amount, client would issue a warning.
+ * (set in lustre/autoconf/lustre-version.ac) */
+#define LUSTRE_VERSION_OFFSET_WARN @AC_LUSTRE_LIB_VER_OFFSET_WARN@
+#endif
 
-#define LUSTRE_VERSION_CODE OBD_OCD_VERSION(LUSTRE_MAJOR,LUSTRE_MINOR,LUSTRE_PATCH,LUSTRE_FIX)
 
 #endif
diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c
index c3fbc7da5a..2d96ad770a 100644
--- a/lustre/ptlrpc/import.c
+++ b/lustre/ptlrpc/import.c
@@ -696,21 +696,23 @@ finish:
                         /* Sigh, some compilers do not like #ifdef in the middle
                            of macro arguments */
 #ifdef __KERNEL__
-                        const char *action = "upgrading this client";
+                        const char *older =
+                                "older.  Consider upgrading this client";
 #else
-                        const char *action = "recompiling this application";
+                        const char *older =
+                                "older.  Consider recompiling this application";
 #endif
+                        const char *newer = "newer than client version";
 
-                        CWARN("Server %s version (%d.%d.%d.%d) is much %s. "
-                              "Consider %s (%s).\n",
-                              obd2cli_tgt(imp->imp_obd),
-                              OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
-                              OBD_OCD_VERSION_MINOR(ocd->ocd_version),
-                              OBD_OCD_VERSION_PATCH(ocd->ocd_version),
-                              OBD_OCD_VERSION_FIX(ocd->ocd_version),
-                              ocd->ocd_version > LUSTRE_VERSION_CODE ?
-                              "newer" : "older",
-                              action, LUSTRE_VERSION_STRING);
+                        LCONSOLE_WARN("Server %s version (%d.%d.%d.%d) "
+                                      "is much %s (%s)\n",
+                                      obd2cli_tgt(imp->imp_obd),
+                                      OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
+                                      OBD_OCD_VERSION_MINOR(ocd->ocd_version),
+                                      OBD_OCD_VERSION_PATCH(ocd->ocd_version),
+                                      OBD_OCD_VERSION_FIX(ocd->ocd_version),
+                                      ocd->ocd_version > LUSTRE_VERSION_CODE ?
+                                      newer : older, LUSTRE_VERSION_STRING);
                 }
 
                 if (ocd->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) {
@@ -745,18 +747,16 @@ finish:
                            /* Actually servers are only supposed to refuse
                               connection from liblustre clients, so we should
                               never see this from VFS context */
-                                CERROR("Server %s version (%d.%d.%d.%d) "
-                                       "refused connection from this client "
-                                       "as too %s version (%s).  Client must "
-                                       "be recompiled\n",
-                                      obd2cli_tgt(imp->imp_obd),
-                                      OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
-                                      OBD_OCD_VERSION_MINOR(ocd->ocd_version),
-                                      OBD_OCD_VERSION_PATCH(ocd->ocd_version),
-                                      OBD_OCD_VERSION_FIX(ocd->ocd_version),
-                                      ocd->ocd_version > LUSTRE_VERSION_CODE ?
-                                      "old" : "new",
-                                      LUSTRE_VERSION_STRING);
+                                LCONSOLE_ERROR("Server %s version (%d.%d.%d.%d)"
+                                        " refused connection from this client "
+                                        "with an incompatible version (%s).  "
+                                        "Client must be recompiled\n",
+                                        obd2cli_tgt(imp->imp_obd),
+                                        OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
+                                        OBD_OCD_VERSION_MINOR(ocd->ocd_version),
+                                        OBD_OCD_VERSION_PATCH(ocd->ocd_version),
+                                        OBD_OCD_VERSION_FIX(ocd->ocd_version),
+                                        LUSTRE_VERSION_STRING);
                                 ptlrpc_deactivate_import(imp);
                                 IMPORT_SET_STATE(imp, LUSTRE_IMP_CLOSED);
                         }
-- 
GitLab