Changeset 4617

Show
Ignore:
Timestamp:
10/06/05 09:43:04 (8 years ago)
Author:
robl
Message:

[pcarns]: add protocol versioning to PVFS2. Major version changes are
incompatible up or down. New clients can't talk to old servers, but new
servers can talk to old clients.

Location:
trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r4605 r4617  
    33----------------------- 
    44 
    5 pvfs2-1.2.1-pre1 
     5pvfs2-1.3.0-pre1 
    66=============== 
    77- Murali Vilayannur contributed extened attribute support to the VFS interface 
     
    1111- Phil also contributed improvements to the request processor which should 
    1212  help speed up some concurrent workloads. 
     13- Phil further contributed protocol versioning to PVFS2.  Major version 
     14  changes are incompatible up or down.  New clients can't talk to old servers, 
     15  but new servers can talk to old clients.  
    1316 
    1417pvfs2-1.2.0 
  • trunk/doc/add-server-req

    r4510 r4617  
    1515                        add a stub in include/pvfs2-encode-stubs.h 
    1616 
     172b) update the protocol version number 
     18                src/proto/pvfs2-req-proto.h 
     19                        increment PVFS2_PROTO_MINOR, assuming that the 
     20                        addition of this new request does not break backwards 
     21                        compatibility for other request types 
     22        
    17233) add entries to decode/encode functions 
    1824                src/proto/PINT-le-bytefield.c 
  • trunk/include/pvfs2-mgmt.h

    r4574 r4617  
    33 * 
    44 * See COPYING in top-level directory. 
     5 */ 
     6/* NOTE: if you make any changes to the encoding definitions in this file, 
     7 * please update the PVFS2_PROTO_VERSION in pvfs2-req-proto.h accordingly 
    58 */ 
    69 
  • trunk/include/pvfs2-types.h

    r4593 r4617  
    33 * 
    44 * See COPYING in top-level directory. 
     5 */ 
     6/* NOTE: if you make any changes to the encoding definitions in this file,  
     7 * please update the PVFS2_PROTO_VERSION in pvfs2-req-proto.h accordingly 
    58 */ 
    69 
  • trunk/src/proto/PINT-reqproto-encode.c

    r4536 r4617  
    6363        /* header prepended to all messages of this type */ 
    6464        *((int32_t*)&(le_bytefield_table.generic_header[0])) =  
    65             htobmi32(PVFS_RELEASE_NR); 
     65            htobmi32(PVFS2_PROTO_VERSION); 
    6666        *((int32_t*)&(le_bytefield_table.generic_header[4])) =  
    6767            htobmi32(ENCODING_LE_BFIELD); 
    6868 
     69        le_bytefield_table.enc_type = ENCODING_LE_BFIELD; 
    6970        ret = 0; 
    7071    } 
     
    166167    int ret; 
    167168    int32_t enc_type_recved, proto_ver_recved; 
     169    int proto_major_recved, proto_minor_recved; 
    168170 
    169171    gossip_debug(GOSSIP_ENDECODE_DEBUG,"PINT_decode\n"); 
    170     /* compare the header of the incoming buffer against the precalculated 
    171      * header associated with each module 
    172      */ 
     172 
     173    /* sanity check size */ 
     174    if(size < PINT_ENC_GENERIC_HEADER_SIZE) 
     175    { 
     176        gossip_err("Error: poorly formatted protocol message received.\n"); 
     177        gossip_err("   Too small: message only %Ld bytes.\n", 
     178            Ld(size)); 
     179        return(-PVFS_EPROTO); 
     180    } 
     181     
     182    /* pull the encoding type and protocol version out */ 
     183    proto_ver_recved = (int)bmitoh32(*((int32_t*)input_buffer)); 
     184    enc_type_recved = bmitoh32(*((int32_t*)enc_type_ptr)); 
     185    proto_major_recved = proto_ver_recved / 1000; 
     186    proto_minor_recved = proto_ver_recved - (proto_major_recved*1000); 
     187 
     188    /* check encoding type */ 
     189    if(enc_type_recved != ENCODING_LE_BFIELD) 
     190    { 
     191        gossip_err("Error: poorly formatted protocol message received.\n"); 
     192        gossip_err("   Encoding type mismatch: received type %d when " 
     193            "expecting %d.\n", (int)enc_type_recved,  
     194            ENCODING_LE_BFIELD); 
     195        return(-PVFS_EPROTONOSUPPORT); 
     196    } 
     197 
     198    /* check various protocol version possibilities */ 
     199    if(proto_major_recved != PVFS2_PROTO_MAJOR) 
     200    { 
     201        gossip_err("Error: poorly formatted protocol message received.\n"); 
     202        gossip_err("   Protocol version mismatch: received major version %d when " 
     203            "expecting %d.\n", (int)proto_major_recved, 
     204            PVFS2_PROTO_MAJOR); 
     205        gossip_err("   Please verify your PVFS2 installation and make sure " 
     206        "that the version is\n   consistent.\n"); 
     207        return(-PVFS_EPROTONOSUPPORT); 
     208    } 
     209 
     210    if((input_type == PINT_DECODE_REQ) &&  
     211        (proto_minor_recved > PVFS2_PROTO_MINOR)) 
     212    { 
     213        gossip_err("Error: poorly formatted protocol message received.\n"); 
     214        gossip_err("   Protocol version mismatch: request has minor version %d when " 
     215            "expecting %d or lower.\n", (int)proto_minor_recved, 
     216            PVFS2_PROTO_MINOR); 
     217        gossip_err("   Client is too new for server.\n"); 
     218        gossip_err("   Please verify your PVFS2 installation and make sure " 
     219        "that the version is\n   consistent.\n"); 
     220        return(-PVFS_EPROTONOSUPPORT); 
     221    } 
     222 
     223    if((input_type == PINT_DECODE_RESP) &&  
     224        (proto_minor_recved < PVFS2_PROTO_MINOR)) 
     225    { 
     226        gossip_err("Error: poorly formatted protocol message received.\n"); 
     227        gossip_err("   Protocol version mismatch: request has minor version %d when " 
     228            "expecting %d or higher.\n", (int)proto_minor_recved, 
     229            PVFS2_PROTO_MINOR); 
     230        gossip_err("   Server is too old for client.\n"); 
     231        gossip_err("   Please verify your PVFS2 installation and make sure " 
     232        "that the version is\n   consistent.\n"); 
     233        return(-PVFS_EPROTONOSUPPORT); 
     234    } 
     235 
    173236    for(i=0; i<ENCODING_TABLE_SIZE; i++) 
    174237    { 
    175         if(PINT_encoding_table[i] && !(memcmp(input_buffer,  
    176             PINT_encoding_table[i]->generic_header,  
    177             PINT_ENC_GENERIC_HEADER_SIZE))) 
    178         { 
     238        if(PINT_encoding_table[i] && (PINT_encoding_table[i]->enc_type 
     239            == enc_type_recved)) 
     240        { 
    179241            struct PVFS_server_req* tmp_req; 
    180242            struct PVFS_server_req* tmp_resp; 
    181             target_msg->enc_type = bmitoh32(*((int32_t*)enc_type_ptr)); 
     243            target_msg->enc_type = enc_type_recved; 
    182244            if(input_type == PINT_DECODE_REQ) 
    183245            { 
     
    215277    gossip_err("Error: poorly formatted protocol message received.\n"); 
    216278 
    217     enc_type_recved = bmitoh32(*((int32_t*)enc_type_ptr)); 
    218     proto_ver_recved = (int)bmitoh32(*((int32_t*)input_buffer)); 
    219  
    220     if(size < PINT_ENC_GENERIC_HEADER_SIZE) 
    221     { 
    222         gossip_err("   Too small: message only %Ld bytes.\n", 
    223             Ld(size)); 
    224         return(-PVFS_EPROTO); 
    225     } 
    226  
    227     if(enc_type_recved != ENCODING_LE_BFIELD) 
    228     { 
    229         gossip_err("   Encoding type mismatch: received type %d when " 
    230             "expecting %d.\n", (int)enc_type_recved,  
    231             ENCODING_LE_BFIELD); 
    232     } 
    233  
    234     if(proto_ver_recved != PVFS_RELEASE_NR) 
    235     { 
    236         gossip_err("   Protocol version mismatch: received version %d when " 
    237             "expecting version %d.\n", (int)proto_ver_recved, 
    238             PVFS_RELEASE_NR); 
    239         gossip_err("   Please verify your PVFS2 installation and make sure " 
    240         "that the version is consistent.\n"); 
    241     } 
    242  
    243279    return(-PVFS_EPROTONOSUPPORT); 
    244280} 
  • trunk/src/proto/PINT-reqproto-module.h

    r3784 r4617  
    5151    void (*init_fun) (void); 
    5252    char generic_header[PINT_ENC_GENERIC_HEADER_SIZE]; 
     53    int enc_type; 
    5354} PINT_encoding_table_values; 
    5455 
  • trunk/src/proto/endecode-funcs.h

    r4539 r4617  
    66 * Defines for macros related to wire encoding and decoding.  Only included 
    77 * by include/pvfs2-encode-stubs.h by core encoding users. 
     8 */ 
     9/* NOTE: if you make any changes to the code contained in this file, please 
     10 * update the PVFS2_PROTO_VERSION in pvfs2-req-proto.h accordingly 
    811 */ 
    912#ifndef __SRC_PROTO_ENDECODE_FUNCS_H 
  • trunk/src/proto/pvfs2-attr.h

    r4570 r4617  
    33 * 
    44 * See COPYING in top-level directory. 
     5 */ 
     6/* NOTE: if you make any changes to the code contained in this file, please 
     7 * update the PVFS2_PROTO_VERSION in pvfs2-req-proto.h accordingly 
    58 */ 
    69 
  • trunk/src/proto/pvfs2-req-proto.h

    r4539 r4617  
    33 * 
    44 * See COPYING in top-level directory. 
     5 */ 
     6/* NOTE: if you make any changes to the code contained in this file, please 
     7 * update the PVFS2_PROTO_VERSION accordingly 
    58 */ 
    69 
     
    1518#include "pvfs2-mgmt.h" 
    1619 
    17 /* release number: This is a base-10, 5 digit number, with one digit 
    18  * for the most significant version number and two for the last two 
    19  * (e.g. 1.5.6 => 10506) 
     20/* update PVFS2_PROTO_MAJOR on wire protocol changes that break backwards 
     21 * compatibility (such as changing the semantics or protocol fields for an 
     22 * existing request type) 
    2023 */ 
    21 #define PVFS_RELEASE_NR ((PVFS2_VERSION_MAJOR * 10000) + \ 
    22   (PVFS2_VERSION_MINOR * 100) + PVFS2_VERSION_SUB) 
     24#define PVFS2_PROTO_MAJOR 1 
     25/* update PVFS2_PROTO_MINOR on wire protocol changes that preserve backwards 
     26 * compatibility (such as adding a new request type) 
     27 */ 
     28#define PVFS2_PROTO_MINOR 1 
     29#define PVFS2_PROTO_VERSION ((PVFS2_PROTO_MAJOR*1000)+(PVFS2_PROTO_MINOR)) 
    2330 
    2431enum PVFS_server_op