@@ -613,8 +613,8 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
ns->ns_bucket_bits = ldlm_ns_hash_defs[ns_type].nsd_all_bits -
ldlm_ns_hash_defs[ns_type].nsd_bkt_bits;
- ns->ns_rs_buckets = kvmalloc(BIT(ns->ns_bucket_bits) *
- sizeof(ns->ns_rs_buckets[0]),
+ ns->ns_rs_buckets = kvzalloc((1 << ns->ns_bucket_bits) *
+ sizeof(*ns->ns_rs_buckets),
GFP_KERNEL);
if (!ns->ns_rs_buckets)
goto out_hash;
@@ -1780,7 +1780,7 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
w = pp_info->pp_w_hist.oh_buckets[i];
read_cum += r;
write_cum += w;
- end = BIT(i + LL_HIST_START - units);
+ end = 1 << (i + LL_HIST_START - units);
seq_printf(seq,
"%4lu%c - %4lu%c%c: %14lu %4u %4u | %14lu %4u %4u\n",
start, *unitp, end, *unitp,
@@ -1958,7 +1958,7 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
lprocfs_oh_clear(&io_extents->pp_extents[cur].pp_w_hist);
}
- for (i = 0; (count >= BIT(LL_HIST_START + i)) &&
+ for (i = 0; (count >= 1 << (LL_HIST_START + i)) &&
(i < (LL_HIST_MAX - 1)); i++)
;
if (rw == 0) {
@@ -113,27 +113,29 @@ static int class_resolve_dev_name(u32 len, const char *name)
static int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
{
- if (data->ioc_len > BIT(30)) {
+ const int maxlen = 1 << 30;
+
+ if (data->ioc_len > maxlen) {
CERROR("OBD ioctl: ioc_len larger than 1<<30\n");
return 1;
}
- if (data->ioc_inllen1 > BIT(30)) {
+ if (data->ioc_inllen1 > maxlen) {
CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
return 1;
}
- if (data->ioc_inllen2 > BIT(30)) {
+ if (data->ioc_inllen2 > maxlen) {
CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
return 1;
}
- if (data->ioc_inllen3 > BIT(30)) {
+ if (data->ioc_inllen3 > maxlen) {
CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n");
return 1;
}
- if (data->ioc_inllen4 > BIT(30)) {
+ if (data->ioc_inllen4 > maxlen) {
CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n");
return 1;
}
@@ -80,18 +80,17 @@ static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
{
- if (data->ioc_hdr.ioc_len > BIT(30)) {
- CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
+ const int maxlen = 1 << 30;
+
+ if (data->ioc_hdr.ioc_len > maxlen)
return true;
- }
- if (data->ioc_inllen1 > BIT(30)) {
- CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
+
+ if (data->ioc_inllen1 > maxlen)
return true;
- }
- if (data->ioc_inllen2 > BIT(30)) {
- CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
+
+ if (data->ioc_inllen2 > maxlen)
return true;
- }
+
if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
return true;