9
9
#include <linux/debugfs.h>
10
10
#include <linux/seq_file.h>
11
11
#include <linux/ratelimit.h>
12
+ #include <linux/bits.h>
12
13
13
14
#include "super.h"
14
15
#include "mds_client.h"
@@ -1057,20 +1058,21 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq)
1057
1058
return msg ;
1058
1059
}
1059
1060
1061
+ static const unsigned char feature_bits [] = CEPHFS_FEATURES_CLIENT_SUPPORTED ;
1062
+ #define FEATURE_BYTES (c ) (DIV_ROUND_UP((size_t)feature_bits[c - 1] + 1, 64) * 8)
1060
1063
static void encode_supported_features (void * * p , void * end )
1061
1064
{
1062
- static const unsigned char bits [] = CEPHFS_FEATURES_CLIENT_SUPPORTED ;
1063
- static const size_t count = ARRAY_SIZE (bits );
1065
+ static const size_t count = ARRAY_SIZE (feature_bits );
1064
1066
1065
1067
if (count > 0 ) {
1066
1068
size_t i ;
1067
- size_t size = (( size_t ) bits [ count - 1 ] + 64 ) / 64 * 8 ;
1069
+ size_t size = FEATURE_BYTES ( count ) ;
1068
1070
1069
1071
BUG_ON (* p + 4 + size > end );
1070
1072
ceph_encode_32 (p , size );
1071
1073
memset (* p , 0 , size );
1072
1074
for (i = 0 ; i < count ; i ++ )
1073
- ((unsigned char * )(* p ))[i / 8 ] |= 1 << ( bits [i ] % 8 );
1075
+ ((unsigned char * )(* p ))[i / 8 ] |= BIT ( feature_bits [i ] % 8 );
1074
1076
* p += size ;
1075
1077
} else {
1076
1078
BUG_ON (* p + 4 > end );
@@ -1091,6 +1093,7 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6
1091
1093
int metadata_key_count = 0 ;
1092
1094
struct ceph_options * opt = mdsc -> fsc -> client -> options ;
1093
1095
struct ceph_mount_options * fsopt = mdsc -> fsc -> mount_options ;
1096
+ size_t size , count ;
1094
1097
void * p , * end ;
1095
1098
1096
1099
const char * metadata [][2 ] = {
@@ -1108,8 +1111,13 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6
1108
1111
strlen (metadata [i ][1 ]);
1109
1112
metadata_key_count ++ ;
1110
1113
}
1114
+
1111
1115
/* supported feature */
1112
- extra_bytes += 4 + 8 ;
1116
+ size = 0 ;
1117
+ count = ARRAY_SIZE (feature_bits );
1118
+ if (count > 0 )
1119
+ size = FEATURE_BYTES (count );
1120
+ extra_bytes += 4 + size ;
1113
1121
1114
1122
/* Allocate the message */
1115
1123
msg = ceph_msg_new (CEPH_MSG_CLIENT_SESSION , sizeof (* h ) + extra_bytes ,
@@ -1129,7 +1137,7 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6
1129
1137
* Serialize client metadata into waiting buffer space, using
1130
1138
* the format that userspace expects for map<string, string>
1131
1139
*
1132
- * ClientSession messages with metadata are v2
1140
+ * ClientSession messages with metadata are v3
1133
1141
*/
1134
1142
msg -> hdr .version = cpu_to_le16 (3 );
1135
1143
msg -> hdr .compat_version = cpu_to_le16 (1 );
0 commit comments