add setattr capability check for oss (including req from mds).
code cleanup.
}
static int cmm_init_capa_ctxt(const struct lu_env *env, struct md_device *md,
- __u32 valid, unsigned long timeout, __u32 alg,
+ int mode , unsigned long timeout, __u32 alg,
struct lustre_capa_key *keys)
{
struct cmm_device *cmm_dev = md2cmm_dev(md);
ENTRY;
LASSERT(cmm_child_ops(cmm_dev)->mdo_init_capa_ctxt);
rc = cmm_child_ops(cmm_dev)->mdo_init_capa_ctxt(env, cmm_dev->cmm_child,
- valid, timeout, alg,
+ mode, timeout, alg,
keys);
RETURN(rc);
}
*/
int (*dt_init_capa_ctxt)(const struct lu_env *env,
struct dt_device *dev,
- __u32 valid, unsigned long timeout,
+ int mode, unsigned long timeout,
__u32 alg, struct lustre_capa_key *keys);
/*
int (*do_readpage)(const struct lu_env *env,
struct dt_object *dt, const struct lu_rdpg *rdpg,
struct lustre_capa *capa);
- int (*do_capa_get)(const struct lu_env *env,
- struct dt_object *dt, struct lustre_capa *capa);
+ struct obd_capa *(*do_capa_get)(const struct lu_env *env,
+ struct dt_object *dt, __u64 opc);
};
/*
extern int capa_count[];
extern cfs_mem_cache_t *capa_cachep;
-void capa_add(struct lustre_capa *capa);
+struct obd_capa *capa_add(struct lustre_capa *capa);
struct obd_capa *capa_lookup(struct lustre_capa *capa);
int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key);
};
#define BYPASS_CAPA (struct lustre_capa *)ERR_PTR(-ENOENT)
-
-enum {
- CAPA_CTX_ON = 1,
- CAPA_CTX_TIMEOUT = 1<<1,
- CAPA_CTX_ALG = 1<<2,
- CAPA_CTX_KEYS = 1<<3,
-};
#endif /* __LINUX_CAPA_H_ */
int mds_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
struct lov_mds_md *lmm, int lmm_size,
- struct llog_cookie *logcookies, __u64 id, __u32 gen);
+ struct llog_cookie *logcookies, __u64 id, __u32 gen,
+ struct obd_capa *oc);
int mds_log_op_unlink(struct obd_device *obd,
struct lov_mds_md *lmm, int lmm_size,
struct kstatfs *sfs);
int (*mdo_init_capa_ctxt)(const struct lu_env *env, struct md_device *m,
- __u32 valid, unsigned long timeout, __u32 alg,
+ int mode, unsigned long timeout, __u32 alg,
struct lustre_capa_key *keys);
int (*mdo_update_capa_key)(const struct lu_env *env,
struct lov_stripe_md *mem_tgt);
int (*o_preallocate)(struct lustre_handle *, obd_count *req,
obd_id *ids);
+ /* FIXME: add fid capability support for create & destroy! */
int (*o_create)(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md **ea, struct obd_trans_info *oti);
int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *ea, struct obd_trans_info *oti,
- struct obd_export *md_exp, void *capa);
+ struct obd_export *md_exp);
int (*o_setattr)(struct obd_export *exp, struct obd_info *oinfo,
struct obd_trans_info *oti);
int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
static inline int obd_destroy(struct obd_export *exp, struct obdo *obdo,
struct lov_stripe_md *ea,
struct obd_trans_info *oti,
- struct obd_export *md_exp, void *capa)
+ struct obd_export *md_exp)
{
int rc;
ENTRY;
EXP_CHECK_DT_OP(exp, destroy);
OBD_COUNTER_INCREMENT(exp->exp_obd, destroy);
- rc = OBP(exp->exp_obd, destroy)(exp, obdo, ea, oti, md_exp, capa);
+ rc = OBP(exp->exp_obd, destroy)(exp, obdo, ea, oti, md_exp);
RETURN(rc);
}
}
}
- rc = obd_destroy(llu_i2obdexp(dir), oa, lsm, &oti, NULL, NULL);
+ rc = obd_destroy(llu_i2obdexp(dir), oa, lsm, &oti, NULL);
obdo_free(oa);
if (rc)
CERROR("obd destroy objid 0x"LPX64" error %d\n",
if (!obd_capa_is_valid(ocapa))
continue;
if ((opc & CAPA_OPC_OSS_WRITE) &&
- capa_opc_supported(&ocapa->c_capa, opc)) {
+ capa_opc_supported(&ocapa->c_capa, CAPA_OPC_OSS_WRITE)) {
found = 1; break;
} else if ((opc & CAPA_OPC_OSS_READ) &&
- capa_opc_supported(&ocapa->c_capa, opc)) {
+ capa_opc_supported(&ocapa->c_capa,
+ CAPA_OPC_OSS_READ)) {
found = 1; break;
} else if ((opc & CAPA_OPC_OSS_TRUNC) &&
capa_opc_supported(&ocapa->c_capa, opc)) {
oinfo.oi_oa = oa;
oinfo.oi_md = lsm;
+ oinfo.oi_capa = ll_i2mdscapa(inode);
/* XXX: this looks unnecessary now. */
rc = obd_setattr_rqset(sbi->ll_dt_exp, &oinfo, NULL);
+ capa_put(oinfo.oi_capa);
if (rc)
CERROR("obd_setattr_async fails: rc=%d\n", rc);
obdo_free(oa);
struct lov_stripe_md *lsm = NULL;
struct obd_trans_info oti = { 0 };
struct obdo *oa;
- struct obd_capa *oc;
int rc;
ENTRY;
}
}
- /* FIXME: parent mds capability is the only one can find! */
- oc = ll_i2mdscapa(dir);
- rc = obd_destroy(ll_i2dtexp(dir), oa, lsm, &oti, ll_i2mdexp(dir), oc);
- capa_put(oc);
+ rc = obd_destroy(ll_i2dtexp(dir), oa, lsm, &oti, ll_i2mdexp(dir));
obdo_free(oa);
if (rc)
CERROR("obd destroy objid "LPX64" error %d\n",
static int lov_destroy(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *lsm, struct obd_trans_info *oti,
- struct obd_export *md_exp, void *capa)
+ struct obd_export *md_exp)
{
struct lov_request_set *set;
struct obd_info oinfo;
oti->oti_logcookies = set->set_cookies + req->rq_stripe;
err = obd_destroy(lov->lov_tgts[req->rq_idx]->ltd_exp,
- req->rq_oi.oi_oa, NULL, oti, NULL, capa);
+ req->rq_oi.oi_oa, NULL, oti, NULL);
err = lov_update_common_set(set, req, err);
if (err) {
CERROR("error: destroying objid "LPX64" subobj "
CDEBUG(D_INODE, "stripe %d has size "LPU64"/"LPU64"\n",
i, req->rq_oi.oi_oa->o_size, src_oa->o_size);
}
-
}
LASSERT(set->set_count == stripes);
continue;
sub_exp = lov->lov_tgts[req->rq_idx]->ltd_exp;
- err = obd_destroy(sub_exp, req->rq_oi.oi_oa, NULL, oti, NULL,
- NULL);
+ err = obd_destroy(sub_exp, req->rq_oi.oi_oa, NULL, oti, NULL);
if (err)
CERROR("Failed to uncreate objid "LPX64" subobj "
LPX64" on OST idx %d: rc = %d\n",
/* remember the index for sort brw_page array */
info[i].index = req->rq_pgaidx;
+ req->rq_oi.oi_capa = oinfo->oi_capa;
+
lov_set_add_req(req, set);
}
if (!set->set_count)
sizeof(*req->rq_oi.oi_oa));
req->rq_oi.oi_oa->o_id = loi->loi_id;
req->rq_oi.oi_cb_up = cb_getattr_update;
+ req->rq_oi.oi_capa = oinfo->oi_capa;
req->rq_rqset = set;
lov_set_add_req(req, set);
|| req->rq_oi.oi_oa->o_gr>0);
req->rq_oi.oi_oa->o_stripe_idx = i;
req->rq_oi.oi_cb_up = cb_setattr_update;
+ req->rq_oi.oi_capa = oinfo->oi_capa;
req->rq_rqset = set;
if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE) {
req->rq_oi.oi_policy.l_extent.end = re;
req->rq_oi.oi_policy.l_extent.gid = -1;
+ req->rq_oi.oi_capa = oinfo->oi_capa;
+
lov_set_add_req(req, set);
}
if (!set->set_count)
req->rq_oi.oi_policy.l_extent.end = re;
req->rq_oi.oi_policy.l_extent.gid = -1;
+ req->rq_oi.oi_capa = oinfo->oi_capa;
+
lov_set_add_req(req, set);
}
if (!set->set_count)
LASSERT(op_data != NULL);
- if (op_data->mod_capa1)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = op_data->mod_capa1 ?
+ sizeof(struct lustre_capa) : 0;
if (op_data->flags & (MF_SOM_CHANGE | MF_EPOCH_OPEN))
size[REQ_REC_OFF + 2] = sizeof(struct mdt_epoch);
struct ptlrpc_request *req;
ENTRY;
- if (op_data->mod_capa1)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
-
+ size[REQ_REC_OFF + 1] = op_data->mod_capa1 ?
+ sizeof(struct lustre_capa) : 0;
if (data && datalen) {
size[bufcount] = datalen;
bufcount++;
LASSERT(req == NULL);
- if (op_data->mod_capa1)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = op_data->mod_capa1 ?
+ sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
MDS_REINT, 4, size, NULL);
int rc;
ENTRY;
- if (op_data->mod_capa1)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
- if (op_data->mod_capa2)
- size[REQ_REC_OFF + 2] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = op_data->mod_capa1 ?
+ sizeof(struct lustre_capa) : 0;
+ size[REQ_REC_OFF + 2] = op_data->mod_capa2 ?
+ sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
MDS_REINT, 5, size, NULL);
int rc;
ENTRY;
- if (op_data->mod_capa1)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
- if (op_data->mod_capa2)
- size[REQ_REC_OFF + 2] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = op_data->mod_capa1 ?
+ sizeof(struct lustre_capa) : 0;
+ size[REQ_REC_OFF + 2] = op_data->mod_capa2 ?
+ sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
MDS_REINT, 6, size, NULL);
extern int mds_queue_req(struct ptlrpc_request *);
-static inline struct obd_capa *mdc_unpack_capa(struct ptlrpc_request *req,
+static struct obd_capa *mdc_unpack_capa(struct ptlrpc_request *req,
unsigned int offset)
{
struct lustre_capa *capa;
ea_size);
if (acl_size)
CDEBUG(D_INODE, "reserved %u bytes for ACL\n", acl_size);
- if (mdscapa)
- size[REPLY_REC_OFF + 2] = sizeof(struct lustre_capa);
+ size[REPLY_REC_OFF + 2] = mdscapa ? sizeof(struct lustre_capa) : 0;
ptlrpc_req_set_repsize(req, 5, size);
int acl_size = 0, rc;
ENTRY;
- if (oc)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = oc ? sizeof(struct lustre_capa) : 0;
/*
* XXX do we need to make another request here? We just did a getattr
int rc;
ENTRY;
- if (oc)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = oc ? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
MDS_GETATTR_NAME, 4, size, NULL);
int rc;
ENTRY;
- if (pc)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
- if (cc)
- size[REQ_REC_OFF + 2] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = pc ? sizeof(struct lustre_capa) : 0;
+ size[REQ_REC_OFF + 2] = cc ? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
MDS_IS_SUBDIR, 4, size, NULL);
void *tmp;
ENTRY;
- if (oc)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = oc ? sizeof(struct lustre_capa) : 0;
if (xattr_name) {
xattr_namelen = strlen(xattr_name) + 1;
size[bufcnt++] = xattr_namelen;
int rc;
ENTRY;
- if (op_data->mod_capa1)
- reqsize[REQ_REC_OFF + 2] = sizeof(struct lustre_capa);
+ reqsize[REQ_REC_OFF + 2] = op_data->mod_capa1 ?
+ sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
MDS_CLOSE, 4, reqsize, NULL);
if (req == NULL)
CDEBUG(D_INODE, "object: "DFID"\n", PFID(fid));
- if (oc != NULL)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
-
- req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE, 3,
- size, NULL);
+ size[REQ_REC_OFF + 1] = oc ? sizeof(struct lustre_capa) : 0;
+ req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE, 3, size,
+ NULL);
if (req == NULL)
GOTO(out, rc = -ENOMEM);
int rc, size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- if (oc)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = oc ? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
MDS_PIN, 3, size, NULL);
if (req == NULL)
}
int mdc_sync(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc,
- struct ptlrpc_request **request)
+ struct obd_capa *oc, struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
int size[3] = { sizeof(struct ptlrpc_body), sizeof(struct mdt_body) };
int rc;
ENTRY;
- if (oc)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = oc ? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
MDS_SYNC, 3, size, NULL);
if (!req)
int rc;
ENTRY;
- if (oc)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
+ size[REQ_REC_OFF + 1] = oc ? sizeof(struct lustre_capa) : 0;
*request = NULL;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
}
static int mdd_init_capa_ctxt(const struct lu_env *env, struct md_device *m,
- __u32 valid, unsigned long timeout, __u32 alg,
+ int mode, unsigned long timeout, __u32 alg,
struct lustre_capa_key *keys)
{
struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
int rc;
ENTRY;
- if (valid & CAPA_CTX_KEYS)
- mds->mds_capa_keys = keys;
-
- rc = mdd_child_ops(mdd)->dt_init_capa_ctxt(env, mdd->mdd_child, valid,
+ mds->mds_capa_keys = keys;
+ rc = mdd_child_ops(mdd)->dt_init_capa_ctxt(env, mdd->mdd_child, mode,
timeout, alg, keys);
RETURN(rc);
}
{
struct dt_object *next;
struct mdd_object *mdd_obj = md2mdd_obj(obj);
- int rc;
+ struct obd_capa *oc;
ENTRY;
LASSERT(lu_object_exists(mdd2lu_obj(mdd_obj)));
next = mdd_object_child(mdd_obj);
- rc = next->do_ops->do_capa_get(env, next, capa);
+ oc = next->do_ops->do_capa_get(env, next, capa->lc_opc);
+ if (oc) {
+ capa_cpy(capa, oc);
+ capa_put(oc);
+ }
- RETURN(rc);
+ RETURN(0);
}
struct md_device_operations mdd_ops = {
__u32 create_flags = spec->sp_cr_flags;
int rc = 0;
struct obd_trans_info *oti = &mdd_env_info(env)->mti_oti;
+ struct dt_object *next;
ENTRY;
if (create_flags & MDS_OPEN_DELAY_CREATE ||
OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLGROUP;
oa->o_size = 0;
+ next = mdd_object_child(child);
if (!(create_flags & MDS_OPEN_HAS_OBJS)) {
if (create_flags & MDS_OPEN_HAS_EA) {
LASSERT(eadata != NULL);
if (rc)
GOTO(out_oa, rc);
}
+
rc = obd_create(lov_exp, oa, &lsm, oti);
if (rc) {
if (rc > 0) {
oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
oinfo->oi_oa = oa;
oinfo->oi_md = lsm;
+ oinfo->oi_capa = next->do_ops->do_capa_get(env, next,
+ CAPA_OPC_MDS_DEFAULT);
rc = obd_setattr(lov_exp, oinfo, oti);
+ capa_put(oinfo->oi_capa);
if (rc) {
CERROR("Error setting attrs for "DFID": rc %d\n",
PFID(mdo2fid(child)), rc);
struct dt_object *next = mdd_object_child(obj);
__u32 seq = lu_object_fid(mdd2lu_obj(obj))->f_seq;
__u32 oid = lu_object_fid(mdd2lu_obj(obj))->f_oid;
+ struct obd_capa *oc;
int rc = 0;
ENTRY;
if (rc)
RETURN(rc);
+ oc = next->do_ops->do_capa_get(env, next, CAPA_OPC_MDS_DEFAULT);
rc = mds_osc_setattr_async(obd, tmp_la->la_uid, tmp_la->la_gid, lmm,
- lmm_size, NULL, seq, oid);
+ lmm_size, NULL, seq, oid, oc);
+ capa_put(oc);
RETURN(rc);
}
int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *ea, struct obd_trans_info *oti,
- struct obd_export *md_exp, void *unused)
+ struct obd_export *md_exp)
{
struct mds_obd *mds = &exp->exp_obd->u.mds;
struct inode *parent_inode = mds->mds_objects_dir->d_inode;
struct lov_stripe_md **ea, struct obd_trans_info *oti);
int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *ea, struct obd_trans_info *oti,
- struct obd_export *md_exp, void *unused);
+ struct obd_export *md_exp);
void mds_init_ctxt(struct obd_device *obd, struct vfsmount *mnt);
/* mds/handler.c */
int mds_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
struct lov_mds_md *lmm, int lmm_size,
- struct llog_cookie *logcookies, __u64 id, __u32 gen)
+ struct llog_cookie *logcookies, __u64 id, __u32 gen,
+ struct obd_capa *oc)
{
struct mds_obd *mds = &obd->u.mds;
struct obd_trans_info oti = { 0 };
oinfo.oi_oa->o_fid = id;
oinfo.oi_oa->o_generation = gen;
oinfo.oi_oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
+ oinfo.oi_capa = oc;
/* do async setattr from mds to ost not waiting for responses. */
rc = obd_setattr_async(mds->mds_osc_exp, &oinfo, &oti, NULL);
if (!rc && !err && lmm_size)
mds_osc_setattr_async(obd, inode->i_ino, inode->i_generation, lmm,
lmm_size, logcookies, rec->ur_fid1->id,
- rec->ur_fid1->generation);
+ rec->ur_fid1->generation, NULL);
switch (cleanup_phase) {
case 2:
oa->o_valid |= OBD_MD_FLCOOKIE;
oti.oti_logcookies = logcookies;
}
- rc = obd_destroy(mds->mds_osc_exp, oa, lsm, &oti, obd->obd_self_export,
- NULL);
+ rc = obd_destroy(mds->mds_osc_exp, oa, lsm, &oti, obd->obd_self_export);
obdo_free(oa);
if (rc)
CDEBUG(D_INODE, "destroy orphan objid 0x"LPX64" on ost error "
LASSERT(capa);
*capa = *c;
+ capa->lc_expiry = 0;
rc = mo_capa_get(info->mti_env, mdt_object_child(obj), capa);
body = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY);
if (reqbody->valid & OBD_MD_FLOSSCAPA) {
rc = mdt_renew_capa(info);
- GOTO(out, rc);
+ mdt_shrink_reply(info, REPLY_REC_OFF + 1, 0, 0);
+ RETURN(rc);
}
if (reqbody->valid & OBD_MD_FLRMTPERM) {
static int mdt_init_capa_ctxt(const struct lu_env *env, struct mdt_device *m)
{
struct md_device *next = m->mdt_child;
- __u32 valid = CAPA_CTX_TIMEOUT | CAPA_CTX_ALG | CAPA_CTX_KEYS;
- int rc;
- if (m->mdt_opts.mo_mds_capa)
- valid |= CAPA_CTX_ON;
- rc = next->md_ops->mdo_init_capa_ctxt(env, next, valid,
- m->mdt_capa_timeout,
- m->mdt_capa_alg,
- m->mdt_capa_keys);
- return rc;
+ return next->md_ops->mdo_init_capa_ctxt(env, next,
+ m->mdt_opts.mo_mds_capa,
+ m->mdt_capa_timeout,
+ m->mdt_capa_alg,
+ m->mdt_capa_keys);
}
/*
m->mdt_rootsquash_info = NULL;
}
- next->md_ops->mdo_init_capa_ctxt(env, next, CAPA_CTX_KEYS, 0, 0, NULL);
+ next->md_ops->mdo_init_capa_ctxt(env, next, 0, 0, 0, NULL);
cleanup_capas(CAPA_SITE_SERVER);
del_timer(&m->mdt_ck_timer);
mdt_ck_thread_stop(m);
offset += !!md_size;
lustre_shrink_reply(req, offset, acl_size, 1);
offset += !!acl_size;
- if (mdscapa && !(body->valid & (OBD_MD_FLMDSCAPA | OBD_MD_FLOSSCAPA)))
+ if (mdscapa && !(body->valid & OBD_MD_FLMDSCAPA))
lustre_shrink_reply(req, offset, 0, 1);
offset += mdscapa;
if (osscapa && !(body->valid & OBD_MD_FLOSSCAPA))
}
/* add or update */
-void capa_add(struct lustre_capa *capa)
+struct obd_capa *capa_add(struct lustre_capa *capa)
{
struct hlist_head *head = capa_hash + capa_hashfn(&capa->lc_fid);
struct obd_capa *ocapa, *old = NULL;
ocapa = alloc_capa(CAPA_SITE_SERVER);
if (!ocapa)
- return;
+ return NULL;
spin_lock(&capa_lock);
set_capa_expiry(ocapa);
hlist_add_head(&ocapa->u.tgt.c_hash, head);
list_add_tail(&ocapa->c_list, &capa_list[CAPA_SITE_SERVER]);
+ capa_get(ocapa);
if (capa_count[CAPA_SITE_SERVER] > CAPA_HASH_SIZE)
free_capa_lru(&capa_list[CAPA_SITE_SERVER]);
DEBUG_CAPA(D_SEC, &ocapa->c_capa, "new");
spin_unlock(&capa_lock);
- return;
+ return ocapa;
}
- spin_lock(&old->c_lock);
- old->c_capa = *capa;
- set_capa_expiry(old);
- spin_unlock(&old->c_lock);
-
list_move_tail(&old->c_list, &capa_list[CAPA_SITE_SERVER]);
+ capa_get(old);
spin_unlock(&capa_lock);
DEBUG_CAPA(D_SEC, &old->c_capa, "update");
free_capa(ocapa);
+ return old;
}
struct obd_capa *capa_lookup(struct lustre_capa *capa)
if (rc)
GOTO(out, rc);
- rc = obd_destroy(handle->lgh_ctxt->loc_exp, oa, NULL, NULL, NULL,
- NULL);
+ rc = obd_destroy(handle->lgh_ctxt->loc_exp, oa, NULL, NULL, NULL);
out:
obdo_free(oa);
RETURN(rc);
int echo_destroy(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *ea, struct obd_trans_info *oti,
- struct obd_export *md_exp, void *unused)
+ struct obd_export *md_exp)
{
struct obd_device *obd = class_exp2obd(exp);
oa->o_id, on_target ? " (undoing create)" : "");
if (on_target)
- obd_destroy(ec->ec_exp, oa, lsm, oti, NULL, NULL);
+ obd_destroy(ec->ec_exp, oa, lsm, oti, NULL);
rc = -EEXIST;
goto failed;
oa->o_gr = FILTER_GROUP_ECHO;
oa->o_valid |= OBD_MD_FLGROUP;
rc = obd_destroy(ec->ec_exp, oa, eco->eco_lsm,
- &dummy_oti, NULL, NULL);
+ &dummy_oti, NULL);
if (rc == 0)
eco->eco_deleted = 1;
echo_put_object(eco);
if (export == NULL)
RETURN(NULL);
- OBD_ALLOC(fglog, sizeof(*fglog));
+ OBD_ALLOC_PTR(fglog);
if (fglog == NULL)
RETURN(NULL);
fglog->group = group;
- OBD_ALLOC(fglog->llogs, sizeof(struct obd_llogs));
+ OBD_ALLOC_PTR(fglog->llogs);
if (fglog->llogs == NULL) {
- OBD_FREE(fglog, sizeof(*fglog));
+ OBD_FREE_PTR(fglog);
RETURN(NULL);
}
rc = llog_cat_initialize(obd, fglog->llogs, 1, NULL);
if (rc) {
- OBD_FREE(fglog->llogs, sizeof(*(fglog->llogs)));
- OBD_FREE(fglog, sizeof(*fglog));
+ OBD_FREE_PTR(fglog->llogs);
+ OBD_FREE_PTR(fglog);
RETURN(NULL);
}
if (rc)
CERROR("failed to cleanup llogging subsystem for %u\n",
log->group);
- OBD_FREE(log->llogs, sizeof(*(log->llogs)));
- OBD_FREE(log, sizeof(*log));
+ OBD_FREE_PTR(log->llogs);
+ OBD_FREE_PTR(log);
spin_lock(&filter->fo_llog_list_lock);
}
spin_unlock(&filter->fo_llog_list_lock);
exp->exp_obd->obd_name, oa->o_id + 1, last);
for (id = last; id > oa->o_id; id--) {
doa.o_id = id;
- rc = filter_destroy(exp, &doa, NULL, NULL, NULL, NULL);
+ rc = filter_destroy(exp, &doa, NULL, NULL, NULL);
if (rc && rc != -ENOENT) /* this is pretty fatal... */
CEMERG("error destroying precreate objid "LPU64": %d\n",
id, rc);
int filter_destroy(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *md, struct obd_trans_info *oti,
- struct obd_export *md_exp, void *capa)
+ struct obd_export *md_exp)
{
unsigned int qcids[MAXQUOTAS] = {0, 0};
struct obd_device *obd;
LASSERT(oa->o_valid & OBD_MD_FLGROUP);
-#if 0 /* some places don't support capability yet */
- rc = filter_verify_capa(exp, NULL, obdo_mdsno(oa),
- (struct lustre_capa *)capa,
- CAPA_OPC_INDEX_LOOKUP);
- if (rc)
- RETURN(rc);
-#endif
-
#if 0
if (!(oa->o_valid & OBD_MD_FLGROUP))
oa->o_gr = 0;
struct filter_obd *filter = &obd->u.filter;
struct filter_capa_key *k;
struct lustre_capa_key key;
- struct obd_capa *c;
+ struct obd_capa *oc;
__u8 *hmac;
int keys_ready = 0, key_found = 0, rc = 0;
ENTRY;
#warning "enable fid check in filter_verify_capa when fid ready"
- if (!capa_opc_supported(capa, opc)) {
+ if (opc == CAPA_OPC_OSS_READ) {
+ if (!(capa->lc_opc & (CAPA_OPC_OSS_READ | CAPA_OPC_OSS_WRITE)))
+ rc = -EACCES;
+ } else if (!capa_opc_supported(capa, opc)) {
+ rc = -EACCES;
+ }
+ if (rc) {
DEBUG_CAPA(D_ERROR, capa, "opc "LPX64" not supported by", opc);
- RETURN(-EACCES);
+ RETURN(rc);
}
- c = capa_lookup(capa);
- if (c) {
- spin_lock(&c->c_lock);
- if (memcmp(&c->c_capa, capa, sizeof(*capa))) {
+ oc = capa_lookup(capa);
+ if (oc) {
+ spin_lock(&oc->c_lock);
+ if (memcmp(&oc->c_capa, capa, sizeof(*capa))) {
DEBUG_CAPA(D_ERROR, capa, "HMAC mismatch");
rc = -EACCES;
- } else if (capa_is_expired(c)) {
+ } else if (capa_is_expired(oc)) {
DEBUG_CAPA(D_ERROR, capa, "expired");
rc = -ESTALE;
}
- spin_unlock(&c->c_lock);
+ spin_unlock(&oc->c_lock);
- capa_put(c);
+ capa_put(oc);
RETURN(rc);
}
}
/* store in capa hash */
- capa_add(capa);
+ oc = capa_add(capa);
+ capa_put(oc);
RETURN(0);
}
void *option);
int filter_destroy(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *md, struct obd_trans_info *,
- struct obd_export *, void *capa);
+ struct obd_export *);
int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
struct obdo *oa, struct obd_trans_info *oti);
int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
rc = filter_verify_capa(exp, NULL, obdo_mdsno(oa), capa,
CAPA_OPC_OSS_READ);
- if (rc)
- RETURN(rc);
+ if (rc) {
+ rc = filter_verify_capa(exp, NULL, obdo_mdsno(oa), capa,
+ CAPA_OPC_OSS_READ);
+ if (rc)
+ RETURN(rc);
+ }
if (oa && oa->o_valid & OBD_MD_FLGRANT) {
spin_lock(&obd->obd_osfs_lock);
memcpy(obdo_logcookie(oa), cookie, sizeof(*cookie));
oid = oa->o_id;
- rc = filter_destroy(exp, oa, NULL, NULL, NULL, NULL);
+ rc = filter_destroy(exp, oa, NULL, NULL, NULL);
obdo_free(oa);
if (rc == -ENOENT) {
CDEBUG(D_HA, "object already removed, send cookie\n");
struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
int try_again = 1, rc = 0;
ENTRY;
+
LASSERT(oa);
LASSERT(ea);
-
LASSERT(oa->o_gr > 0);
LASSERT(oa->o_valid & OBD_MD_FLGROUP);
struct osc_async_args *aa;
ENTRY;
- size[REQ_REC_OFF + 1] = oinfo->oi_capa ? sizeof(*oinfo->oi_capa) : 0;
+ size[REQ_REC_OFF + 1] = oinfo->oi_capa ? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
OST_GETATTR, 3, size,NULL);
if (!req)
int rc, size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
- size[REQ_REC_OFF + 1] = oinfo->oi_capa ? sizeof(*oinfo->oi_capa) : 0;
+ size[REQ_REC_OFF + 1] = oinfo->oi_capa ? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
OST_GETATTR, 3, size, NULL);
if (!req)
LASSERT(!(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP) ||
oinfo->oi_oa->o_gr > 0);
- size[REQ_REC_OFF + 1] = oinfo->oi_capa ? sizeof(*oinfo->oi_capa) : 0;
+ size[REQ_REC_OFF + 1] = oinfo->oi_capa ? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
OST_SETATTR, 3, size, NULL);
if (!req)
struct osc_async_args *aa;
ENTRY;
- size[REQ_REC_OFF + 1] = oinfo->oi_capa ? sizeof(*oinfo->oi_capa) : 0;
+ size[REQ_REC_OFF + 1] = oinfo->oi_capa ? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
OST_SETATTR, 3, size, NULL);
if (!req)
struct ptlrpc_request *req;
struct ost_body *body;
struct lov_stripe_md *lsm;
- int rc, size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
LASSERT(oa);
RETURN(rc);
}
- /* FIXME: how to find one OSS WRITE capability? */
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_CREATE, 3, size, NULL);
+ OST_CREATE, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
struct ptlrpc_request *req;
struct osc_async_args *aa;
struct ost_body *body;
- struct lustre_capa *capa = oinfo->oi_capa;
int size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
RETURN(-EINVAL);
}
- size[REQ_REC_OFF + 1] = capa ? sizeof(*capa) : 0;
+ size[REQ_REC_OFF + 1] = oinfo->oi_capa? sizeof(struct lustre_capa) : 0;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
OST_PUNCH, 3, size, NULL);
if (!req)
body->oa.o_blocks = oinfo->oi_policy.l_extent.end;
body->oa.o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
- if (capa) {
- struct lustre_capa *c;
-
- c = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, sizeof(*c));
- /* setattr_raw is protected by i_sem, no need to lock here */
- *c = *capa;
- body->oa.o_valid |= OBD_MD_FLOSSCAPA;
- }
-
ptlrpc_req_set_repsize(req, 2, size);
req->rq_interpret_reply = osc_punch_interpret;
* cookies to the MDS after committing destroy transactions. */
static int osc_destroy(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *ea, struct obd_trans_info *oti,
- struct obd_export *md_export, void *capa)
+ struct obd_export *md_export)
{
struct ptlrpc_request *req;
struct ost_body *body;
- int size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
if (!oa) {
RETURN(-EINVAL);
}
- if (capa)
- size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa);
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
- OST_DESTROY, 3, size, NULL);
+ OST_DESTROY, 2, size, NULL);
if (!req)
RETURN(-ENOMEM);
sizeof(*oti->oti_logcookies));
body->oa = *oa;
- osc_pack_capa(req, REQ_REC_OFF + 1, body, capa);
-
ptlrpc_req_set_repsize(req, 2, size);
ptlrpcd_add_req(req);
}
static int osd_init_capa_ctxt(const struct lu_env *env, struct dt_device *d,
- __u32 valid, unsigned long timeout, __u32 alg,
+ int mode, unsigned long timeout, __u32 alg,
struct lustre_capa_key *keys)
{
struct osd_device *dev = osd_dt_dev(d);
ENTRY;
- if (valid & CAPA_CTX_ON)
- dev->od_fl_capa = 1;
- else
- dev->od_fl_capa = 0;
-
- if (valid & CAPA_CTX_TIMEOUT)
- dev->od_capa_timeout = timeout;
-
- if (valid & CAPA_CTX_ALG)
- dev->od_capa_alg = alg;
-
- if (valid & CAPA_CTX_KEYS)
- dev->od_capa_keys = keys;
+ dev->od_fl_capa = mode;
+ dev->od_capa_timeout = timeout;
+ dev->od_capa_alg = alg;
+ dev->od_capa_keys = keys;
RETURN(0);
}
.dt_sync = osd_sync,
.dt_ro = osd_ro,
.dt_credit_get = osd_credit_get,
- .dt_init_capa_ctxt = osd_init_capa_ctxt
+ .dt_init_capa_ctxt = osd_init_capa_ctxt,
};
static void osd_object_read_lock(const struct lu_env *env,
struct lustre_capa *capa,
struct lustre_capa_key *keys)
{
- struct obd_capa *c;
- struct osd_thread_info *oti = lu_context_key_get(&env->le_ctx, &osd_key);
+ struct osd_thread_info *oti;
+ struct obd_capa *oc;
int i, rc = 1;
ENTRY;
- c = capa_lookup(capa);
- if (c) {
- spin_lock(&c->c_lock);
- if (memcmp(&c->c_capa, capa, sizeof(*capa))) {
+ oti = lu_context_key_get(&env->le_ctx, &osd_key);
+
+ oc = capa_lookup(capa);
+ if (oc) {
+ if (memcmp(&oc->c_capa, capa, sizeof(*capa))) {
DEBUG_CAPA(D_ERROR, capa, "HMAC mismatch");
rc = -EACCES;
- } else if (capa_is_expired(c)) {
+ } else if (capa_is_expired(oc)) {
DEBUG_CAPA(D_ERROR, capa, "expired");
rc = -ESTALE;
}
- spin_unlock(&c->c_lock);
-
- capa_put(c);
+ capa_put(oc);
RETURN(rc);
}
RETURN(-EACCES);
}
- capa_add(capa);
+ oc = capa_add(capa);
+ capa_put(oc);
RETURN(1);
}
if (!capa) {
CERROR("no capability is provided for fid "DFID"\n", PFID(fid));
- LBUG();
return -EACCES;
}
return rc ? rc : rc1;
}
-static int osd_capa_get(const struct lu_env *env,
- struct dt_object *dt, struct lustre_capa *capa)
+static struct obd_capa *osd_capa_get(const struct lu_env *env,
+ struct dt_object *dt,
+ __u64 opc)
{
struct osd_thread_info *info = lu_context_key_get(&env->le_ctx,
&osd_key);
struct osd_object *obj = osd_dt_obj(dt);
struct osd_device *dev = osd_obj2dev(obj);
struct lustre_capa_key *key = &info->oti_capa_key;
+ struct lustre_capa *capa = &info->oti_capa;
struct obd_capa *oc;
int rc;
ENTRY;
+ if (!dev->od_fl_capa)
+ RETURN(NULL);
+
LASSERT(dt_object_exists(dt));
LASSERT(osd_invariant(obj));
capa->lc_fid = *fid;
+ capa->lc_opc = opc;
+ capa->lc_flags |= dev->od_capa_alg << 24;
if (dev->od_capa_timeout < CAPA_TIMEOUT)
capa->lc_flags |= CAPA_FL_SHORT_EXPIRY;
- capa->lc_flags = dev->od_capa_alg << 24;
-
- /* TODO: get right permission here */
oc = capa_lookup(capa);
if (oc) {
LASSERT(!capa_is_expired(oc));
- capa_cpy(capa, oc);
- capa_put(oc);
- RETURN(0);
+ RETURN(oc);
}
spin_lock(&capa_lock);
*key = dev->od_capa_keys[1];
- capa->lc_expiry = CURRENT_SECONDS + dev->od_capa_timeout;
spin_unlock(&capa_lock);
capa->lc_keyid = key->lk_keyid;
+ capa->lc_expiry = CURRENT_SECONDS + dev->od_capa_timeout;
+
rc = capa_hmac(capa->lc_hmac, capa, key->lk_key);
- if (rc)
- RETURN(rc);
+ if (rc) {
+ DEBUG_CAPA(D_ERROR, capa, "HMAC failed: %d for", rc);
+ RETURN(NULL);
+ }
- capa_add(capa);
- RETURN(0);
+ oc = capa_add(capa);
+ RETURN(oc);
}
static struct dt_object_operations osd_obj_ops = {
*/
char oti_capa_hmac[CAPA_HMAC_KEY_MAX_LEN];
struct lustre_capa_key oti_capa_key;
+ struct lustre_capa oti_capa;
};
#endif /* __KERNEL__ */
struct obd_trans_info *oti)
{
struct ost_body *body, *repbody;
- struct lustre_capa *capa = NULL;
int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
ENTRY;
repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
- if (body->oa.o_valid & OBD_MD_FLOSSCAPA)
- capa = lustre_unpack_capa(req->rq_reqmsg, REQ_REC_OFF + 1);
- req->rq_status = obd_destroy(exp, &body->oa, NULL, oti, NULL, capa);
+ req->rq_status = obd_destroy(exp, &body->oa, NULL, oti, NULL);
RETURN(0);
}
oinfo.oi_oa = &repbody->oa;
if (oinfo.oi_oa->o_valid & OBD_MD_FLOSSCAPA)
- oinfo.oi_capa = lustre_unpack_capa(req->rq_repmsg,
+ oinfo.oi_capa = lustre_unpack_capa(req->rq_reqmsg,
REQ_REC_OFF + 1);
req->rq_status = obd_getattr(exp, &oinfo);
RETURN(0);
oinfo.oi_oa->o_valid &= ~OBD_MD_FLFLAGS;
if (oinfo.oi_oa->o_valid & OBD_MD_FLOSSCAPA)
- oinfo.oi_capa = lustre_unpack_capa(req->rq_repmsg,
+ oinfo.oi_capa = lustre_unpack_capa(req->rq_reqmsg,
REQ_REC_OFF + 1);
req->rq_status = obd_punch(exp, &oinfo, oti, NULL);
ost_punch_lock_put(exp, oinfo.oi_oa, &lh);
oinfo.oi_oa = &repbody->oa;
if (oinfo.oi_oa->o_valid & OBD_MD_FLOSSCAPA)
- oinfo.oi_capa = lustre_unpack_capa(req->rq_repmsg,
+ oinfo.oi_capa = lustre_unpack_capa(req->rq_reqmsg,
REQ_REC_OFF + 1);
req->rq_status = obd_setattr(exp, &oinfo, oti);
RETURN(0);
if (pinger_thread != NULL)
RETURN(-EALREADY);
- OBD_ALLOC(pinger_thread, sizeof(*pinger_thread));
+ OBD_ALLOC_PTR(pinger_thread);
if (pinger_thread == NULL)
RETURN(-ENOMEM);
cfs_waitq_init(&pinger_thread->t_ctl_waitq);
l_wait_event(pinger_thread->t_ctl_waitq,
(pinger_thread->t_flags & SVC_STOPPED), &lwi);
- OBD_FREE(pinger_thread, sizeof(*pinger_thread));
+ OBD_FREE_PTR(pinger_thread);
pinger_thread = NULL;
RETURN(rc);
}
{
struct ptlrpc_request_buffer_desc *rqbd;
- OBD_ALLOC(rqbd, sizeof (*rqbd));
+ OBD_ALLOC_PTR(rqbd);
if (rqbd == NULL)
return (NULL);
rqbd->rqbd_buffer = ptlrpc_alloc_request_buffer(svc->srv_buf_size);
if (rqbd->rqbd_buffer == NULL) {
- OBD_FREE(rqbd, sizeof (*rqbd));
+ OBD_FREE_PTR(rqbd);
return (NULL);
}
spin_unlock(&svc->srv_lock);
ptlrpc_free_request_buffer (rqbd->rqbd_buffer, svc->srv_buf_size);
- OBD_FREE (rqbd, sizeof (*rqbd));
+ OBD_FREE_PTR(rqbd);
}
int
LASSERT (bufsize >= max_req_size + SPTLRPC_MAX_PAYLOAD);
LASSERT (ctx_tags != 0);
- OBD_ALLOC(service, sizeof(*service));
+ OBD_ALLOC_PTR(service);
if (service == NULL)
RETURN(NULL);
list_del(&thread->t_link);
spin_unlock(&svc->srv_lock);
- OBD_FREE(thread, sizeof(*thread));
+ OBD_FREE_PTR(thread);
}
void ptlrpc_stop_all_threads(struct ptlrpc_service *svc)
int rc;
ENTRY;
- OBD_ALLOC(thread, sizeof(*thread));
+ OBD_ALLOC_PTR(thread);
if (thread == NULL)
RETURN(-ENOMEM);
cfs_waitq_init(&thread->t_ctl_waitq);
OBD_FREE(rs, service->srv_max_reply_size);
}
- OBD_FREE(service, sizeof(*service));
+ OBD_FREE_PTR(service);
return 0;
}