LPU64||%llu
LPX64i||%llx
LPX64||%#llx
+\bMAX\(||max_t
+\bMIN\(||min_t
mktemp||mkstemp
page_cache_get||get_page
PAGE_CACHE_MASK||PAGE_MASK
/* logical equivalence */
#define equi(a, b) (!!(a) == !!(b))
-/* what used to be in portals_lib.h */
-#ifndef MIN
-# define MIN(a,b) (((a)<(b)) ? (a): (b))
-#endif
-#ifndef MAX
-# define MAX(a,b) (((a)>(b)) ? (a): (b))
-#endif
-
#define MKSTR(ptr) ((ptr))? (ptr) : ""
static inline size_t cfs_size_round4(size_t val)
* check context */
conn->gnc_device = dev;
- conn->gnc_timeout = MAX(*kgnilnd_tunables.kgn_timeout,
- GNILND_MIN_TIMEOUT);
+ conn->gnc_timeout = max(*kgnilnd_tunables.kgn_timeout,
+ GNILND_MIN_TIMEOUT);
kgnilnd_update_reaper_timeout(conn->gnc_timeout);
/* this is the ep_handle for doing SMSG & BTE */
/* set timeout vals in conn early so we can use them for the NAK */
/* use max of the requested and our timeout, peer will do the same */
- conn->gnc_timeout = MAX(conn->gnc_timeout, connreq->gncr_timeout);
+ conn->gnc_timeout = max(conn->gnc_timeout, connreq->gncr_timeout);
/* only ep_bind really mucks around with the CQ */
/* only ep bind if we are not connecting to ourself and the dstnid is not a wildcard. this check
current_to += *kgnilnd_tunables.kgn_min_reconnect_interval / 2;
}
- current_to = MIN(current_to,
- *kgnilnd_tunables.kgn_max_reconnect_interval);
+ current_to = min(current_to,
+ *kgnilnd_tunables.kgn_max_reconnect_interval);
peer->gnp_reconnect_interval = current_to;
CDEBUG(D_NET, "peer %s can reconnect at %lu interval %lu\n",
peer, libcfs_nid2str(peer->gnp_nid),
peer->gnp_reconnect_interval);
- timeout = cfs_time_seconds(MAX(*kgnilnd_tunables.kgn_timeout,
+ timeout = cfs_time_seconds(max(*kgnilnd_tunables.kgn_timeout,
GNILND_MIN_TIMEOUT));
conn = kgnilnd_find_conn_locked(peer);
fma_blk->gnm_hndl.qword1, fma_blk->gnm_hndl.qword2);
fma_blk->gnm_held_mboxs++;
- fma_blk->gnm_max_timeout = MAX(fma_blk->gnm_max_timeout,
- conn->gnc_timeout);
+ fma_blk->gnm_max_timeout = max_t(long, fma_blk->gnm_max_timeout,
+ conn->gnc_timeout);
} else {
CDEBUG(D_NET, "conn %p smsg %p fmablk %p release SMSG mbox %d "
"hndl %#llx.%#llx\n",
return rd->rd_frags[index].rf_addr;
}
-static inline __u32
+static inline int
kiblnd_rd_frag_size(struct kib_rdma_desc *rd, int index)
{
return rd->rd_frags[index].rf_nob;
break;
}
- sge_nob = MIN(MIN(kiblnd_rd_frag_size(srcrd, srcidx),
- kiblnd_rd_frag_size(dstrd, dstidx)), resid);
+ sge_nob = min3(kiblnd_rd_frag_size(srcrd, srcidx),
+ kiblnd_rd_frag_size(dstrd, dstidx),
+ resid);
sge = &tx->tx_sge[tx->tx_nsge];
sge->addr = kiblnd_rd_frag_addr(srcrd, srcidx);
LASSERT(net->ksnn_ninterfaces <= LNET_INTERFACES_NUM);
/* Only match interfaces for additional connections
- * if I have > 1 interface */
- n_ips = (net->ksnn_ninterfaces < 2) ? 0 :
- MIN(n_peerips, net->ksnn_ninterfaces);
+ * if I have > 1 interface
+ */
+ n_ips = (net->ksnn_ninterfaces < 2) ? 0 :
+ min(n_peerips, net->ksnn_ninterfaces);
for (i = 0; peer_ni->ksnp_n_passive_ips < n_ips; i++) {
/* ^ yes really... */
/* Set up to skip as much as possible now. If there's more left
* (ran out of iov entries) we'll get called again */
- conn->ksnc_rx_state = SOCKNAL_RX_SLOP;
- conn->ksnc_rx_nob_left = nob_to_skip;
+ conn->ksnc_rx_state = SOCKNAL_RX_SLOP;
+ conn->ksnc_rx_nob_left = nob_to_skip;
conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space;
- skipped = 0;
- niov = 0;
+ skipped = 0;
+ niov = 0;
- do {
- nob = MIN (nob_to_skip, sizeof (ksocknal_slop_buffer));
+ do {
+ nob = min_t(int, nob_to_skip, sizeof(ksocknal_slop_buffer));
- conn->ksnc_rx_iov[niov].iov_base = ksocknal_slop_buffer;
- conn->ksnc_rx_iov[niov].iov_len = nob;
- niov++;
- skipped += nob;
- nob_to_skip -=nob;
+ conn->ksnc_rx_iov[niov].iov_base = ksocknal_slop_buffer;
+ conn->ksnc_rx_iov[niov].iov_len = nob;
+ niov++;
+ skipped += nob;
+ nob_to_skip -= nob;
- } while (nob_to_skip != 0 && /* mustn't overflow conn's rx iov */
+ } while (nob_to_skip != 0 && /* mustn't overflow conn's rx iov */
niov < sizeof(conn->ksnc_rx_iov_space) / sizeof(struct kvec));
conn->ksnc_rx_niov = niov;
unsigned int nob)
{
/* NB diov, siov are READ-ONLY */
- unsigned int this_nob;
+ unsigned int this_nob;
if (nob == 0)
return;
do {
LASSERT(ndiov > 0);
LASSERT(nsiov > 0);
- this_nob = MIN(diov->iov_len - doffset,
- siov->iov_len - soffset);
- this_nob = MIN(this_nob, nob);
+ this_nob = min3((unsigned int)diov->iov_len - doffset,
+ (unsigned int)siov->iov_len - soffset,
+ nob);
memcpy((char *)diov->iov_base + doffset,
(char *)siov->iov_base + soffset, this_nob);
do {
LASSERT(ndiov > 0);
LASSERT(nsiov > 0);
- this_nob = MIN(diov->kiov_len - doffset,
- siov->kiov_len - soffset);
- this_nob = MIN(this_nob, nob);
+ this_nob = min3(diov->kiov_len - doffset,
+ siov->kiov_len - soffset,
+ nob);
if (daddr == NULL)
daddr = ((char *)kmap(diov->kiov_page)) +
do {
LASSERT(niov > 0);
LASSERT(nkiov > 0);
- this_nob = MIN(iov->iov_len - iovoffset,
- kiov->kiov_len - kiovoffset);
- this_nob = MIN(this_nob, nob);
+ this_nob = min3((unsigned int)iov->iov_len - iovoffset,
+ (unsigned int)kiov->kiov_len - kiovoffset,
+ nob);
if (addr == NULL)
addr = ((char *)kmap(kiov->kiov_page)) +
do {
LASSERT(nkiov > 0);
LASSERT(niov > 0);
- this_nob = MIN(kiov->kiov_len - kiovoffset,
- iov->iov_len - iovoffset);
- this_nob = MIN(this_nob, nob);
+ this_nob = min3((unsigned int)kiov->kiov_len - kiovoffset,
+ (unsigned int)iov->iov_len - iovoffset,
+ nob);
if (addr == NULL)
addr = ((char *)kmap(kiov->kiov_page)) +
struct lnet_hdr *hdr = &msg->msg_hdr;
struct lnet_process_id src = {0};
struct lnet_libmd *md;
- int rlength;
- int mlength;
+ unsigned int rlength;
+ unsigned int mlength;
int cpt;
cpt = lnet_cpt_of_cookie(hdr->msg.reply.dst_wmd.wh_object_cookie);
LASSERT(md->md_offset == 0);
rlength = hdr->payload_length;
- mlength = MIN(rlength, (int)md->md_length);
+ mlength = min(rlength, md->md_length);
if (mlength < rlength &&
(md->md_options & LNET_MD_TRUNCATE) == 0) {
lp->lp_state &= ~LNET_PEER_ROUTER_ENABLED;
spin_unlock(&lp->lp_lock);
- nnis = MAX(lp->lp_nnis, pbuf->pb_info.pi_nnis);
+ nnis = max_t(int, lp->lp_nnis, pbuf->pb_info.pi_nnis);
LIBCFS_ALLOC(curnis, nnis * sizeof(*curnis));
LIBCFS_ALLOC(addnis, nnis * sizeof(*addnis));
LIBCFS_ALLOC(delnis, nnis * sizeof(*delnis));
pnid = lnet_peer_select_nid(lp);
lnet_net_unlock(cpt);
- nnis = MAX(lp->lp_data_nnis, LNET_INTERFACES_MIN);
+ nnis = max(lp->lp_data_nnis, LNET_INTERFACES_MIN);
rc = lnet_send_ping(pnid, &lp->lp_ping_mdh, nnis, lp,
the_lnet.ln_dc_eqh, false);
*/
#define LNET_PROC_CPT_BITS (LNET_CPT_BITS + 1)
/* change version, 16 bits or 8 bits */
-#define LNET_PROC_VER_BITS MAX(((MIN(LNET_LOFFT_BITS, 64)) / 4), 8)
+#define LNET_PROC_VER_BITS \
+ clamp_t(int, LNET_LOFFT_BITS / 4, 8, 16)
#define LNET_PROC_HASH_BITS LNET_PEER_HASH_BITS
/*
#define LST_TRANS_TIMEOUT 30
#define LST_TRANS_MIN_TIMEOUT 3
-#define LST_VALIDATE_TIMEOUT(t) MIN(MAX(t, LST_TRANS_MIN_TIMEOUT), LST_TRANS_TIMEOUT)
+#define LST_VALIDATE_TIMEOUT(t) \
+ clamp_t(int, t, LST_TRANS_MIN_TIMEOUT, LST_TRANS_TIMEOUT)
#define LST_PING_INTERVAL 8
LASSERT(scd->scd_buf_posting > 0);
scd->scd_buf_posting--;
scd->scd_buf_total++;
- scd->scd_buf_low = MAX(2, scd->scd_buf_total / 4);
+ scd->scd_buf_low = max(2, scd->scd_buf_total / 4);
}
if (rc != 0) {
if (scd->scd_buf_err == 0 && /* adding buffer is enabled */
scd->scd_buf_adjust == 0 &&
scd->scd_buf_nposted < scd->scd_buf_low) {
- scd->scd_buf_adjust = MAX(scd->scd_buf_total / 2,
+ scd->scd_buf_adjust = max(scd->scd_buf_total / 2,
SFW_TEST_WI_MIN);
swi_schedule_workitem(&scd->scd_buf_wi);
}
lcme->lcme_id = cpu_to_le32(id);
}
- id = MAX(le32_to_cpu(lcme->lcme_id), id);
+ id = max(le32_to_cpu(lcme->lcme_id), id);
}
mirror_id = mirror_id_of(id) + 1;
if (!lu_extent_is_overlapped(ext, lle->lle_extent))
continue;
- ext->e_start = MIN(ext->e_start, lle->lle_extent->e_start);
- ext->e_end = MAX(ext->e_end, lle->lle_extent->e_end);
+ ext->e_start = min(ext->e_start, lle->lle_extent->e_start);
+ ext->e_end = max(ext->e_end, lle->lle_extent->e_end);
++count;
}
if (count == 0) {
generation = obddev->u.cli.cl_import->imp_generation;
if (!it || (it->it_op & (IT_OPEN | IT_CREAT)))
- acl_bufsize = MIN(imp->imp_connect_data.ocd_max_easize,
- XATTR_SIZE_MAX);
+ acl_bufsize = min_t(__u32, imp->imp_connect_data.ocd_max_easize,
+ XATTR_SIZE_MAX);
else
acl_bufsize = LUSTRE_POSIX_ACL_MAX_SIZE_OLD;
acl_bufsize == LUSTRE_POSIX_ACL_MAX_SIZE_OLD) {
mdc_clear_replay_flag(req, -ERANGE);
ptlrpc_req_finished(req);
- acl_bufsize = MIN(imp->imp_connect_data.ocd_max_easize,
- XATTR_SIZE_MAX);
+ acl_bufsize = min_t(__u32, imp->imp_connect_data.ocd_max_easize,
+ XATTR_SIZE_MAX);
goto resend;
}
rc = mdc_getattr_common(exp, req);
if (rc) {
if (rc == -ERANGE) {
- acl_bufsize = MIN(imp->imp_connect_data.ocd_max_easize,
- XATTR_SIZE_MAX);
+ acl_bufsize = min_t(__u32,
+ imp->imp_connect_data.ocd_max_easize,
+ XATTR_SIZE_MAX);
mdc_reset_acl_req(req);
goto again;
}
rc = mdc_getattr_common(exp, req);
if (rc) {
if (rc == -ERANGE) {
- acl_bufsize = MIN(imp->imp_connect_data.ocd_max_easize,
- XATTR_SIZE_MAX);
+ acl_bufsize = min_t(__u32,
+ imp->imp_connect_data.ocd_max_easize,
+ XATTR_SIZE_MAX);
mdc_reset_acl_req(req);
goto again;
}
GOTO(out_free, rc = PTR_ERR(handle));
lu_buf_check_and_alloc(&info->mti_xattr_buf,
- MIN(mdd->mdd_dt_conf.ddp_max_ea_size, XATTR_SIZE_MAX));
+ min_t(unsigned int, mdd->mdd_dt_conf.ddp_max_ea_size,
+ XATTR_SIZE_MAX));
acl_buf = info->mti_xattr_buf;
def_acl_buf.lb_buf = info->mti_key;
def_acl_buf.lb_len = sizeof(info->mti_key);
/* Read HSM attrs from disk */
current_buf = lu_buf_check_and_alloc(&info->mti_xattr_buf,
- MIN(mdd_obj2mdd_dev(mdd_obj)->mdd_dt_conf.ddp_max_ea_size,
+ min_t(unsigned int,
+ mdd_obj2mdd_dev(mdd_obj)->mdd_dt_conf.ddp_max_ea_size,
XATTR_SIZE_MAX));
rc = mdo_xattr_get(env, mdd_obj, current_buf, XATTR_NAME_HSM);
rc = lustre_buf2hsm(current_buf->lb_buf, rc, current_mh);
ENTRY;
lu_buf_check_and_alloc(&mdd_env_info(env)->mti_xattr_buf,
- MIN(mdd_obj2mdd_dev(o)->mdd_dt_conf.ddp_max_ea_size,
- XATTR_SIZE_MAX));
+ min_t(unsigned int,
+ mdd_obj2mdd_dev(o)->mdd_dt_conf.ddp_max_ea_size,
+ XATTR_SIZE_MAX));
buf = mdd_env_info(env)->mti_xattr_buf;
if (buf.lb_buf == NULL)
RETURN(-ENOMEM);
ENTRY;
lu_buf_check_and_alloc(&mdd_env_info(env)->mti_xattr_buf,
- MIN(mdd_obj2mdd_dev(obj)->mdd_dt_conf.ddp_max_ea_size,
- XATTR_SIZE_MAX));
+ min_t(unsigned int,
+ mdd_obj2mdd_dev(obj)->mdd_dt_conf.ddp_max_ea_size,
+ XATTR_SIZE_MAX));
buf = mdd_env_info(env)->mti_xattr_buf;
if (buf.lb_buf == NULL)
RETURN(-ENOMEM);
buf->lb_buf != info->mti_big_acl) {
if (info->mti_big_acl == NULL) {
info->mti_big_aclsize =
- MIN(mdt->mdt_max_ea_size,
- XATTR_SIZE_MAX);
+ min_t(unsigned int,
+ mdt->mdt_max_ea_size,
+ XATTR_SIZE_MAX);
OBD_ALLOC_LARGE(info->mti_big_acl,
info->mti_big_aclsize);
if (info->mti_big_acl == NULL) {
nid = libcfs_str2nid(nidstr);
nodemap_test_nid(nid, name_buf, sizeof(name_buf));
rc = copy_to_user(data->ioc_pbuf1, name_buf,
- MIN(data->ioc_plen1, sizeof(name_buf)));
+ min_t(size_t, data->ioc_plen1,
+ sizeof(name_buf)));
if (rc != 0)
GOTO(out_lcfg, rc = -EFAULT);
break;
return;
lu_site_purge_objects(env, dev->ld_site,
- MIN(size - nr, LU_CACHE_NR_MAX_ADJUST), 0);
+ min_t(__u64, size - nr, LU_CACHE_NR_MAX_ADJUST),
+ 0);
}
/**
ff->ff_layout_version = oa->o_layout_version;
ff->ff_range = 0;
} else if (oa->o_layout_version > ff->ff_layout_version) {
- ff->ff_range = MAX(ff->ff_range,
- oa->o_layout_version - ff->ff_layout_version);
+ ff->ff_range = max_t(__u32, ff->ff_range,
+ oa->o_layout_version -
+ ff->ff_layout_version);
}
}
mem_tight |= ext->oe_memalloc;
grant += ext->oe_grants;
page_count += ext->oe_nr_pages;
- layout_version = MAX(layout_version, ext->oe_layout_version);
+ layout_version = max(layout_version, ext->oe_layout_version);
if (obj == NULL)
obj = ext->oe_obj;
}
int dnodesize, dmu_tx_t *tx)
{
if (dnodesize == 0)
- dnodesize = MAX(dmu_objset_dnodesize(os), DNODE_MIN_SIZE);
+ dnodesize = max_t(int, dmu_objset_dnodesize(os),
+ DNODE_MIN_SIZE);
return dmu_object_alloc_dnsize(os, objtype, blocksize, DMU_OT_SA,
DN_BONUS_SIZE(dnodesize), dnodesize, tx);
int indirect_blockshift, int dnodesize, dmu_tx_t *tx)
{
if (dnodesize == 0)
- dnodesize = MAX(dmu_objset_dnodesize(os), DNODE_MIN_SIZE);
+ dnodesize = max_t(int, dmu_objset_dnodesize(os),
+ DNODE_MIN_SIZE);
return zap_create_flags_dnsize(os, normflags, flags, ot,
leaf_blockshift, indirect_blockshift,