From: ericm Date: Fri, 12 Aug 2005 07:12:41 +0000 (+0000) Subject: more of b7300: fix (actually hack around) the getattr reply buffer X-Git-Tag: v1_7_100~929 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=02b88a2a3bd8d5a01b8b78c4c410663cf7222660;p=fs%2Flustre-release.git more of b7300: fix (actually hack around) the getattr reply buffer positioning: make remote acl always occupy 2 buffers, just like local acl. --- diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index caf54c3..6d103e9 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -323,7 +323,10 @@ int mdc_access_check(struct obd_export *exp, struct lustre_id *id, 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); @@ -432,58 +435,57 @@ int mdc_req2lustre_capa(struct ptlrpc_request *req, unsigned int offset, 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, @@ -577,13 +579,20 @@ int mdc_req2lustre_md(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) diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index b6f1dc9..c25bd26 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1093,27 +1093,26 @@ int mds_pack_xattr_list(struct dentry *dentry, struct ptlrpc_request *req, } 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) @@ -1121,18 +1120,18 @@ int mds_pack_posix_acl(struct lustre_msg *repmsg, int *offset, 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); @@ -1140,9 +1139,9 @@ int mds_pack_remote_perm(struct ptlrpc_request *req, int *reply_off, 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; } @@ -1179,13 +1178,11 @@ int mds_pack_remote_perm(struct ptlrpc_request *req, int *reply_off, 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; @@ -1193,7 +1190,7 @@ int mds_pack_acl(struct ptlrpc_request *req, int *reply_off, 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; } @@ -1252,7 +1249,8 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry, 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) { @@ -1395,6 +1393,7 @@ static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct dentry *de, /* 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); @@ -1788,7 +1787,7 @@ static int mds_access_check(struct ptlrpc_request *req, int offset) 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) { @@ -1834,8 +1833,7 @@ static int mds_access_check(struct ptlrpc_request *req, int offset) 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; @@ -4147,6 +4145,7 @@ static int mds_intent_prepare_reply_buffers(struct ptlrpc_request *req, 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), @@ -4160,9 +4159,11 @@ static int mds_intent_prepare_reply_buffers(struct ptlrpc_request *req, * 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); diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index 2a34fbc..488ca7c 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -286,7 +286,7 @@ int mds_pack_xattr(struct dentry *dentry, struct ptlrpc_request *req, struct mds_body *repbody, int req_off, int reply_off); int mds_pack_xattr_list(struct dentry *dentry, struct ptlrpc_request *req, struct mds_body *repbody, int reply_off); -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 mds_pack_inode2id(struct obd_device *, struct lustre_id *, diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index efa8f60..816bb60 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -751,7 +751,8 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild, } reply_off = 3; - rc = mds_pack_acl(req, &reply_off, body, dchild->d_inode); + rc = mds_pack_acl(req, reply_off, body, dchild->d_inode); + reply_off += 2; if (rc < 0) { CERROR("pack posix acl: rc = %d\n", rc);