body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
memcpy(&body->id1, id, sizeof(*id));
+ size[0] = sizeof(*body);
+ size[1] = sizeof(struct mds_remote_perm);
req->rq_replen = lustre_msg_size(2, size);
+
mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
rc = ptlrpc_queue_wait(req);
mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
RETURN(0);
}
-static int mdc_unpack_acl(struct obd_export *exp_lmv, struct ptlrpc_request *req,
- unsigned int *offset, struct lustre_md *md)
+static
+int mdc_unpack_acl(struct obd_export *exp_lmv, struct ptlrpc_request *req,
+ unsigned int offset, struct lustre_md *md)
{
struct posix_acl *acl;
struct mds_remote_perm *perm;
- int size, acl_off = 0, rc = 0;
- void *buf;
+ int size, rc;
+ void *buf;
+ ENTRY;
- /* if anything wrong when unpacking md, we don't check acl
- * stuff, for simplicity
- */
- if (md->body->valid & OBD_MD_FLACL) {
- acl_off = *offset;
- if (md->body->valid & OBD_MD_FLRMTACL) {
- acl_off++; /* XXX: pass place where acl size is stored */
- buf = lustre_swab_repbuf(req, acl_off++, sizeof(*perm),
- lustre_swab_remote_perm);
- if (buf == NULL) {
- CERROR("Can't unpack remote perm\n");
- RETURN(0);
- }
- OBD_ALLOC(perm, sizeof(*perm));
- if (!perm)
- RETURN(-ENOMEM);
- memcpy(perm, buf, sizeof(*perm));
- md->remote_perm = perm;
- *offset = acl_off;
- } else {
- size = le32_to_cpu(*(__u32 *) lustre_msg_buf(
- req->rq_repmsg, acl_off++, 4));
- buf = lustre_msg_buf(req->rq_repmsg, acl_off++, size);
-
- acl = posix_acl_from_xattr(buf, size);
- *offset = acl_off;
- if (IS_ERR(acl)) {
- rc = PTR_ERR(acl);
- CERROR("convert xattr to acl failed: %d\n", rc);
- RETURN(0);
- } else if (acl) {
- rc = posix_acl_valid(acl);
- if (rc) {
- CERROR("acl valid error: %d\n", rc);
- posix_acl_release(acl);
- RETURN(0);
- }
- }
- md->posix_acl = acl;
+ if (!(md->body->valid & OBD_MD_FLACL))
+ RETURN(0);
+
+ if (md->body->valid & OBD_MD_FLRMTACL) {
+ offset++; /* first 'size' is not used */
+
+ buf = lustre_swab_repbuf(req, offset, sizeof(*perm),
+ lustre_swab_remote_perm);
+ if (buf == NULL) {
+ CERROR("Can't unpack remote perm\n");
+ RETURN(-EFAULT);
}
+
+ OBD_ALLOC(perm, sizeof(*perm));
+ if (!perm)
+ RETURN(-ENOMEM);
+ memcpy(perm, buf, sizeof(*perm));
+ md->remote_perm = perm;
} else {
- *offset += 2;
+ size = le32_to_cpu(*(__u32 *) lustre_msg_buf(
+ req->rq_repmsg, offset, 4));
+ buf = lustre_msg_buf(req->rq_repmsg, offset + 1, size);
+
+ acl = posix_acl_from_xattr(buf, size);
+ if (IS_ERR(acl)) {
+ rc = PTR_ERR(acl);
+ CERROR("convert xattr to acl failed: %d\n", rc);
+ RETURN(rc);
+ } else if (acl) {
+ rc = posix_acl_valid(acl);
+ if (rc) {
+ CERROR("acl valid error: %d\n", rc);
+ posix_acl_release(acl);
+ RETURN(rc);
+ }
+ }
+
+ md->posix_acl = acl;
}
- RETURN(rc);
+
+ RETURN(0);
}
static int mdc_unpack_gskey(struct obd_export *exp_lmv, struct ptlrpc_request *req,
S_ISSOCK(md->body->mode));
}
+ /* if anything wrong when unpacking md, we don't check acl
+ * stuff, for simplicity
+ */
+ if (rc)
+ RETURN(rc);
+
reply_off = (md->body->valid & OBD_MD_FLEASIZE) ?
(offset + 2) : (offset + 1);
- rc = mdc_unpack_acl(exp_lmv, req, &reply_off, md);
+ rc = mdc_unpack_acl(exp_lmv, req, reply_off, md);
if (rc) {
CERROR("upack acl error %d \n", rc);
RETURN(rc);
}
+ reply_off += 2;
rc = mdc_unpack_gskey(exp_lmv, req, &reply_off, md);
if (rc)
}
static
-int mds_pack_posix_acl(struct lustre_msg *repmsg, int *offset,
+int mds_pack_posix_acl(struct lustre_msg *repmsg, int offset,
struct mds_body *body, struct inode *inode)
{
struct dentry de = { .d_inode = inode };
__u32 buflen, *sizep;
void *buf;
- int size, pack_off = *offset;
+ int size;
ENTRY;
- sizep = lustre_msg_buf(repmsg, pack_off++, 4);
+ if (!inode->i_op->getxattr)
+ RETURN(0);
+
+ sizep = lustre_msg_buf(repmsg, offset, 4);
if (!sizep) {
CERROR("can't locate returned acl size buf\n");
RETURN(-EPROTO);
}
-
- if (!inode->i_op->getxattr)
- RETURN(0);
- buflen = repmsg->buflens[pack_off];
- buf = lustre_msg_buf(repmsg, pack_off++, buflen);
- *offset = pack_off;
+ buflen = repmsg->buflens[offset + 1];
+ buf = lustre_msg_buf(repmsg, offset + 1, buflen);
size = inode->i_op->getxattr(&de, XATTR_NAME_ACL_ACCESS, buf, buflen);
if (size == -ENODATA || size == -EOPNOTSUPP)
if (size < 0)
RETURN(size);
LASSERT(size);
- body->valid |= OBD_MD_FLACL;
*sizep = cpu_to_le32(size);
+ body->valid |= OBD_MD_FLACL;
+
RETURN(0);
}
-int mds_pack_remote_perm(struct ptlrpc_request *req, int *reply_off,
+int mds_pack_remote_perm(struct ptlrpc_request *req, int reply_off,
struct mds_body *body, struct inode *inode)
{
struct lustre_sec_desc *lsd;
struct mds_remote_perm *perm;
- int pack_off = *reply_off;
__u32 lsd_perms;
LASSERT(inode->i_op);
LASSERT(req->rq_export->exp_mds_data.med_remote);
perm = (struct mds_remote_perm *)
- lustre_msg_buf(req->rq_repmsg, pack_off++, sizeof(perm));
+ lustre_msg_buf(req->rq_repmsg, reply_off, sizeof(perm));
if (!perm) {
- CERROR("no remote perm buf at offset %d\n", pack_off - 1);
+ CERROR("no remote perm buf at offset %d\n", reply_off);
return -EINVAL;
}
perm->mrp_perm |= MAY_READ;
body->valid |= (OBD_MD_FLACL | OBD_MD_FLRMTACL);
-
- *reply_off = pack_off;
RETURN(0);
}
-int mds_pack_acl(struct ptlrpc_request *req, int *reply_off,
+int mds_pack_acl(struct ptlrpc_request *req, int reply_off,
struct mds_body *body, struct inode *inode)
{
int rc;
if (!req->rq_export->exp_mds_data.med_remote)
rc = mds_pack_posix_acl(req->rq_repmsg, reply_off, body, inode);
else
- rc = mds_pack_remote_perm(req, reply_off, body, inode);
+ rc = mds_pack_remote_perm(req, reply_off + 1, body, inode);
return rc;
}
offset = reply_off + ((reqbody->valid & OBD_MD_FLEASIZE) ? 2 : 1);
if (reqbody->valid & OBD_MD_FLACL) {
- rc = mds_pack_acl(req, &offset, body, inode);
+ rc = mds_pack_acl(req, offset, body, inode);
+ offset += 2;
}
if (reqbody->valid & OBD_MD_FLKEY) {
/* may co-exist with OBD_MD_FLEASIZE */
if (body->valid & OBD_MD_FLACL) {
if (req->rq_export->exp_mds_data.med_remote) {
+ size[bufcount++] = sizeof(int);
size[bufcount++] = sizeof(struct mds_remote_perm);
} else {
size[bufcount++] = sizeof(int);
struct lvfs_ucred uc;
int rep_size[2] = {sizeof(*body),
sizeof(struct mds_remote_perm)};
- int rc = 0, rep_offset;
+ int rc = 0;
ENTRY;
if (!req->rq_export->exp_mds_data.med_remote) {
body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
LASSERT(body);
- rep_offset = 1;
- rc = mds_pack_remote_perm(req, &rep_offset, body, de->d_inode);
+ rc = mds_pack_remote_perm(req, 1, body, de->d_inode);
EXIT;
struct ldlm_intent *it)
{
struct mds_obd *mds = &req->rq_export->exp_obd->u.mds;
+ struct mds_export_data *med = &req->rq_export->u.eu_mds_data;
int rc, reply_buffers;
int repsize[8] = {sizeof(struct ldlm_reply),
sizeof(struct mds_body),
* be fixed in future, Now each item is in the fix position,
* the sequence is lsm, acl, crypto ea, capa.*/
repsize[reply_buffers++] = sizeof(int);
- /* XXX: mds_remote_perm is stored here too, and for it
- * the 'size' is ignored */
- repsize[reply_buffers++] =
+ if (med->med_remote)
+ repsize[reply_buffers++] =
+ sizeof(struct mds_remote_perm);
+ else
+ repsize[reply_buffers++] =
xattr_acl_size(LL_ACL_MAX_ENTRIES);
repsize[reply_buffers++] = sizeof(int);