static bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
{
- if (data->ioc_hdr.ioc_len > BIT(30))
+ const int maxlen = 1 << 30;
+ if (data->ioc_hdr.ioc_len > maxlen)
return true;
- if (data->ioc_inllen1 > BIT(30))
+ if (data->ioc_inllen1 > maxlen)
return true;
- if (data->ioc_inllen2 > BIT(30))
+ if (data->ioc_inllen2 > maxlen)
return true;
if (data->ioc_inlbuf1 && !data->ioc_inllen1)
ns->ns_bucket_bits = ldlm_ns_hash_defs[ns_type].nsd_all_bits -
ldlm_ns_hash_defs[ns_type].nsd_bkt_bits;
- OBD_ALLOC_LARGE(ns->ns_rs_buckets,
- BIT(ns->ns_bucket_bits) * sizeof(ns->ns_rs_buckets[0]));
+ OBD_ALLOC_PTR_ARRAY_LARGE(ns->ns_rs_buckets, 1 << ns->ns_bucket_bits);
if (!ns->ns_rs_buckets)
goto out_hash;
ldlm_namespace_sysfs_unregister(ns);
ldlm_namespace_cleanup(ns, 0);
out_hash:
- OBD_FREE_LARGE(ns->ns_rs_buckets,
- BIT(ns->ns_bucket_bits) * sizeof(ns->ns_rs_buckets[0]));
+ OBD_FREE_PTR_ARRAY_LARGE(ns->ns_rs_buckets, 1 << ns->ns_bucket_bits);
kfree(ns->ns_name);
cfs_hash_putref(ns->ns_rs_hash);
out_ns:
ldlm_namespace_debugfs_unregister(ns);
ldlm_namespace_sysfs_unregister(ns);
cfs_hash_putref(ns->ns_rs_hash);
- OBD_FREE_LARGE(ns->ns_rs_buckets,
- BIT(ns->ns_bucket_bits) * sizeof(ns->ns_rs_buckets[0]));
+ OBD_FREE_PTR_ARRAY_LARGE(ns->ns_rs_buckets, 1 << ns->ns_bucket_bits);
kfree(ns->ns_name);
/* Namespace \a ns should be not on list at this time, otherwise
* this will cause issues related to using freed \a ns in poold
write_tot += pp_info->pp_w_hist.oh_buckets[i];
}
- for(i = 0; i < LL_HIST_MAX; i++) {
- r = pp_info->pp_r_hist.oh_buckets[i];
- w = pp_info->pp_w_hist.oh_buckets[i];
- read_cum += r;
- write_cum += w;
- end = BIT(i + LL_HIST_START - units);
+ for(i = 0; i < LL_HIST_MAX; i++) {
+ r = pp_info->pp_r_hist.oh_buckets[i];
+ w = pp_info->pp_w_hist.oh_buckets[i];
+ read_cum += r;
+ write_cum += w;
+ 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,
- (i == LL_HIST_MAX - 1) ? '+' : ' ',
- r, pct(r, read_tot), pct(read_cum, read_tot),
- w, pct(w, write_tot), pct(write_cum, write_tot));
- start = end;
- if (start == BIT(10)) {
- start = 1;
- units += 10;
- unitp++;
- }
- if (read_cum == read_tot && write_cum == write_tot)
- break;
- }
+ (i == LL_HIST_MAX - 1) ? '+' : ' ',
+ r, pct(r, read_tot), pct(read_cum, read_tot),
+ w, pct(w, write_tot), pct(write_cum, write_tot));
+ start = end;
+ if (start == (1 << 10)) {
+ start = 1;
+ units += 10;
+ unitp++;
+ }
+ if (read_cum == read_tot && write_cum == write_tot)
+ break;
+ }
}
static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v)
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) {
io_extents->pp_extents[cur].pp_r_hist.oh_buckets[i]++;
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;
}