Description: Not Check whether lov_tgts is NULL in some lov functions
Details : Checking whether lov_tgts is NULL in some functions.
+Severity : normal
+Bugzilla : 11815
+Description: replace obdo_alloc() with OBDO_ALLOC macro
+Details : nothing special is done in obdo_alloc() function, and for
+ debugging purpose, it needs to be replaced with macros.
+
--------------------------------------------------------------------------------
2007-05-03 Cluster File Systems, Inc. <info@clusterfs.com>
/* support routines */
extern cfs_mem_cache_t *obdo_cachep;
-static inline struct obdo *obdo_alloc(void)
-{
- struct obdo *oa;
-
- OBD_SLAB_ALLOC(oa, obdo_cachep, CFS_ALLOC_STD, sizeof(*oa));
- return oa;
-}
+#define OBDO_ALLOC(ptr) \
+do { \
+ OBD_SLAB_ALLOC_PTR((ptr), obdo_cachep); \
+} while(0)
-static inline void obdo_free(struct obdo *oa)
-{
- OBD_SLAB_FREE(oa, obdo_cachep, sizeof(*oa));
-}
+#define OBDO_FREE(ptr) \
+do { \
+ OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \
+} while(0)
/* I'm as embarrassed about this as you are.
*
(ptr) = (void *)0xdeadbeef; \
} while (0)
+#define OBD_SLAB_ALLOC_PTR(ptr, slab) \
+ OBD_SLAB_ALLOC((ptr), (slab), CFS_ALLOC_STD, sizeof *(ptr))
+#define OBD_SLAB_FREE_PTR(ptr, slab) \
+ OBD_SLAB_FREE((ptr), (slab), sizeof *(ptr))
+
#define KEY_IS(str) (keylen >= strlen(key) && strcmp(key, str) == 0)
#if defined(__linux__)
}
LASSERT(rc >= sizeof(*lsm));
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
GOTO(out_free_memmd, rc = -ENOMEM);
}
rc = obd_destroy(llu_i2obdexp(dir), oa, lsm, &oti, NULL);
- obdo_free(oa);
+ OBDO_FREE(oa);
if (rc)
CERROR("obd destroy objid 0x"LPX64" error %d\n",
lsm->lsm_object_id, rc);
if (obd->obd_no_recov)
GOTO(out, rc = 0);
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (!oa)
RETURN(-ENOMEM); // XXX We leak openhandle and request here.
inode->i_ino, rc);
}
- obdo_free(oa);
+ OBDO_FREE(oa);
if (rc == 0) {
rc = ll_objects_destroy(req, inode);
if (rc) {
RETURN(-EFAULT);
}
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
RETURN(-ENOMEM);
GOTO(out, rc);
out:
up(&lli->lli_size_sem);
- obdo_free(oa);
+ OBDO_FREE(oa);
return rc;
}
ptlrpc_req_finished(req);
if (data && lsm) {
- struct obdo *oa = obdo_alloc();
+ struct obdo *oa;
+ OBDO_ALLOC(oa);
if (!oa)
RETURN(rc ? rc : -ENOMEM);
0, OBD_OBJECT_EOF);
if (!rc)
rc = err;
- obdo_free(oa);
+ OBDO_FREE(oa);
}
RETURN(rc);
} else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
obd_flag flags;
struct obd_info oinfo = { { { 0 } } };
- struct obdo *oa = obdo_alloc();
+ struct obdo *oa;
+ OBDO_ALLOC(oa);
CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
inode->i_ino, LTIME_S(attr->ia_mtime));
rc = obd_setattr_rqset(sbi->ll_osc_exp, &oinfo, NULL);
if (rc)
CERROR("obd_setattr_async fails: rc=%d\n", rc);
- obdo_free(oa);
+ OBDO_FREE(oa);
} else {
rc = -ENOMEM;
}
RETURN(-EFAULT);
oinfo.oi_md = lsm;
- oinfo.oi_oa = obdo_alloc();
+ OBDO_ALLOC(oinfo.oi_oa);
if (!oinfo.oi_oa)
RETURN(-ENOMEM);
(struct iattr *)&attr, NULL, 0, NULL, 0, &req);
ptlrpc_req_finished(req);
if (rc || lsm == NULL) {
- obdo_free(oinfo.oi_oa);
+ OBDO_FREE(oinfo.oi_oa);
RETURN(rc);
}
obdo_from_inode(oinfo.oi_oa, inode,
OBD_MD_FLFID | OBD_MD_FLGENER);
rc = obd_setattr_rqset(sbi->ll_osc_exp, &oinfo, NULL);
- obdo_free(oinfo.oi_oa);
+ OBDO_FREE(oinfo.oi_oa);
if (rc) {
if (rc != -EPERM && rc != -EACCES)
CERROR("mdc_setattr_async fails: rc = %d\n", rc);
if (rc)
GOTO(out_free_memmd, rc);
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
GOTO(out_free_memmd, rc = -ENOMEM);
}
rc = obd_destroy(ll_i2obdexp(dir), oa, lsm, &oti, ll_i2mdcexp(dir));
- obdo_free(oa);
+ OBDO_FREE(oa);
if (rc)
CERROR("obd destroy objid "LPX64" error %d\n",
lsm->lsm_object_id, rc);
lov = &export->exp_obd->u.lov;
- tmp_oa = obdo_alloc();
+ OBDO_ALLOC(tmp_oa);
if (tmp_oa == NULL)
RETURN(-ENOMEM);
}
lov_putref(export->exp_obd);
- obdo_free(tmp_oa);
+ OBDO_FREE(tmp_oa);
RETURN(rc);
}
if (req->rq_oi.oi_md == NULL)
GOTO(out_err, rc = -ENOMEM);
- req->rq_oi.oi_oa = obdo_alloc();
+ OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL)
GOTO(out_err, rc = -ENOMEM);
list_del_init(&req->rq_link);
if (req->rq_oi.oi_oa)
- obdo_free(req->rq_oi.oi_oa);
+ OBDO_FREE(req->rq_oi.oi_oa);
if (req->rq_oi.oi_md)
OBD_FREE(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_osfs)
qos_shrink_lsm(set);
}
- ret_oa = obdo_alloc();
+ OBDO_ALLOC(ret_oa);
if (ret_oa == NULL)
GOTO(cleanup, rc = -ENOMEM);
}
ret_oa->o_id = src_oa->o_id;
memcpy(src_oa, ret_oa, sizeof(*src_oa));
- obdo_free(ret_oa);
+ OBDO_FREE(ret_oa);
*lsmp = set->set_oi->oi_md;
GOTO(done, rc = 0);
if (!set->set_success)
RETURN(-EIO);
- tmp_oa = obdo_alloc();
+ OBDO_ALLOC(tmp_oa);
if (tmp_oa == NULL)
GOTO(out, rc = -ENOMEM);
memcpy(set->set_oi->oi_oa, tmp_oa, sizeof(*set->set_oi->oi_oa));
out:
if (tmp_oa)
- obdo_free(tmp_oa);
+ OBDO_FREE(tmp_oa);
RETURN(rc);
}
if (req == NULL)
GOTO(out, rc = -ENOMEM);
- req->rq_oi.oi_oa = obdo_alloc();
+ OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out, rc = -ENOMEM);
req->rq_buflen = sizeof(*req->rq_oi.oi_md);
OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_md == NULL) {
- obdo_free(req->rq_oi.oi_oa);
+ OBDO_FREE(req->rq_oi.oi_oa);
OBD_FREE(req, sizeof(*req));
GOTO(out, rc = -ENOMEM);
}
req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx;
- req->rq_oi.oi_oa = obdo_alloc();
+ OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out_set, rc = -ENOMEM);
req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx;
- req->rq_oi.oi_oa = obdo_alloc();
+ OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out_set, rc = -ENOMEM);
req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx;
- req->rq_oi.oi_oa = obdo_alloc();
+ OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out_set, rc = -ENOMEM);
req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx;
- req->rq_oi.oi_oa = obdo_alloc();
+ OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out_set, rc = -ENOMEM);
req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx;
- req->rq_oi.oi_oa = obdo_alloc();
+ OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out_set, rc = -ENOMEM);
if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_ALLOC_OBDO))
GOTO(out_ids, rc = -ENOMEM);
- oinfo.oi_oa = obdo_alloc();
+ OBDO_ALLOC(oinfo.oi_oa);
if (oinfo.oi_oa == NULL)
GOTO(out_ids, rc = -ENOMEM);
oinfo.oi_oa->o_uid = 0; /* must have 0 uid / gid on OST */
obd_free_diskmd(mds->mds_osc_exp, &lmm);
out_oa:
oti_free_cookies(&oti);
- obdo_free(oinfo.oi_oa);
+ OBDO_FREE(oinfo.oi_oa);
out_ids:
if (rc) {
OBD_FREE(*ids, mds->mds_lov_desc.ld_tgt_count * sizeof(**ids));
RETURN(0);
/* first get memory EA */
- oinfo.oi_oa = obdo_alloc();
+ OBDO_ALLOC(oinfo.oi_oa);
if (!oinfo.oi_oa)
RETURN(-ENOMEM);
out:
if (oinfo.oi_md)
obd_free_memmd(mds->mds_osc_exp, &oinfo.oi_md);
- obdo_free(oinfo.oi_oa);
+ OBDO_FREE(oinfo.oi_oa);
RETURN(rc);
}
if (rc)
GOTO(out_free_memmd, rc);
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
GOTO(out_free_memmd, rc = -ENOMEM);
oa->o_id = lsm->lsm_object_id;
oti.oti_logcookies = logcookies;
}
rc = obd_destroy(mds->mds_osc_exp, oa, lsm, &oti, obd->obd_self_export);
- obdo_free(oa);
+ OBDO_FREE(oa);
if (rc)
CDEBUG(D_INODE, "destroy orphan objid 0x"LPX64" on ost error "
"%d\n", lsm->lsm_object_id, rc);
handle->lgh_id.lgl_ogen =
handle->lgh_file->f_dentry->d_inode->i_generation;
} else {
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
GOTO(cleanup, rc = -ENOMEM);
handle->lgh_ctxt = ctxt;
finish:
if (oa)
- obdo_free(oa);
+ OBDO_FREE(oa);
RETURN(rc);
cleanup:
switch (cleanup_phase) {
RETURN(rc);
}
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
RETURN(-ENOMEM);
rc = obd_destroy(handle->lgh_ctxt->loc_exp, oa, NULL, NULL, NULL);
out:
- obdo_free(oa);
+ OBDO_FREE(oa);
RETURN(rc);
}
ENTRY;
lur = (struct llog_unlink_rec *)rec;
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
RETURN(-ENOMEM);
oa->o_valid |= OBD_MD_FLCOOKIE;
oid = oa->o_id;
rc = filter_destroy(exp, oa, NULL, NULL, NULL);
- obdo_free(oa);
+ OBDO_FREE(oa);
if (rc == -ENOENT) {
CDEBUG(D_HA, "object already removed, send cookie\n");
llog_cancel(ctxt, NULL, 1, cookie, 0);
ENTRY;
lsr = (struct llog_setattr_rec *)rec;
- oinfo.oi_oa = obdo_alloc();
+ OBDO_ALLOC(oinfo.oi_oa);
oinfo.oi_oa->o_valid |= (OBD_MD_FLID | OBD_MD_FLUID | OBD_MD_FLGID |
OBD_MD_FLCOOKIE);
oid = oinfo.oi_oa->o_id;
rc = filter_setattr(exp, &oinfo, NULL);
- obdo_free(oinfo.oi_oa);
+ OBDO_FREE(oinfo.oi_oa);
if (rc == -ENOENT) {
CDEBUG(D_HA, "object already removed, send cookie\n");
*oinfo->oi_oa = *saved_oa;
} else if (page_count > pages_per_brw) {
/* save a copy of oa (brw will clobber it) */
- saved_oa = obdo_alloc();
+ OBDO_ALLOC(saved_oa);
if (saved_oa == NULL)
GOTO(out, rc = -ENOMEM);
*saved_oa = *oinfo->oi_oa;
osc_release_ppga(orig, page_count_orig);
if (saved_oa != NULL)
- obdo_free(saved_oa);
+ OBDO_FREE(saved_oa);
RETURN(rc);
}
client_obd_list_unlock(&cli->cl_loi_list_lock);
- obdo_free(aa->aa_oa);
+ OBDO_FREE(aa->aa_oa);
osc_release_ppga(aa->aa_ppga, aa->aa_page_count);
RETURN(rc);
if (pga == NULL)
RETURN(ERR_PTR(-ENOMEM));
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
GOTO(out, req = ERR_PTR(-ENOMEM));
out:
if (IS_ERR(req)) {
if (oa)
- obdo_free(oa);
+ OBDO_FREE(oa);
if (pga)
OBD_FREE(pga, sizeof(*pga) * page_count);
}
struct obd_async_page_ops *ops;
struct obdo *oa;
- oa = obdo_alloc();
+ OBDO_ALLOC(oa);
if (oa == NULL)
RETURN(-ENOMEM);
NO_QUOTA)
rc = -EDQUOT;
- obdo_free(oa);
+ OBDO_FREE(oa);
if (rc)
RETURN(rc);
}