Whamcloud - gitweb
LU-17217 obd: reserve server-side connection policy bits 93/52793/2
authorTimothy Day <timday@amazon.com>
Wed, 18 Oct 2023 17:00:39 +0000 (17:00 +0000)
committerOleg Drokin <green@whamcloud.com>
Mon, 4 Mar 2024 20:02:47 +0000 (20:02 +0000)
Reserve bits for new mechanism enabling server to refuse
client connections based on arbitrary criterion that Lustre
admins can define via policies.

The policies envisioned currently are:
ALLOW (allow connection to procede as normal)
WARN (generate a warning on the client-side)
SOFT_BLOCK (block mounting unless client overrides)
HARD_BLOCK (block mounting entirely)

In order to SOFT_BLOCK a client, servers need to be able to
differentiate between clients that support scp and those that
don't scp. Older clients would not have the mechanism to
override a server-side SOFT_BLOCK, so they would HARD_BLOCK
instead.

We also need a bitmask for the client/server to communciate
policy opinions (i.e. don't soft-block me).

Therefore, this patch reserves:
1) OBD_CONNECT2_CONN_POLICY
2) 8 bits of obd_connect_data

It also explicitly defines the use of some of the bits
via an enum.

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: If717045728e516eece7c2d812f8ee6e7ebba9497
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52793
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/obdclass/lprocfs_status.c
lustre/ptlrpc/wiretest.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index 3b012b8..5630acb 100644 (file)
@@ -865,6 +865,7 @@ struct ptlrpc_body_v2 {
  * ignored for ldiskfs servers
  */
 #define OBD_CONNECT2_UNALIGNED_DIO     0x400000000ULL /* unaligned DIO */
+#define OBD_CONNECT2_CONN_POLICY       0x800000000ULL /* server-side connection policy */
 /* XXX README XXX README XXX README XXX README XXX README XXX README XXX
  * Please DO NOT add OBD_CONNECT flags before first ensuring that this value
  * is not in use by some other branch/patch.  Email adilger@whamcloud.com
@@ -1006,7 +1007,8 @@ struct obd_connect_data {
         * may result in out-of-bound memory access and kernel oops.
         */
        __u16 ocd_maxmodrpcs;    /* Maximum modify RPCs in parallel */
-       __u16 padding0;          /* READ BELOW! also fix lustre_swab_connect */
+       __u8  ocd_conn_policy;   /* bitmask for client/server to communicate about policy */
+       __u8  padding0;          /* READ BELOW! also fix lustre_swab_connect */
        __u32 padding1;          /* READ BELOW! also fix lustre_swab_connect */
        __u64 ocd_connect_flags2;/* OBD_CONNECT2_* per above */
        __u64 ocd_compr_type;    /* bitmask of supported compression types */
@@ -1068,6 +1070,15 @@ enum cksum_types {
 #define OBD_CKSUM_T10_TOP OBD_CKSUM_ADLER
 
 /*
+ * Explicitly define the meaning of the bits in ocd_conn_policy,
+ * for server-side connection policy.
+ */
+enum conn_policy_flags {
+       BYPASS_SOFT_BLOCK = 0,
+       CONN_POLICY_FLAGS_NUM = 8,
+};
+
+/*
  *   OST requests: OBDO & OBD request records
  */
 
index 3aa4b9e..c2305b9 100644 (file)
@@ -658,6 +658,7 @@ static const char *const obd_connect_names[] = {
        "large_nid",                    /* 0x100000000 */
        "compressed_file",              /* 0x200000000 */
        "unaligned_dio",                /* 0x400000000 */
+       "conn_policy",                  /* 0x800000000 */
        NULL
 };
 
index fca228a..5cafbf3 100644 (file)
@@ -1207,9 +1207,13 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obd_connect_data, ocd_maxmodrpcs));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_maxmodrpcs) == 2, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_maxmodrpcs));
-       LASSERTF((int)offsetof(struct obd_connect_data, padding0) == 74, "found %lld\n",
+       LASSERTF((int)offsetof(struct obd_connect_data, ocd_conn_policy) == 74, "found %lld\n",
+                (long long)(int)offsetof(struct obd_connect_data, ocd_conn_policy));
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_conn_policy) == 1, "found %lld\n",
+                (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_conn_policy));
+       LASSERTF((int)offsetof(struct obd_connect_data, padding0) == 75, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding0));
-       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 2, "found %lld\n",
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 1, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->padding0));
        LASSERTF((int)offsetof(struct obd_connect_data, padding1) == 76, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding1));
@@ -1459,6 +1463,8 @@ void lustre_assert_wire_constants(void)
                 OBD_CONNECT2_COMPRESS);
        LASSERTF(OBD_CONNECT2_UNALIGNED_DIO == 0x400000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT2_UNALIGNED_DIO);
+       LASSERTF(OBD_CONNECT2_CONN_POLICY == 0x800000000ULL, "found 0x%.16llxULL\n",
+                OBD_CONNECT2_CONN_POLICY);
 
        LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",
                (unsigned)OBD_CKSUM_CRC32);
index 1cdf551..6c6b62c 100644 (file)
@@ -572,6 +572,7 @@ check_obd_connect_data(void)
        CHECK_MEMBER(obd_connect_data, ocd_instance);
        CHECK_MEMBER(obd_connect_data, ocd_maxbytes);
        CHECK_MEMBER(obd_connect_data, ocd_maxmodrpcs);
+       CHECK_MEMBER(obd_connect_data, ocd_conn_policy);
        CHECK_MEMBER(obd_connect_data, padding0);
        CHECK_MEMBER(obd_connect_data, padding1);
        CHECK_MEMBER(obd_connect_data, ocd_connect_flags2);
@@ -684,6 +685,7 @@ check_obd_connect_data(void)
        CHECK_DEFINE_64X(OBD_CONNECT2_LARGE_NID);
        CHECK_DEFINE_64X(OBD_CONNECT2_COMPRESS);
        CHECK_DEFINE_64X(OBD_CONNECT2_UNALIGNED_DIO);
+       CHECK_DEFINE_64X(OBD_CONNECT2_CONN_POLICY);
 
        BLANK_LINE();
        CHECK_VALUE_X(OBD_CKSUM_CRC32);
index 72dee0d..c320e4b 100644 (file)
@@ -1232,9 +1232,13 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obd_connect_data, ocd_maxmodrpcs));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_maxmodrpcs) == 2, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_maxmodrpcs));
-       LASSERTF((int)offsetof(struct obd_connect_data, padding0) == 74, "found %lld\n",
+       LASSERTF((int)offsetof(struct obd_connect_data, ocd_conn_policy) == 74, "found %lld\n",
+                (long long)(int)offsetof(struct obd_connect_data, ocd_conn_policy));
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_conn_policy) == 1, "found %lld\n",
+                (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_conn_policy));
+       LASSERTF((int)offsetof(struct obd_connect_data, padding0) == 75, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding0));
-       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 2, "found %lld\n",
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 1, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->padding0));
        LASSERTF((int)offsetof(struct obd_connect_data, padding1) == 76, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding1));
@@ -1484,6 +1488,8 @@ void lustre_assert_wire_constants(void)
                 OBD_CONNECT2_COMPRESS);
        LASSERTF(OBD_CONNECT2_UNALIGNED_DIO == 0x400000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT2_UNALIGNED_DIO);
+       LASSERTF(OBD_CONNECT2_CONN_POLICY == 0x800000000ULL, "found 0x%.16llxULL\n",
+                OBD_CONNECT2_CONN_POLICY);
 
        LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",
                (unsigned)OBD_CKSUM_CRC32);