Cleanup in general headers.
* use size_t in cfs_size_round*()
* make unsigned index and len in lustre_cfg_*() and object_update_*()
* make iteration variable the same type as comparing value
* make unsigned pages counters
* fix printf formats
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I9af487f0c8e04825adfce94ae11fe0a64c71c2e5
Reviewed-on: http://review.whamcloud.com/11327
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
#define MKSTR(ptr) ((ptr))? (ptr) : ""
-static inline int cfs_size_round4 (int val)
+static inline size_t cfs_size_round4(size_t val)
{
return (val + 3) & (~0x3);
}
#ifndef HAVE_CFS_SIZE_ROUND
-static inline int cfs_size_round (int val)
+static inline size_t cfs_size_round(size_t val)
{
return (val + 7) & (~0x7);
}
#define HAVE_CFS_SIZE_ROUND
#endif
-static inline int cfs_size_round16(int val)
+static inline size_t cfs_size_round16(size_t val)
{
return (val + 0xf) & (~0xf);
}
-static inline int cfs_size_round32(int val)
+static inline size_t cfs_size_round32(size_t val)
{
return (val + 0x1f) & (~0x1f);
}
-static inline int cfs_size_round0(int val)
+static inline size_t cfs_size_round0(size_t val)
{
if (!val)
return 0;
static inline size_t cfs_round_strlen(char *fset)
{
- return (size_t)cfs_size_round((int)strlen(fset) + 1);
+ return cfs_size_round(strlen(fset) + 1);
}
/* roundup \a val to power2 */
-static inline unsigned int cfs_power2_roundup(unsigned int val)
+static inline size_t cfs_power2_roundup(size_t val)
{
if (val != LOWEST_BIT_SET(val)) { /* not a power of 2 already */
do {
int idx,
enum lprocfs_fields_flags field)
{
- int i;
+ unsigned int i;
unsigned int num_cpu;
unsigned long flags = 0;
__u64 ret = 0;
lustre_cfg_bufs_set_string(bufs, 0, name);
}
-static inline void *lustre_cfg_buf(struct lustre_cfg *lcfg, int index)
+static inline void *lustre_cfg_buf(struct lustre_cfg *lcfg, __u32 index)
{
- int i;
- int offset;
- int bufcount;
- LASSERT (lcfg != NULL);
- LASSERT (index >= 0);
+ __u32 i;
+ size_t offset;
+ __u32 bufcount;
+ LASSERT (lcfg != NULL);
bufcount = lcfg->lcfg_bufcount;
if (index >= bufcount)
static inline void lustre_cfg_bufs_init(struct lustre_cfg_bufs *bufs,
struct lustre_cfg *lcfg)
{
- int i;
+ __u32 i;
bufs->lcfg_bufcount = lcfg->lcfg_bufcount;
for (i = 0; i < bufs->lcfg_bufcount; i++) {
bufs->lcfg_buflen[i] = lcfg->lcfg_buflens[i];
}
}
-static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, int index)
+static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, __u32 index)
{
char *s;
* of data. Try to use the padding first though.
*/
if (s[lcfg->lcfg_buflens[index] - 1] != '\0') {
- int last = min((int)lcfg->lcfg_buflens[index],
+ size_t last = min((size_t)lcfg->lcfg_buflens[index],
cfs_size_round(lcfg->lcfg_buflens[index]) - 1);
char lost = s[last];
s[last] = '\0';
return s;
}
-static inline int lustre_cfg_len(__u32 bufcount, __u32 *buflens)
+static inline __u32 lustre_cfg_len(__u32 bufcount, __u32 *buflens)
{
- int i;
- int len;
+ __u32 i;
+ __u32 len;
ENTRY;
len = LCFG_HDR_SIZE(bufcount);
struct lustre_cfg_bufs *bufs)
{
char *ptr;
- int i;
+ __u32 i;
lcfg->lcfg_version = LUSTRE_CFG_VERSION;
lcfg->lcfg_command = cmd;
return;
}
-static inline int lustre_cfg_sanity_check(void *buf, int len)
+static inline int lustre_cfg_sanity_check(void *buf, size_t len)
{
struct lustre_cfg *lcfg = (struct lustre_cfg *)buf;
ENTRY;
static inline void check_lcd(char *obd_name, int index,
struct lsd_client_data *lcd)
{
- int length = sizeof(lcd->lcd_uuid);
+ size_t length = sizeof(lcd->lcd_uuid);
if (strnlen((char*)lcd->lcd_uuid, length) == length) {
lcd->lcd_uuid[length - 1] = '\0';
static inline void range_array_cpu_to_le(struct lu_seq_range_array *dst,
const struct lu_seq_range_array *src)
{
- int i;
+ __u32 i;
for (i = 0; i < src->lsra_count; i++)
range_cpu_to_le(&dst->lsra_lsr[i], &src->lsra_lsr[i]);
static inline void range_array_le_to_cpu(struct lu_seq_range_array *dst,
const struct lu_seq_range_array *src)
{
- int i;
+ __u32 i;
dst->lsra_count = le32_to_cpu(src->lsra_count);
for (i = 0; i < dst->lsra_count; i++)
__u32 ioc_version;
};
-static inline int obd_ioctl_packlen(struct obd_ioctl_data *data)
+static inline __u32 obd_ioctl_packlen(struct obd_ioctl_data *data)
{
- int len = cfs_size_round(sizeof(*data));
+ __u32 len = cfs_size_round(sizeof(*data));
len += cfs_size_round(data->ioc_inllen1);
len += cfs_size_round(data->ioc_inllen2);
int obd_ioctl_getdata(char **buf, int *len, void *arg);
int obd_ioctl_popdata(void *arg, void *data, int len);
-static inline void obd_ioctl_freedata(char *buf, int len)
+static inline void obd_ioctl_freedata(char *buf, size_t len)
{
ENTRY;
static inline bool
lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2)
{
- int idx;
+ __u32 idx;
if (lsm1->lsm_md_magic != lsm2->lsm_md_magic ||
lsm1->lsm_md_stripe_count != lsm2->lsm_md_stripe_count ||
static inline void lmv1_le_to_cpu(struct lmv_mds_md_v1 *lmv_dst,
const struct lmv_mds_md_v1 *lmv_src)
{
- int i;
+ __u32 i;
lmv_dst->lmv_magic = le32_to_cpu(lmv_src->lmv_magic);
lmv_dst->lmv_stripe_count = le32_to_cpu(lmv_src->lmv_stripe_count);
/**
* Returns 1 if request buffer at offset \a index was already swabbed
*/
-static inline int lustre_req_swabbed(struct ptlrpc_request *req, int index)
+static inline int lustre_req_swabbed(struct ptlrpc_request *req, size_t index)
{
LASSERT(index < sizeof(req->rq_req_swab_mask) * 8);
return req->rq_req_swab_mask & (1 << index);
/**
* Returns 1 if request reply buffer at offset \a index was already swabbed
*/
-static inline int lustre_rep_swabbed(struct ptlrpc_request *req, int index)
+static inline int lustre_rep_swabbed(struct ptlrpc_request *req, size_t index)
{
LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8);
return req->rq_rep_swab_mask & (1 << index);
/**
* Mark request buffer at offset \a index that it was already swabbed
*/
-static inline void lustre_set_req_swabbed(struct ptlrpc_request *req, int index)
+static inline void lustre_set_req_swabbed(struct ptlrpc_request *req,
+ size_t index)
{
LASSERT(index < sizeof(req->rq_req_swab_mask) * 8);
LASSERT((req->rq_req_swab_mask & (1 << index)) == 0);
/**
* Mark request reply buffer at offset \a index that it was already swabbed
*/
-static inline void lustre_set_rep_swabbed(struct ptlrpc_request *req, int index)
+static inline void lustre_set_rep_swabbed(struct ptlrpc_request *req,
+ size_t index)
{
LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8);
LASSERT((req->rq_rep_swab_mask & (1 << index)) == 0);
{
const struct object_update_param *param;
unsigned long size;
- int i;
+ size_t i;
size = offsetof(struct object_update, ou_params[0]);
for (i = 0; i < update->ou_params_count; i++) {
}
static inline void
-*object_update_param_get(const struct object_update *update, int index,
- int *size)
+*object_update_param_get(const struct object_update *update, size_t index,
+ size_t *size)
{
const struct object_update_param *param;
- int i;
+ size_t i;
if (index >= update->ou_params_count)
return NULL;
static inline unsigned long
object_update_request_size(const struct object_update_request *our)
{
- unsigned long size;
- int i = 0;
+ unsigned long size;
+ size_t i = 0;
size = offsetof(struct object_update_request, ourq_updates[0]);
for (i = 0; i < our->ourq_count; i++) {
static inline struct object_update
*object_update_request_get(const struct object_update_request *our,
- int index, int *size)
+ size_t index, size_t *size)
{
void *ptr;
- int i;
+ size_t i;
if (index >= our->ourq_count)
return NULL;
}
static inline void
-object_update_reply_init(struct object_update_reply *reply, int count)
+object_update_reply_init(struct object_update_reply *reply, size_t count)
{
reply->ourp_magic = UPDATE_REPLY_MAGIC;
reply->ourp_count = count;
static inline struct object_update_result
*object_update_result_get(const struct object_update_reply *reply,
- int index, int *size)
+ size_t index, size_t *size)
{
char *ptr;
- int count = reply->ourp_count;
- int i;
+ size_t count = reply->ourp_count;
+ size_t i;
if (index >= count)
return NULL;
static inline void
object_update_result_insert(struct object_update_reply *reply,
- void *data, int data_len, int index,
+ void *data, size_t data_len, size_t index,
int rc)
{
struct object_update_result *update_result;
static inline int
object_update_result_data_get(const struct object_update_reply *reply,
- struct lu_buf *lbuf, int index)
+ struct lu_buf *lbuf, size_t index)
{
struct object_update_result *update_result;
- int size = 0;
- int result;
+ size_t size = 0;
+ int result;
LASSERT(lbuf != NULL);
update_result = object_update_result_get(reply, index, &size);
struct sptlrpc_flavor cl_flvr_mgc; /* fixed flavor of mgc->mgs */
/* the grant values are protected by loi_list_lock below */
- long cl_dirty_pages; /* all _dirty_ in pages */
- long cl_dirty_max_pages; /* allowed w/o rpc */
- long cl_dirty_transit; /* dirty synchronous */
- long cl_avail_grant; /* bytes of credit for ost */
- long cl_lost_grant; /* lost credits (trunc) */
+ unsigned long cl_dirty_pages; /* all _dirty_ in pages */
+ unsigned long cl_dirty_max_pages; /* allowed w/o rpc */
+ unsigned long cl_dirty_transit; /* dirty synchronous */
+ unsigned long cl_avail_grant; /* bytes of credit for ost */
+ unsigned long cl_lost_grant; /* lost credits (trunc) */
/* since we allocate grant by blocks, we don't know how many grant will
* be used to add a page into cache. As a solution, we reserve maximum
struct list_head cl_loi_hp_ready_list;
struct list_head cl_loi_write_list;
struct list_head cl_loi_read_list;
- int cl_r_in_flight;
- int cl_w_in_flight;
+ __u32 cl_r_in_flight;
+ __u32 cl_w_in_flight;
/* just a sum of the loi/lop pending numbers to be exported by /proc */
atomic_t cl_pending_w_pages;
atomic_t cl_pending_r_pages;
__u32 cl_max_pages_per_rpc;
- int cl_max_rpcs_in_flight;
+ __u32 cl_max_rpcs_in_flight;
struct obd_histogram cl_read_rpc_hist;
struct obd_histogram cl_write_rpc_hist;
struct obd_histogram cl_read_page_hist;
cli->cl_dirty_max_pages = (OSC_MAX_DIRTY_DEFAULT * 1024 * 1024)
>> PAGE_CACHE_SHIFT;
else {
- long dirty_max = cli->cl_max_rpcs_in_flight *
- cli->cl_max_pages_per_rpc;
+ unsigned long dirty_max = cli->cl_max_rpcs_in_flight *
+ cli->cl_max_pages_per_rpc;
if (dirty_max > cli->cl_dirty_max_pages)
cli->cl_dirty_max_pages = dirty_max;
cli->cl_dirty_pages, cli->cl_dirty_max_pages);
oa->o_undirty = 0;
} else {
- long max_in_flight = (cli->cl_max_pages_per_rpc <<
+ unsigned long max_in_flight = (cli->cl_max_pages_per_rpc <<
PAGE_CACHE_SHIFT) *
(cli->cl_max_rpcs_in_flight + 1);
oa->o_undirty = max(cli->cl_dirty_max_pages << PAGE_CACHE_SHIFT,
}
client_obd_list_unlock(&cli->cl_loi_list_lock);
- DEBUG_REQ(D_INODE, req, "%d pages, aa %p. now %dr/%dw in flight",
+ DEBUG_REQ(D_INODE, req, "%d pages, aa %p. now %ur/%uw in flight",
page_count, aa, cli->cl_r_in_flight,
cli->cl_w_in_flight);
void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *entry)
{
- int i;
+ __u8 i;
__swab64s(&entry->mne_version);
__swab32s(&entry->mne_instance);
void lustre_swab_fiemap(struct ll_user_fiemap *fiemap)
{
- int i;
+ __u32 i;
__swab64s(&fiemap->fm_start);
__swab64s(&fiemap->fm_length);
void lustre_swab_object_update(struct object_update *ou)
{
struct object_update_param *param;
- int i;
+ size_t i;
__swab16s(&ou->ou_type);
__swab16s(&ou->ou_params_count);
void lustre_swab_object_update_request(struct object_update_request *our)
{
- int i;
+ size_t i;
__swab32s(&our->ourq_magic);
__swab16s(&our->ourq_count);
__swab16s(&our->ourq_padding);
void lustre_swab_object_update_reply(struct object_update_reply *our)
{
- int i;
+ size_t i;
__swab32s(&our->ourp_magic);
__swab16s(&our->ourp_count);
struct lu_attr *attr = &tti->tti_attr;
struct lu_fid *fid = NULL;
struct obdo *wobdo;
- int size;
+ size_t size;
int rc;
ENTRY;
dof->dof_type = dt_mode_to_dft(attr->la_mode);
if (update->ou_params_count > 1) {
- int size;
-
fid = object_update_param_get(update, 1, &size);
if (fid == NULL || size != sizeof(*fid)) {
CERROR("%s: invalid fid: rc = %d\n",
struct dt_object *obj = tti->tti_u.update.tti_dt_object;
struct obdo *lobdo = &tti->tti_u.update.tti_obdo;
struct obdo *wobdo;
- int size;
+ size_t size;
int rc;
ENTRY;
char *name;
char *buf;
__u32 *tmp;
- int buf_len = 0;
+ size_t buf_len = 0;
int flag;
- int size = 0;
+ size_t size = 0;
int rc;
ENTRY;
tmp = object_update_param_get(update, 2, &size);
if (tmp == NULL || size != sizeof(*tmp)) {
- CERROR("%s: emptry or wrong size %d flag: rc = %d\n",
+ CERROR("%s: emptry or wrong size %zd flag: rc = %d\n",
tgt_name(tsi->tsi_tgt), size, -EPROTO);
RETURN(err_serious(-EPROTO));
}
char *name;
__u32 *ptype;
int rc = 0;
- int size;
+ size_t size;
ENTRY;
name = object_update_param_get(update, 0, NULL);
struct lu_buf *lbuf = &tti->tti_buf;
char *buf;
__u64 *tmp;
- int size = 0;
- int buf_len = 0;
+ size_t size = 0;
+ size_t buf_len = 0;
loff_t pos;
int rc;
ENTRY;
tmp = object_update_param_get(update, 1, &size);
if (tmp == NULL || size != sizeof(*tmp)) {
- CERROR("%s: empty or wrong size %d pos: rc = %d\n",
+ CERROR("%s: empty or wrong size %zd pos: rc = %d\n",
tgt_name(tsi->tsi_tgt), size, -EPROTO);
RETURN(err_serious(-EPROTO));
}