Whamcloud - gitweb
LU-5319 ptlrpc: Add OBD_CONNECT_MULTIMODRPCS flag 60/13960/6
authorGregoire Pichon <gregoire.pichon@bull.net>
Wed, 3 Sep 2014 08:53:00 +0000 (10:53 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 31 Mar 2015 13:42:59 +0000 (13:42 +0000)
The new OBD_CONNECT_MULTIMODRPCS connection flag indicates the support
of multiple modify RPCs in parallel. It can be specified by the client
within the connection request and by the server within the connection
reply.
The new ocd_maxmodrpcs connection data specifies the maximum modify
RPCs in parallel supported by the server.

To allow the MDS to send the new ocd_maxmodrpcs field, it has been
required to modify RMF_CONNECT_DATA so that its size includes the new
field. This change leads to remove the ocd_connect_data_v1 structure.
Note that the client has been allocating an extra 16*sizeof(__u64) for
the obd_connect_data reply since 2.0 (commit fd908da9, and even in
later versions of 1.8) so there is no problem for the MDS to just send
the full reply size.

This patch fixes a bug in __req_capsule_get() since it wasn't checking
RMF_F_NO_SIZE_CHECK when receiving the message. This allows legacy
clients (with version lower that this commit) to send connection
request with ocd_connect_data structure size smaller (actually size is
ocd_connect_data_v1 structure size) than new server ocd_connect_data
structure size.

This patch also fixes a bug in the routine that displays the import's
connect data.

Signed-off-by: Gregoire Pichon <gregoire.pichon@bull.net>
Change-Id: I4b8a567241f8986d967240efff94c7f407fdd864
Reviewed-on: http://review.whamcloud.com/13960
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
lustre/include/lustre/lustre_idl.h
lustre/obdclass/lprocfs_status.c
lustre/ptlrpc/layout.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/wiretest.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index b1e5284..0a4e6cf 100644 (file)
@@ -1355,6 +1355,8 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                                       name in request */
 #define OBD_CONNECT_LFSCK      0x40000000000000ULL/* support online LFSCK */
 #define OBD_CONNECT_UNLINK_CLOSE 0x100000000000000ULL/* close file in unlink */
                                                       name in request */
 #define OBD_CONNECT_LFSCK      0x40000000000000ULL/* support online LFSCK */
 #define OBD_CONNECT_UNLINK_CLOSE 0x100000000000000ULL/* close file in unlink */
+#define OBD_CONNECT_MULTIMODRPCS 0x200000000000000ULL /* support multiple modify
+                                                        RPCs in parallel */
 #define OBD_CONNECT_DIR_STRIPE  0x400000000000000ULL /* striped DNE dir */
 
 /* XXX README XXX:
 #define OBD_CONNECT_DIR_STRIPE  0x400000000000000ULL /* striped DNE dir */
 
 /* XXX README XXX:
@@ -1434,25 +1436,6 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
  *
  * If we eventually have separate connect data for different types, which we
  * almost certainly will, then perhaps we stick a union in here. */
  *
  * If we eventually have separate connect data for different types, which we
  * almost certainly will, then perhaps we stick a union in here. */
-struct obd_connect_data_v1 {
-       __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
-       __u32 ocd_version;       /* lustre release version number */
-       __u32 ocd_grant;         /* initial cache grant amount (bytes) */
-       __u32 ocd_index;         /* LOV index to connect to */
-       __u32 ocd_brw_size;      /* Maximum BRW size in bytes, must be 2^n */
-        __u64 ocd_ibits_known;   /* inode bits this client understands */
-        __u8  ocd_blocksize;     /* log2 of the backend filesystem blocksize */
-        __u8  ocd_inodespace;    /* log2 of the per-inode space consumption */
-        __u16 ocd_grant_extent;  /* per-extent grant overhead, in 1K blocks */
-        __u32 ocd_unused;        /* also fix lustre_swab_connect */
-        __u64 ocd_transno;       /* first transno from client to be replayed */
-        __u32 ocd_group;         /* MDS group on OST */
-        __u32 ocd_cksum_types;   /* supported checksum algorithms */
-        __u32 ocd_max_easize;    /* How big LOV EA can be on MDS */
-        __u32 ocd_instance;      /* also fix lustre_swab_connect */
-        __u64 ocd_maxbytes;      /* Maximum stripe size in bytes */
-};
-
 struct obd_connect_data {
        __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
        __u32 ocd_version;       /* lustre release version number */
 struct obd_connect_data {
        __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
        __u32 ocd_version;       /* lustre release version number */
@@ -1474,7 +1457,9 @@ struct obd_connect_data {
          * if the corresponding flag in ocd_connect_flags is set. Accessing
          * any field after ocd_maxbytes on the receiver without a valid flag
          * may result in out-of-bound memory access and kernel oops. */
          * if the corresponding flag in ocd_connect_flags is set. Accessing
          * any field after ocd_maxbytes on the receiver without a valid flag
          * may result in out-of-bound memory access and kernel oops. */
-        __u64 padding1;          /* added 2.1.0. also fix lustre_swab_connect */
+       __u16 ocd_maxmodrpcs;    /* Maximum modify RPCs in parallel */
+       __u16 padding0;          /* added 2.1.0. also fix lustre_swab_connect */
+       __u32 padding1;          /* added 2.1.0. also fix lustre_swab_connect */
         __u64 padding2;          /* added 2.1.0. also fix lustre_swab_connect */
         __u64 padding3;          /* added 2.1.0. also fix lustre_swab_connect */
         __u64 padding4;          /* added 2.1.0. also fix lustre_swab_connect */
         __u64 padding2;          /* added 2.1.0. also fix lustre_swab_connect */
         __u64 padding3;          /* added 2.1.0. also fix lustre_swab_connect */
         __u64 padding4;          /* added 2.1.0. also fix lustre_swab_connect */
index 3f4c432..02764bd 100644 (file)
@@ -650,7 +650,7 @@ static const char *obd_connect_names[] = {
        "lfsck",
        "unknown",
        "unlink_close",
        "lfsck",
        "unknown",
        "unlink_close",
-       "unknown",
+       "multi_mod_rpcs",
        "dir_stripe",
        "unknown",
        NULL
        "dir_stripe",
        "unknown",
        NULL
@@ -695,7 +695,7 @@ EXPORT_SYMBOL(obd_connect_flags2str);
 static void obd_connect_data_seqprint(struct seq_file *m,
                                      struct obd_connect_data *ocd)
 {
 static void obd_connect_data_seqprint(struct seq_file *m,
                                      struct obd_connect_data *ocd)
 {
-       int flags;
+       __u64 flags;
 
        LASSERT(ocd != NULL);
        flags = ocd->ocd_connect_flags;
 
        LASSERT(ocd != NULL);
        flags = ocd->ocd_connect_flags;
@@ -740,6 +740,9 @@ static void obd_connect_data_seqprint(struct seq_file *m,
        if (flags & OBD_CONNECT_MAXBYTES)
                seq_printf(m, "       max_object_bytes: "LPU64"\n",
                              ocd->ocd_maxbytes);
        if (flags & OBD_CONNECT_MAXBYTES)
                seq_printf(m, "       max_object_bytes: "LPU64"\n",
                              ocd->ocd_maxbytes);
+       if (flags & OBD_CONNECT_MULTIMODRPCS)
+               seq_printf(m, "       max_mod_rpcs: %hu\n",
+                             ocd->ocd_maxmodrpcs);
 }
 
 int lprocfs_import_seq_show(struct seq_file *m, void *data)
 }
 
 int lprocfs_import_seq_show(struct seq_file *m, void *data)
index 48338ff..eec818c 100644 (file)
@@ -1004,18 +1004,7 @@ EXPORT_SYMBOL(RMF_CONN);
 struct req_msg_field RMF_CONNECT_DATA =
        DEFINE_MSGF("cdata",
                    RMF_F_NO_SIZE_CHECK /* we allow extra space for interop */,
 struct req_msg_field RMF_CONNECT_DATA =
        DEFINE_MSGF("cdata",
                    RMF_F_NO_SIZE_CHECK /* we allow extra space for interop */,
-#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 7, 53, 0)
                    sizeof(struct obd_connect_data),
                    sizeof(struct obd_connect_data),
-#else
-/* For interoperability with 1.8 and 2.0 clients/servers.
- * The RPC verification code allows larger RPC buffers, but not
- * smaller buffers.  Until we no longer need to keep compatibility
- * with older servers/clients we can only check that the buffer
- * size is at least as large as obd_connect_data_v1.  That is not
- * not in itself harmful, since the chance of just corrupting this
- * field is low.  See JIRA LU-16 for details. */
-                   sizeof(struct obd_connect_data_v1),
-#endif
                    lustre_swab_connect, NULL);
 EXPORT_SYMBOL(RMF_CONNECT_DATA);
 
                    lustre_swab_connect, NULL);
 EXPORT_SYMBOL(RMF_CONNECT_DATA);
 
@@ -2002,18 +1991,19 @@ static void *__req_capsule_get(struct req_capsule *pill,
         getter = (field->rmf_flags & RMF_F_STRING) ?
                 (typeof(getter))lustre_msg_string : lustre_msg_buf;
 
         getter = (field->rmf_flags & RMF_F_STRING) ?
                 (typeof(getter))lustre_msg_string : lustre_msg_buf;
 
-        if (field->rmf_flags & RMF_F_STRUCT_ARRAY) {
-                /*
-                 * We've already asserted that field->rmf_size > 0 in
-                 * req_layout_init().
-                 */
-                len = lustre_msg_buflen(msg, offset);
-                if ((len % field->rmf_size) != 0) {
-                        CERROR("%s: array field size mismatch "
+       if (field->rmf_flags & (RMF_F_STRUCT_ARRAY|RMF_F_NO_SIZE_CHECK)) {
+               /*
+                * We've already asserted that field->rmf_size > 0 in
+                * req_layout_init().
+                */
+               len = lustre_msg_buflen(msg, offset);
+               if (!(field->rmf_flags & RMF_F_NO_SIZE_CHECK) &&
+                   (len % field->rmf_size) != 0) {
+                       CERROR("%s: array field size mismatch "
                                "%d modulo %u != 0 (%d)\n",
                                field->rmf_name, len, field->rmf_size, loc);
                                "%d modulo %u != 0 (%d)\n",
                                field->rmf_name, len, field->rmf_size, loc);
-                        return NULL;
-                }
+                       return NULL;
+               }
         } else if (pill->rc_area[loc][offset] != -1) {
                 len = pill->rc_area[loc][offset];
         } else {
         } else if (pill->rc_area[loc][offset] != -1) {
                 len = pill->rc_area[loc][offset];
         } else {
index f081081..dcab780 100644 (file)
@@ -1670,6 +1670,9 @@ void lustre_swab_connect(struct obd_connect_data *ocd)
                 __swab32s(&ocd->ocd_max_easize);
         if (ocd->ocd_connect_flags & OBD_CONNECT_MAXBYTES)
                 __swab64s(&ocd->ocd_maxbytes);
                 __swab32s(&ocd->ocd_max_easize);
         if (ocd->ocd_connect_flags & OBD_CONNECT_MAXBYTES)
                 __swab64s(&ocd->ocd_maxbytes);
+       if (ocd->ocd_connect_flags & OBD_CONNECT_MULTIMODRPCS)
+               __swab16s(&ocd->ocd_maxmodrpcs);
+       CLASSERT(offsetof(typeof(*ocd), padding0) != 0);
         CLASSERT(offsetof(typeof(*ocd), padding1) != 0);
         CLASSERT(offsetof(typeof(*ocd), padding2) != 0);
         CLASSERT(offsetof(typeof(*ocd), padding3) != 0);
         CLASSERT(offsetof(typeof(*ocd), padding1) != 0);
         CLASSERT(offsetof(typeof(*ocd), padding2) != 0);
         CLASSERT(offsetof(typeof(*ocd), padding3) != 0);
index d843e95..f48c717 100644 (file)
@@ -1007,9 +1007,17 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obd_connect_data, ocd_maxbytes));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_maxbytes) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_maxbytes));
                 (long long)(int)offsetof(struct obd_connect_data, ocd_maxbytes));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_maxbytes) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_maxbytes));
