The osp_update_rpc_pack() macro was using both an operation "name"
argument as well as an "opcode" argument, but totally ignoring the
"opcode" argument. This allowed a caller in osp_attr_set() to pass
a non-existent opcode name to the function that was ignored.
The function also concatenated the passed name string to generate
a function name to be called (which supplied its own opcode value).
This name concatenation obscures the code functionality, since the
called functions are not actually referenced directly in the code.
Instead, pass the function name as the argument, and drop the opcode
completely. This at least makes it possible to see where the function
is being called. Change the macro to be upper-case, so that it is
more clear that it is a macro rather than a real function. It would
be better to replace the macro with an actual function, but this is
not very practical due to the use of variable-length argument lists.
Test-Parameters: trivial
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I7bf5c1d0f7a9abab1d8de8046cc408961f3ebbe5
Reviewed-on: https://review.whamcloud.com/33107
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
int osp_object_update_request_create(struct osp_update_request *our,
size_t size);
int osp_object_update_request_create(struct osp_update_request *our,
size_t size);
-#define osp_update_rpc_pack(env, name, our, op, ...) \
+#define OSP_UPDATE_RPC_PACK(env, out_something_pack, our, ...) \
- struct object_update *object_update; \
- size_t max_update_length; \
+ struct object_update *object_update; \
+ size_t max_update_length; \
struct osp_update_request_sub *ours; \
int ret; \
\
struct osp_update_request_sub *ours; \
int ret; \
\
\
object_update = update_buffer_get_update(ours->ours_req,\
ours->ours_req->ourq_count); \
\
object_update = update_buffer_get_update(ours->ours_req,\
ours->ours_req->ourq_count); \
- ret = out_##name##_pack(env, object_update, \
- &max_update_length, \
- __VA_ARGS__); \
+ ret = out_something_pack(env, object_update, \
+ &max_update_length, \
+ __VA_ARGS__); \
if (ret == -E2BIG) { \
int rc1; \
/* Create new object update request */ \
if (ret == -E2BIG) { \
int rc1; \
/* Create new object update request */ \
struct lu_attr *attr, struct dt_allocation_hint *hint,
struct dt_object_format *dof, struct thandle *th)
{
struct lu_attr *attr, struct dt_allocation_hint *hint,
struct dt_object_format *dof, struct thandle *th)
{
- struct osp_update_request *update;
- struct osp_object *obj = dt2osp_obj(dt);
- int rc;
+ struct osp_update_request *update;
+ struct osp_object *obj = dt2osp_obj(dt);
+ int rc;
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
LASSERT(attr->la_valid & LA_TYPE);
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
LASSERT(attr->la_valid & LA_TYPE);
- rc = osp_update_rpc_pack(env, create, update, OUT_CREATE,
+ rc = OSP_UPDATE_RPC_PACK(env, out_create_pack, update,
lu_object_fid(&dt->do_lu), attr, hint, dof);
if (rc != 0)
GOTO(out, rc);
lu_object_fid(&dt->do_lu), attr, hint, dof);
if (rc != 0)
GOTO(out, rc);
static int osp_md_ref_del(const struct lu_env *env, struct dt_object *dt,
struct thandle *th)
{
static int osp_md_ref_del(const struct lu_env *env, struct dt_object *dt,
struct thandle *th)
{
- struct osp_update_request *update;
- int rc;
+ struct osp_update_request *update;
+ int rc;
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
- rc = osp_update_rpc_pack(env, ref_del, update, OUT_REF_DEL,
+ rc = OSP_UPDATE_RPC_PACK(env, out_ref_del_pack, update,
lu_object_fid(&dt->do_lu));
return rc;
}
lu_object_fid(&dt->do_lu));
return rc;
}
static int osp_md_ref_add(const struct lu_env *env, struct dt_object *dt,
struct thandle *th)
{
static int osp_md_ref_add(const struct lu_env *env, struct dt_object *dt,
struct thandle *th)
{
- struct osp_update_request *update;
- int rc;
+ struct osp_update_request *update;
+ int rc;
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
- rc = osp_update_rpc_pack(env, ref_add, update, OUT_REF_ADD,
+ rc = OSP_UPDATE_RPC_PACK(env, out_ref_add_pack, update,
lu_object_fid(&dt->do_lu));
return rc;
}
lu_object_fid(&dt->do_lu));
return rc;
}
int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt,
const struct lu_attr *attr, struct thandle *th)
{
int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt,
const struct lu_attr *attr, struct thandle *th)
{
- struct osp_update_request *update;
- int rc;
+ struct osp_update_request *update;
+ int rc;
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
- rc = osp_update_rpc_pack(env, attr_set, update, OUT_ATTR_SET,
+ rc = OSP_UPDATE_RPC_PACK(env, out_attr_set_pack, update,
lu_object_fid(&dt->do_lu), attr);
return rc;
}
lu_object_fid(&dt->do_lu), attr);
return rc;
}
if (IS_ERR(update))
RETURN(PTR_ERR(update));
if (IS_ERR(update))
RETURN(PTR_ERR(update));
- rc = osp_update_rpc_pack(env, index_lookup, update, OUT_INDEX_LOOKUP,
+ rc = OSP_UPDATE_RPC_PACK(env, out_index_lookup_pack, update,
lu_object_fid(&dt->do_lu), rec, key);
if (rc != 0) {
CERROR("%s: Insert update error: rc = %d\n",
lu_object_fid(&dt->do_lu), rec, key);
if (rc != 0) {
CERROR("%s: Insert update error: rc = %d\n",
* \retval 0 if packing index insert succeeds.
* \retval negative errno if packing fails.
*/
* \retval 0 if packing index insert succeeds.
* \retval negative errno if packing fails.
*/
-static int osp_md_index_insert(const struct lu_env *env,
- struct dt_object *dt,
+static int osp_md_index_insert(const struct lu_env *env, struct dt_object *dt,
const struct dt_rec *rec,
const struct dt_rec *rec,
- const struct dt_key *key,
- struct thandle *th,
+ const struct dt_key *key, struct thandle *th,
int ignore_quota)
{
struct osp_update_request *update;
int ignore_quota)
{
struct osp_update_request *update;
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
- rc = osp_update_rpc_pack(env, index_insert, update, OUT_INDEX_INSERT,
+ rc = OSP_UPDATE_RPC_PACK(env, out_index_insert_pack, update,
lu_object_fid(&dt->do_lu), rec, key);
return rc;
}
lu_object_fid(&dt->do_lu), rec, key);
return rc;
}
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
- rc = osp_update_rpc_pack(env, index_delete, update, OUT_INDEX_DELETE,
+ rc = OSP_UPDATE_RPC_PACK(env, out_index_delete_pack, update,
lu_object_fid(&dt->do_lu), key);
return rc;
lu_object_fid(&dt->do_lu), key);
return rc;
if (IS_ERR(update))
RETURN(PTR_ERR(update));
if (IS_ERR(update))
RETURN(PTR_ERR(update));
- rc = osp_update_rpc_pack(env, xattr_list, update, OUT_XATTR_LIST,
+ rc = OSP_UPDATE_RPC_PACK(env, out_xattr_list_pack, update,
lu_object_fid(&dt->do_lu), buf->lb_len);
if (rc) {
CERROR("%s: Insert update error "DFID": rc = %d\n",
lu_object_fid(&dt->do_lu), buf->lb_len);
if (rc) {
CERROR("%s: Insert update error "DFID": rc = %d\n",
int osp_md_destroy(const struct lu_env *env, struct dt_object *dt,
struct thandle *th)
{
int osp_md_destroy(const struct lu_env *env, struct dt_object *dt,
struct thandle *th)
{
- struct osp_object *o = dt2osp_obj(dt);
- struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev);
- struct osp_update_request *update;
- int rc = 0;
+ struct osp_object *o = dt2osp_obj(dt);
+ struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev);
+ struct osp_update_request *update;
+ int rc = 0;
ENTRY;
o->opo_non_exist = 1;
ENTRY;
o->opo_non_exist = 1;
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
- rc = osp_update_rpc_pack(env, destroy, update, OUT_DESTROY,
+ rc = OSP_UPDATE_RPC_PACK(env, out_destroy_pack, update,
lu_object_fid(&dt->do_lu));
if (rc != 0)
RETURN(rc);
lu_object_fid(&dt->do_lu));
if (rc != 0)
RETURN(rc);
CDEBUG(D_INFO, "write "DFID" offset = %llu length = %zu\n",
PFID(lu_object_fid(&dt->do_lu)), *pos, buf->lb_len);
CDEBUG(D_INFO, "write "DFID" offset = %llu length = %zu\n",
PFID(lu_object_fid(&dt->do_lu)), *pos, buf->lb_len);
- rc = osp_update_rpc_pack(env, write, update, OUT_WRITE,
+ rc = OSP_UPDATE_RPC_PACK(env, out_write_pack, update,
lu_object_fid(&dt->do_lu), buf, *pos);
if (rc < 0)
RETURN(rc);
lu_object_fid(&dt->do_lu), buf, *pos);
if (rc < 0)
RETURN(rc);
if (IS_ERR(update))
RETURN(PTR_ERR(update));
if (IS_ERR(update))
RETURN(PTR_ERR(update));
- rc = osp_update_rpc_pack(env, read, update, OUT_READ,
+ rc = OSP_UPDATE_RPC_PACK(env, out_read_pack, update,
lu_object_fid(&dt->do_lu),
rbuf->lb_len, *pos);
if (rc != 0) {
lu_object_fid(&dt->do_lu),
rbuf->lb_len, *pos);
if (rc != 0) {
if (IS_ERR(update))
RETURN(PTR_ERR(update));
if (IS_ERR(update))
RETURN(PTR_ERR(update));
- rc = osp_update_rpc_pack(env, attr_get, update, OUT_ATTR_GET,
+ rc = OSP_UPDATE_RPC_PACK(env, out_attr_get_pack, update,
lu_object_fid(&dt->do_lu));
if (rc != 0) {
CERROR("%s: Insert update error "DFID": rc = %d\n",
lu_object_fid(&dt->do_lu));
if (rc != 0) {
CERROR("%s: Insert update error "DFID": rc = %d\n",
if (IS_ERR(update))
RETURN(PTR_ERR(update));
if (IS_ERR(update))
RETURN(PTR_ERR(update));
- rc = osp_update_rpc_pack(env, attr_set, update,
- OUT_ASTTR_SET,
+ rc = OSP_UPDATE_RPC_PACK(env, out_attr_set_pack, update,
lu_object_fid(&dt->do_lu),
attr);
if (rc != 0) {
lu_object_fid(&dt->do_lu),
attr);
if (rc != 0) {
if (IS_ERR(update))
GOTO(out, rc = PTR_ERR(update));
if (IS_ERR(update))
GOTO(out, rc = PTR_ERR(update));
- rc = osp_update_rpc_pack(env, xattr_get, update, OUT_XATTR_GET,
+ rc = OSP_UPDATE_RPC_PACK(env, out_xattr_get_pack, update,
lu_object_fid(&dt->do_lu), name, buf->lb_len);
if (rc != 0) {
CERROR("%s: Insert update error "DFID": rc = %d\n",
lu_object_fid(&dt->do_lu), name, buf->lb_len);
if (rc != 0) {
CERROR("%s: Insert update error "DFID": rc = %d\n",
const struct lu_buf *buf, const char *name, int fl,
struct thandle *th)
{
const struct lu_buf *buf, const char *name, int fl,
struct thandle *th)
{
- struct osp_object *o = dt2osp_obj(dt);
+ struct osp_object *o = dt2osp_obj(dt);
struct osp_update_request *update;
struct osp_update_request *update;
- struct osp_xattr_entry *oxe;
- int rc;
+ struct osp_xattr_entry *oxe;
+ int rc;
ENTRY;
update = thandle_to_osp_update_request(th);
ENTRY;
update = thandle_to_osp_update_request(th);
CDEBUG(D_INODE, DFID" set xattr '%s' with size %zd\n",
PFID(lu_object_fid(&dt->do_lu)), name, buf->lb_len);
CDEBUG(D_INODE, DFID" set xattr '%s' with size %zd\n",
PFID(lu_object_fid(&dt->do_lu)), name, buf->lb_len);
- rc = osp_update_rpc_pack(env, xattr_set, update, OUT_XATTR_SET,
+ rc = OSP_UPDATE_RPC_PACK(env, out_xattr_set_pack, update,
lu_object_fid(&dt->do_lu), buf, name, fl);
if (rc != 0)
RETURN(rc);
lu_object_fid(&dt->do_lu), buf, name, fl);
if (rc != 0)
RETURN(rc);
const char *name, struct thandle *th)
{
struct osp_update_request *update;
const char *name, struct thandle *th)
{
struct osp_update_request *update;
- const struct lu_fid *fid = lu_object_fid(&dt->do_lu);
- struct osp_object *o = dt2osp_obj(dt);
- struct osp_xattr_entry *oxe;
- int rc;
+ const struct lu_fid *fid = lu_object_fid(&dt->do_lu);
+ struct osp_object *o = dt2osp_obj(dt);
+ struct osp_xattr_entry *oxe;
+ int rc;
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
update = thandle_to_osp_update_request(th);
LASSERT(update != NULL);
- rc = osp_update_rpc_pack(env, xattr_del, update, OUT_XATTR_DEL,
- fid, name);
+ rc = OSP_UPDATE_RPC_PACK(env, out_xattr_del_pack, update, fid, name);