Make lu_buf->lb_len unsigned.
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I769b0a21aabb5466096e5f3e1aba4e96bcf64a6b
Reviewed-on: http://review.whamcloud.com/11281
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
* methods.
*/
struct lu_buf {
* methods.
*/
struct lu_buf {
- void *lb_buf;
- ssize_t lb_len;
+ void *lb_buf;
+ size_t lb_len;
};
#define DLUBUF "(%p %zu)"
};
#define DLUBUF "(%p %zu)"
extern struct lu_buf LU_BUF_NULL;
void lu_buf_free(struct lu_buf *buf);
extern struct lu_buf LU_BUF_NULL;
void lu_buf_free(struct lu_buf *buf);
-void lu_buf_alloc(struct lu_buf *buf, int size);
-void lu_buf_realloc(struct lu_buf *buf, int size);
+void lu_buf_alloc(struct lu_buf *buf, size_t size);
+void lu_buf_realloc(struct lu_buf *buf, size_t size);
-int lu_buf_check_and_grow(struct lu_buf *buf, int len);
-struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, int len);
+int lu_buf_check_and_grow(struct lu_buf *buf, size_t len);
+struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, size_t len);
/** @} lu */
#endif /* __LUSTRE_LU_OBJECT_H */
/** @} lu */
#endif /* __LUSTRE_LU_OBJECT_H */
struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
struct thandle *handle = NULL;
size_t buflen = buf->lb_len;
struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
struct thandle *handle = NULL;
size_t buflen = buf->lb_len;
struct lov_mds_md_v1 *lmm;
struct lov_ost_data_v1 *objs;
struct lustre_handle lh = { 0 };
struct lov_mds_md_v1 *lmm;
struct lov_ost_data_v1 *objs;
struct lustre_handle lh = { 0 };
if (rc < 0)
GOTO(unlock_layout, rc);
if (rc < 0)
GOTO(unlock_layout, rc);
- if (buf->lb_len < rc) {
- lu_buf_realloc(buf, rc);
+ lovea_size = rc;
+ if (buf->lb_len < lovea_size) {
+ lu_buf_realloc(buf, lovea_size);
buflen = buf->lb_len;
if (buf->lb_buf == NULL)
GOTO(unlock_layout, rc = -ENOMEM);
buflen = buf->lb_len;
if (buf->lb_buf == NULL)
GOTO(unlock_layout, rc = -ENOMEM);
LASSERT(rc != 0);
goto again;
} else if (rc == -ENODATA || rc == 0) {
LASSERT(rc != 0);
goto again;
} else if (rc == -ENODATA || rc == 0) {
- rc = lov_mds_md_size(ea_off + 1, LOV_MAGIC_V1);
+ lovea_size = lov_mds_md_size(ea_off + 1, LOV_MAGIC_V1);
/* If the declared is not big enough, re-try. */
/* If the declared is not big enough, re-try. */
+ if (buf->lb_len < lovea_size) {
+ rc = lovea_size;
fl = LU_XATTR_CREATE;
} else if (rc < 0) {
GOTO(unlock_parent, rc);
fl = LU_XATTR_CREATE;
} else if (rc < 0) {
GOTO(unlock_parent, rc);
goto again;
} else {
fl = LU_XATTR_REPLACE;
goto again;
} else {
fl = LU_XATTR_REPLACE;
}
if (fl == LU_XATTR_CREATE) {
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
}
if (fl == LU_XATTR_CREATE) {
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
- LASSERT(buf->lb_len >= rc);
+ LASSERT(buf->lb_len >= lovea_size);
+ buf->lb_len = lovea_size;
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, false);
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, false);
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
- LASSERT(buf->lb_len >= rc);
+ LASSERT(buf->lb_len >= lovea_size);
+ buf->lb_len = lovea_size;
memset(lmm, 0, buf->lb_len);
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, true);
memset(lmm, 0, buf->lb_len);
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, true);
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
- rc = lov_mds_md_size(ea_off + 1, magic);
+ lovea_size = lov_mds_md_size(ea_off + 1, magic);
/* If the declared is not big enough, re-try. */
/* If the declared is not big enough, re-try. */
+ if (buf->lb_len < lovea_size) {
+ rc = lovea_size;
+ }
+ buf->lb_len = lovea_size;
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, false);
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, false);
LASSERTF(rc > 0, "invalid rc = %d\n", rc);
LASSERTF(rc > 0, "invalid rc = %d\n", rc);
+ buf->lb_len = lovea_size;
for (i = 0; i < count; i++, objs++) {
/* The MDT-object was created via lfsck_layout_recover_create()
* by others before, and we fill the dummy layout EA. */
for (i = 0; i < count; i++, objs++) {
/* The MDT-object was created via lfsck_layout_recover_create()
* by others before, and we fill the dummy layout EA. */
const struct dt_it_ops *iops;
__u32 stripes;
__u32 magic = le32_to_cpu(lmv1->lmv_magic);
const struct dt_it_ops *iops;
__u32 stripes;
__u32 magic = le32_to_cpu(lmv1->lmv_magic);
if (stripes < 1)
RETURN(0);
if (stripes < 1)
RETURN(0);
- size = lmv_mds_md_size(stripes, magic);
- if (buf->lb_len < size) {
+ rc = lmv_mds_md_size(stripes, magic);
+ if (rc < 0)
+ RETURN(rc);
+ lmv1_size = rc;
+ if (buf->lb_len < lmv1_size) {
struct lu_buf tbuf;
if (!resize)
struct lu_buf tbuf;
if (!resize)
tbuf = *buf;
buf->lb_buf = NULL;
buf->lb_len = 0;
tbuf = *buf;
buf->lb_buf = NULL;
buf->lb_len = 0;
- lu_buf_alloc(buf, size);
+ lu_buf_alloc(buf, lmv1_size);
lmv1 = buf->lb_buf;
if (lmv1 == NULL)
RETURN(-ENOMEM);
lmv1 = buf->lb_buf;
if (lmv1 == NULL)
RETURN(-ENOMEM);
int start;
int count;
int bnr;
int start;
int count;
int bnr;
if (OBD_FAIL_CHECK(OBD_FAIL_OBD_NO_LRU))
RETURN(0);
if (OBD_FAIL_CHECK(OBD_FAIL_OBD_NO_LRU))
RETURN(0);
/**
* Return desired hash table order.
*/
/**
* Return desired hash table order.
*/
-static int lu_htable_order(struct lu_device *top)
+static unsigned int lu_htable_order(struct lu_device *top)
- unsigned long cache_size;
- int bits;
+ unsigned long cache_size;
+ unsigned int bits;
/*
* For ZFS based OSDs the cache should be disabled by default. This
/*
* For ZFS based OSDs the cache should be disabled by default. This
struct lu_site_bkt_data *bkt;
cfs_hash_bd_t bd;
char name[16];
struct lu_site_bkt_data *bkt;
cfs_hash_bd_t bd;
char name[16];
+ unsigned int bits;
+ unsigned int i;
ENTRY;
memset(s, 0, sizeof *s);
mutex_init(&s->ls_purge_mutex);
bits = lu_htable_order(top);
snprintf(name, 16, "lu_site_%s", top->ld_type->ldt_name);
ENTRY;
memset(s, 0, sizeof *s);
mutex_init(&s->ls_purge_mutex);
bits = lu_htable_order(top);
snprintf(name, 16, "lu_site_%s", top->ld_type->ldt_name);
- for (bits = min(max(LU_SITE_BITS_MIN, bits), LU_SITE_BITS_MAX);
+ for (bits = clamp_t(typeof(bits), bits,
+ LU_SITE_BITS_MIN, LU_SITE_BITS_MAX);
bits >= LU_SITE_BITS_MIN; bits--) {
s->ls_obj_hash = cfs_hash_create(name, bits, bits,
bits - LU_SITE_BKT_BITS,
bits >= LU_SITE_BITS_MIN; bits--) {
s->ls_obj_hash = cfs_hash_create(name, bits, bits,
bits - LU_SITE_BKT_BITS,
*/
int lu_context_key_register(struct lu_context_key *key)
{
*/
int lu_context_key_register(struct lu_context_key *key)
{
+ int result;
+ unsigned int i;
LASSERT(key->lct_init != NULL);
LASSERT(key->lct_fini != NULL);
LASSERT(key->lct_init != NULL);
LASSERT(key->lct_fini != NULL);
static void keys_fini(struct lu_context *ctx)
{
static void keys_fini(struct lu_context *ctx)
{
if (ctx->lc_value == NULL)
return;
if (ctx->lc_value == NULL)
return;
static int keys_fill(struct lu_context *ctx)
{
static int keys_fill(struct lu_context *ctx)
{
LINVRNT(ctx->lc_value != NULL);
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
LINVRNT(ctx->lc_value != NULL);
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
*/
void lu_context_exit(struct lu_context *ctx)
{
*/
void lu_context_exit(struct lu_context *ctx)
{
LINVRNT(ctx->lc_state == LCS_ENTERED);
ctx->lc_state = LCS_LEFT;
LINVRNT(ctx->lc_state == LCS_ENTERED);
ctx->lc_state = LCS_LEFT;
static void lu_site_stats_get(cfs_hash_t *hs,
lu_site_stats_t *stats, int populated)
{
static void lu_site_stats_get(cfs_hash_t *hs,
lu_site_stats_t *stats, int populated)
{
- cfs_hash_bd_t bd;
- int i;
+ cfs_hash_bd_t bd;
+ unsigned int i;
cfs_hash_for_each_bucket(hs, &bd, i) {
struct lu_site_bkt_data *bkt = cfs_hash_bd_extra_get(hs, &bd);
cfs_hash_for_each_bucket(hs, &bd, i) {
struct lu_site_bkt_data *bkt = cfs_hash_bd_extra_get(hs, &bd);
void lu_context_keys_dump(void)
{
void lu_context_keys_dump(void)
{
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
struct lu_context_key *key;
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
struct lu_context_key *key;
}
EXPORT_SYMBOL(lu_buf_free);
}
EXPORT_SYMBOL(lu_buf_free);
-void lu_buf_alloc(struct lu_buf *buf, int size)
+void lu_buf_alloc(struct lu_buf *buf, size_t size)
{
LASSERT(buf);
LASSERT(buf->lb_buf == NULL);
{
LASSERT(buf);
LASSERT(buf->lb_buf == NULL);
}
EXPORT_SYMBOL(lu_buf_alloc);
}
EXPORT_SYMBOL(lu_buf_alloc);
-void lu_buf_realloc(struct lu_buf *buf, int size)
+void lu_buf_realloc(struct lu_buf *buf, size_t size)
{
lu_buf_free(buf);
lu_buf_alloc(buf, size);
}
EXPORT_SYMBOL(lu_buf_realloc);
{
lu_buf_free(buf);
lu_buf_alloc(buf, size);
}
EXPORT_SYMBOL(lu_buf_realloc);
-struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, int len)
+struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, size_t len)
{
if (buf->lb_buf == NULL && buf->lb_len == 0)
lu_buf_alloc(buf, len);
{
if (buf->lb_buf == NULL && buf->lb_len == 0)
lu_buf_alloc(buf, len);
* old buffer remains unchanged on error
* \retval 0 or -ENOMEM
*/
* old buffer remains unchanged on error
* \retval 0 or -ENOMEM
*/
-int lu_buf_check_and_grow(struct lu_buf *buf, int len)
+int lu_buf_check_and_grow(struct lu_buf *buf, size_t len)