Make few members/variables related to size or indexes as unsigned.
Fix incorrect comparison between signed and unsigned variables.
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I1bb3dff189e5ad4f37c7696ffd51832af60bd8f1
Reviewed-on: http://review.whamcloud.com/11316
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
#endif
typedef struct {
- int size;
- unsigned long data[0];
+ unsigned int size;
+ unsigned long data[0];
} cfs_bitmap_t;
#define CFS_BITMAP_SIZE(nbits) \
static inline
void cfs_bitmap_copy(cfs_bitmap_t *new, cfs_bitmap_t *old)
{
- int newsize;
+ size_t newsize;
LASSERT(new->size >= old->size);
newsize = new->size;
struct list_head ltd_orphan;
/* number of registered TGTs */
- int ltd_tgtnr;
+ __u32 ltd_tgtnr;
};
#define LTD_TGT(ltd, index) \
{
struct lu_device *next;
int rc = 0;
- int i;
+ unsigned int i;
lod_getref(ltd);
if (ltd->ltd_tgts_size <= 0) {
{
struct lod_device *lod = lu2lod_dev(dev);
struct lu_device *next = &lod->lod_child->dd_lu_dev;
- int i, rc;
+ unsigned int i;
+ int rc;
ENTRY;
LASSERT(lod->lod_recovery_completed == 0);
{
struct lod_device *lod = dt2lod_dev(dev);
struct lod_ost_desc *ost;
- int rc = 0, i;
+ unsigned int i;
+ int rc = 0;
ENTRY;
lod_getref(&lod->lod_ost_descs);
struct obd_device *obd = exp->exp_obd;
struct lod_device *d;
struct lod_ost_desc *ost;
- int i, rc = 1;
+ unsigned int i;
+ int rc = 1;
if (!obd->obd_set_up || obd->obd_stopping)
RETURN(-EAGAIN);
/* Size of the lod_tgts array, granted to be a power of 2 */
__u32 ltd_tgts_size;
/* number of registered TGTs */
- int ltd_tgtnr;
+ __u32 ltd_tgtnr;
/* bitmap of TGTs available */
cfs_bitmap_t *ltd_tgt_bitmap;
/* TGTs scheduled to be deleted */
struct lod_thread_info {
/* per-thread buffer for LOV EA */
void *lti_ea_store;
- int lti_ea_store_size;
+ __u32 lti_ea_store_size;
/* per-thread buffer for LMV EA */
struct lu_buf lti_buf;
struct ost_id lti_ostid;
bool is_from_disk);
int lod_generate_and_set_lovea(const struct lu_env *env,
struct lod_object *mo, struct thandle *th);
-int lod_ea_store_resize(struct lod_thread_info *info, int size);
+int lod_ea_store_resize(struct lod_thread_info *info, size_t size);
/* lod_pool.c */
int lod_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count);
int lod_ost_pool_remove(struct ost_pool *op, __u32 idx);
ltd->ltd_refcount--;
if (ltd->ltd_refcount == 0 && ltd->ltd_death_row) {
struct lod_tgt_desc *tgt_desc, *tmp;
- int idx;
+ unsigned int idx;
CFS_LIST_HEAD(kill);
CDEBUG(D_CONFIG, "destroying %d ltd desc\n",
int lod_fini_tgt(const struct lu_env *env, struct lod_device *lod,
struct lod_tgt_descs *ltd, bool for_ost)
{
- int idx;
+ unsigned int idx;
if (ltd->ltd_tgts_size <= 0)
return 0;
return(rc);
}
-int lod_ea_store_resize(struct lod_thread_info *info, int size)
+int lod_ea_store_resize(struct lod_thread_info *info, size_t size)
{
- int round = size_roundup_power2(size);
+ __u32 round = size_roundup_power2(size);
LASSERT(round <=
lov_mds_md_size(LOV_MAX_STRIPE_COUNT, LOV_MAGIC_V3));
struct lov_mds_md_v1 *lmm;
struct lov_ost_data_v1 *objs;
__u32 magic;
- int i, rc, lmm_size;
- int cplen = 0;
+ int i, rc;
+ size_t lmm_size;
ENTRY;
LASSERT(lo);
objs = &lmm->lmm_objects[0];
} else {
struct lov_mds_md_v3 *v3 = (struct lov_mds_md_v3 *) lmm;
- cplen = strlcpy(v3->lmm_pool_name, lo->ldo_pool,
+ size_t cplen = strlcpy(v3->lmm_pool_name, lo->ldo_pool,
sizeof(v3->lmm_pool_name));
if (cplen >= sizeof(v3->lmm_pool_name))
RETURN(-E2BIG);
RETURN(rc);
}
-static int validate_lod_and_idx(struct lod_device *md, int idx)
+static int validate_lod_and_idx(struct lod_device *md, __u32 idx)
{
if (unlikely(idx >= md->lod_ost_descs.ltd_tgts_size ||
!cfs_bitmap_check(md->lod_ost_bitmap, idx))) {
struct lu_device *nd;
struct dt_object **stripe;
int stripe_len;
- int i, idx, rc = 0;
+ int i, rc = 0;
+ __u32 idx;
ENTRY;
LASSERT(lo != NULL);
rc = lod_parse_striping(env, lo, buf);
} else if (S_ISDIR(lu_object_attr(lod2lu_obj(lo)))) {
rc = lod_get_lmv_ea(env, lo);
- if (rc < sizeof(struct lmv_mds_md_v1))
+ if (rc < (typeof(rc))sizeof(struct lmv_mds_md_v1))
GOTO(out, rc = rc > 0 ? -EINVAL : rc);
buf->lb_buf = info->lti_ea_store;
const struct dt_it_ops *iops;
__u32 stripes;
__u32 magic = le32_to_cpu(lmv1->lmv_magic);
- int size;
+ size_t size;
int rc;
ENTRY;
struct lmv_mds_md_v1 *lmv1;
int rc1 = 0;
- if (rc > sizeof(*lmv1))
+ if (rc > (typeof(rc))sizeof(*lmv1))
RETURN(rc);
- if (rc < sizeof(*lmv1))
+ if (rc < (typeof(rc))sizeof(*lmv1))
RETURN(rc = rc > 0 ? -EINVAL : rc);
if (buf->lb_buf == NULL || buf->lb_len == 0) {
union lmv_mds_md *lmm = buf->lb_buf;
struct lmv_mds_md_v1 *lmv1 = &lmm->lmv_md_v1;
struct lu_fid *fid = &info->lti_fid;
- int i;
+ unsigned int i;
int rc = 0;
ENTRY;
struct lmv_mds_md_v1 *lmm;
struct lmv_mds_md_v1 *slave_lmm = NULL;
struct dt_insert_rec *rec = &info->lti_dt_rec;
- int stripe_count;
+ __u32 stripe_count;
int *idx_array;
int rc = 0;
- int i;
- int j;
+ __u32 i;
+ __u32 j;
ENTRY;
/* The lum has been verifed in lod_verify_md_striping */
for (j = 0; j < lod->lod_remote_mdt_count;
j++, idx = (idx + 1) % (lod->lod_remote_mdt_count + 1)) {
bool already_allocated = false;
- int k;
+ __u32 k;
- CDEBUG(D_INFO, "try idx %d, mdt cnt %d,"
- " allocated %d, last allocated %d\n", idx,
+ CDEBUG(D_INFO, "try idx %d, mdt cnt %u,"
+ " allocated %u, last allocated %d\n", idx,
lod->lod_remote_mdt_count, i, idx_array[i - 1]);
/* Find next available target */
/* Can not allocate more stripes */
if (j == lod->lod_remote_mdt_count) {
- CDEBUG(D_INFO, "%s: require stripes %d only get %d\n",
+ CDEBUG(D_INFO, "%s: require stripes %u only get %d\n",
lod2obd(lod)->obd_name, stripe_count, i - 1);
break;
}
- CDEBUG(D_INFO, "idx %d, mdt cnt %d,"
- " allocated %d, last allocated %d\n", idx,
+ CDEBUG(D_INFO, "idx %d, mdt cnt %u,"
+ " allocated %u, last allocated %d\n", idx,
lod->lod_remote_mdt_count, i, idx_array[i - 1]);
next:
if (rc != 0)
GOTO(out_put, rc);
- snprintf(stripe_name, sizeof(info->lti_key), DFID":%d",
+ snprintf(stripe_name, sizeof(info->lti_key), DFID":%u",
PFID(lu_object_fid(&dto->do_lu)), i);
sname = lod_name_get(env, stripe_name, strlen(stripe_name));
if (rc < 0)
GOTO(unlock, rc);
- if (rc < sizeof(struct lov_user_md)) {
+ if (rc < (typeof(rc))sizeof(struct lov_user_md)) {
/* don't lookup for non-existing or invalid striping */
lp->ldo_def_striping_set = 0;
lp->ldo_striping_cached = 1;
if (rc < 0)
GOTO(unlock, rc);
- if (rc < sizeof(struct lmv_user_md)) {
+ if (rc < (typeof(rc))sizeof(struct lmv_user_md)) {
/* don't lookup for non-existing or invalid striping */
lp->ldo_dir_def_striping_set = 0;
lp->ldo_dir_striping_cached = 1;
struct lod_object *lo = lod_dt_obj(dt);
struct lod_thread_info *info = lod_env_info(env);
char *stripe_name = info->lti_key;
- int rc, i;
+ unsigned int i;
+ int rc;
ENTRY;
/* destroy sub-stripe of master object */
#define POOL_IT_MAGIC 0xB001CEA0
struct lod_pool_iterator {
- int lpi_magic; /* POOL_IT_MAGIC */
- int lpi_idx; /* from 0 to pool_tgt_size - 1 */
+ unsigned int lpi_magic; /* POOL_IT_MAGIC */
+ unsigned int lpi_idx; /* from 0 to pool_tgt_size - 1 */
struct pool_desc *lpi_pool;
};
*/
void lod_dump_pool(int level, struct pool_desc *pool)
{
- int i;
+ unsigned int i;
pool_getref(pool);
*/
int lod_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count)
{
- int rc = 0, i;
+ unsigned int i;
+ int rc = 0;
ENTRY;
down_write(&op->op_rw_sem);
*/
int lod_ost_pool_remove(struct ost_pool *op, __u32 idx)
{
- int i;
+ unsigned int i;
ENTRY;
down_write(&op->op_rw_sem);
*/
int lod_check_index_in_pool(__u32 idx, struct pool_desc *pool)
{
- int i, rc;
+ unsigned int i;
+ int rc;
ENTRY;
pool_getref(pool);
{
struct obd_device *obd = lod2obd(lod);
struct ost_pool *osts = &(lod->lod_pool_info);
- int i, idx, rc = 0;
+ unsigned int i;
+ int idx, rc = 0;
__u64 max_age, avail;
ENTRY;
struct lod_qos_oss *oss;
__u64 ba_max, ba_min, temp;
__u32 num_active;
- int rc, i, prio_wide;
+ unsigned int i;
+ int rc, prio_wide;
time_t now, age;
ENTRY;
{
struct lod_tgt_desc *ost;
struct lod_qos_oss *oss;
- int j;
+ unsigned int j;
ENTRY;
ost = OST_TGT(lod,index);
struct lod_qos_oss *oss;
struct lod_tgt_desc *ost;
unsigned placed, real_count;
- int i, rc;
+ unsigned int i;
+ int rc;
ENTRY;
if (!lqr->lqr_dirty) {
*/
static struct dt_object *lod_qos_declare_object_on(const struct lu_env *env,
struct lod_device *d,
- int ost_idx,
+ __u32 ost_idx,
struct thandle *th)
{
struct lod_tgt_desc *ost;
ENTRY;
LASSERT(d);
- LASSERT(ost_idx >= 0);
LASSERT(ost_idx < d->lod_osts_size);
ost = OST_TGT(d,ost_idx);
LASSERT(ost);
RETURN(dt);
}
-static int min_stripe_count(int stripe_cnt, int flags)
+static int min_stripe_count(__u32 stripe_cnt, int flags)
{
return (flags & LOV_USES_DEFAULT_STRIPE ?
stripe_cnt - (stripe_cnt / 4) : stripe_cnt);
return (msfs->os_bavail < used);
}
-static inline int lod_qos_ost_in_use_clear(const struct lu_env *env, int stripes)
+static inline int lod_qos_ost_in_use_clear(const struct lu_env *env,
+ __u32 stripes)
{
struct lod_thread_info *info = lod_env_info(env);
osts[idx] = ost;
}
-static int lod_qos_is_ost_used(const struct lu_env *env, int ost, int stripes)
+static int lod_qos_is_ost_used(const struct lu_env *env, int ost, __u32 stripes)
{
struct lod_thread_info *info = lod_env_info(env);
int *osts = info->lti_ea_store;
- int j;
+ __u32 j;
for (j = 0; j < stripes; j++) {
if (osts[j] == ost)
struct ost_pool *osts;
struct lod_qos_rr *lqr;
struct dt_object *o;
- unsigned array_idx;
- int i, rc;
- int ost_start_idx_temp;
+ unsigned int i, array_idx;
+ int rc;
+ __u32 ost_start_idx_temp;
int speed = 0;
- int stripe_idx = 0;
- int stripe_cnt = lo->ldo_stripenr;
- int stripe_cnt_min = min_stripe_count(stripe_cnt, flags);
+ __u32 stripe_idx = 0;
+ __u32 stripe_cnt = lo->ldo_stripenr;
+ __u32 stripe_cnt_min = min_stripe_count(stripe_cnt, flags);
__u32 ost_idx;
ENTRY;
struct lod_device *m = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev);
struct obd_statfs *sfs = &lod_env_info(env)->lti_osfs;
struct dt_object *o;
- unsigned ost_idx, array_idx, ost_count;
- int i, rc, stripe_num = 0;
+ __u32 ost_idx;
+ unsigned int i, array_idx, ost_count;
+ int rc, stripe_num = 0;
int speed = 0;
struct pool_desc *pool = NULL;
struct ost_pool *osts;
struct lod_tgt_desc *ost;
struct dt_object *o;
__u64 total_weight = 0;
- int nfound, good_osts, i, rc = 0;
- int stripe_cnt = lo->ldo_stripenr;
- int stripe_cnt_min;
+ unsigned int i;
+ int rc = 0;
+ __u32 nfound, good_osts;
+ __u32 stripe_cnt = lo->ldo_stripenr;
+ __u32 stripe_cnt_min;
struct pool_desc *pool = NULL;
struct ost_pool *osts;
ENTRY;
/* On average, this will hit larger-weighted osts more often.
0-weight osts will always get used last (only when rand=0) */
for (i = 0; i < osts->op_count; i++) {
- int idx = osts->op_array[i];
+ __u32 idx = osts->op_array[i];
if (!cfs_bitmap_check(m->lod_ost_bitmap, idx))
continue;
struct lu_device *next;
struct lustre_cfg *lcfg;
char str[32];
- int val, rc, i;
+ unsigned int i;
+ int val, rc;
LASSERT(dev != NULL);
lod = lu2lod_dev(dev->obd_lu_dev);