-       LASSERTF((int)offsetof(struct obd_connect_data, padding1) == 72, "found %lld\n",
+       LASSERTF((int)offsetof(struct obd_connect_data, ocd_maxmodrpcs) == 72, "found %lld\n",
+                (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",
+                (long long)(int)offsetof(struct obd_connect_data, padding0));
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 2, "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));
                 (long long)(int)offsetof(struct obd_connect_data, padding1));
-       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding1) == 8, "found %lld\n",
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding1) == 4, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->padding1));
        LASSERTF((int)offsetof(struct obd_connect_data, padding2) == 80, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding2));
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->padding1));
        LASSERTF((int)offsetof(struct obd_connect_data, padding2) == 80, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding2));
@@ -1177,6 +1185,8 @@ void lustre_assert_wire_constants(void)
                 OBD_CONNECT_LFSCK);
        LASSERTF(OBD_CONNECT_UNLINK_CLOSE == 0x100000000000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_UNLINK_CLOSE);
                 OBD_CONNECT_LFSCK);
        LASSERTF(OBD_CONNECT_UNLINK_CLOSE == 0x100000000000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_UNLINK_CLOSE);
+       LASSERTF(OBD_CONNECT_MULTIMODRPCS == 0x200000000000000ULL, "found 0x%.16llxULL\n",
+                OBD_CONNECT_MULTIMODRPCS);
        LASSERTF(OBD_CONNECT_DIR_STRIPE == 0x400000000000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_DIR_STRIPE);
        LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",
        LASSERTF(OBD_CONNECT_DIR_STRIPE == 0x400000000000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_DIR_STRIPE);
        LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",
index fc94019..7991e08 100644 (file)
@@ -455,6 +455,8 @@ check_obd_connect_data(void)
        CHECK_MEMBER(obd_connect_data, ocd_max_easize);
        CHECK_MEMBER(obd_connect_data, ocd_instance);
        CHECK_MEMBER(obd_connect_data, ocd_maxbytes);
        CHECK_MEMBER(obd_connect_data, ocd_max_easize);
        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, padding0);
        CHECK_MEMBER(obd_connect_data, padding1);
        CHECK_MEMBER(obd_connect_data, padding2);
        CHECK_MEMBER(obd_connect_data, padding3);
        CHECK_MEMBER(obd_connect_data, padding1);
        CHECK_MEMBER(obd_connect_data, padding2);
        CHECK_MEMBER(obd_connect_data, padding3);
@@ -526,6 +528,7 @@ check_obd_connect_data(void)
        CHECK_DEFINE_64X(OBD_CONNECT_OPEN_BY_FID);
        CHECK_DEFINE_64X(OBD_CONNECT_LFSCK);
        CHECK_DEFINE_64X(OBD_CONNECT_UNLINK_CLOSE);
        CHECK_DEFINE_64X(OBD_CONNECT_OPEN_BY_FID);
        CHECK_DEFINE_64X(OBD_CONNECT_LFSCK);
        CHECK_DEFINE_64X(OBD_CONNECT_UNLINK_CLOSE);
+       CHECK_DEFINE_64X(OBD_CONNECT_MULTIMODRPCS);
        CHECK_DEFINE_64X(OBD_CONNECT_DIR_STRIPE);
 
        CHECK_VALUE_X(OBD_CKSUM_CRC32);
        CHECK_DEFINE_64X(OBD_CONNECT_DIR_STRIPE);
 
        CHECK_VALUE_X(OBD_CKSUM_CRC32);
index 2121298..0d69df8 100644 (file)
@@ -1016,9 +1016,17 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obd_connect_data, ocd_maxbytes));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_maxbytes) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_maxbytes));
                 (long long)(int)offsetof(struct obd_connect_data, ocd_maxbytes));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_maxbytes) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_maxbytes));
-       LASSERTF((int)offsetof(struct obd_connect_data, padding1) == 72, "found %lld\n",
+       LASSERTF((int)offsetof(struct obd_connect_data, ocd_maxmodrpcs) == 72, "found %lld\n",
+                (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",
+                (long long)(int)offsetof(struct obd_connect_data, padding0));
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 2, "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));
                 (long long)(int)offsetof(struct obd_connect_data, padding1));
-       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding1) == 8, "found %lld\n",
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding1) == 4, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->padding1));
        LASSERTF((int)offsetof(struct obd_connect_data, padding2) == 80, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding2));
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->padding1));
        LASSERTF((int)offsetof(struct obd_connect_data, padding2) == 80, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding2));
@@ -1186,6 +1194,8 @@ void lustre_assert_wire_constants(void)
                 OBD_CONNECT_LFSCK);
        LASSERTF(OBD_CONNECT_UNLINK_CLOSE == 0x100000000000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_UNLINK_CLOSE);
                 OBD_CONNECT_LFSCK);
        LASSERTF(OBD_CONNECT_UNLINK_CLOSE == 0x100000000000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_UNLINK_CLOSE);
+       LASSERTF(OBD_CONNECT_MULTIMODRPCS == 0x200000000000000ULL, "found 0x%.16llxULL\n",
+                OBD_CONNECT_MULTIMODRPCS);
        LASSERTF(OBD_CONNECT_DIR_STRIPE == 0x400000000000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_DIR_STRIPE);
        LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",
        LASSERTF(OBD_CONNECT_DIR_STRIPE == 0x400000000000000ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_DIR_STRIPE);
        LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",