*
* Copyright (c) 2003 Cluster File Systems, Inc.
*
- * This file is part of Lustre, http://www.lustre.org.
+ * This file is part of the Lustre file system, http://www.lustre.org
+ * Lustre is a trademark of Cluster File Systems, Inc.
*
- * Lustre is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * You may have signed or agreed to another license before downloading
+ * this software. If so, you are bound by the terms and conditions
+ * of that agreement, and the following does not apply to you. See the
+ * LICENSE file included with this distribution for more information.
*
- * Lustre is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * If you did not agree to a different license, then this copy of Lustre
+ * is open source software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
*
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * In either case, Lustre is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * license text for more details.
*/
#define DEBUG_SUBSYSTEM S_MDS
+#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
+#endif
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <asm/segment.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_mds.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
+#include "mds_internal.h"
-void mds_pack_inode2fid(struct obd_device *obd, struct ll_fid *fid,
- struct inode *inode)
+void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode)
{
fid->id = inode->i_ino;
fid->generation = inode->i_generation;
fid->f_type = (S_IFMT & inode->i_mode);
- fid->mds = obd->u.mds.mds_num;
}
/* Note that we can copy all of the fields, just some will not be "valid" */
-void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b,
- struct inode *inode)
+void mds_pack_inode2body(struct mds_body *b, struct inode *inode)
{
b->valid |= OBD_MD_FLID | OBD_MD_FLCTIME | OBD_MD_FLUID |
OBD_MD_FLGID | OBD_MD_FLFLAGS | OBD_MD_FLTYPE |
b->blocks = inode->i_blocks;
b->uid = inode->i_uid;
b->gid = inode->i_gid;
- b->flags = inode->i_flags;
+ b->flags = ll_inode_to_ext_flags(b->flags, inode->i_flags);
b->rdev = inode->i_rdev;
/* Return the correct link count for orphan inodes */
b->nlink = mds_inode_is_orphan(inode) ? 0 : inode->i_nlink;
b->generation = inode->i_generation;
b->suppgid = -1;
- b->mds = obd->u.mds.mds_num;
}
/* unpacking */
if (rec == NULL)
RETURN (-EFAULT);
- r->ur_fsuid = rec->sa_fsuid;
- r->ur_fsgid = rec->sa_fsgid;
- r->ur_cap = rec->sa_cap;
- r->ur_suppgid1 = rec->sa_suppgid;
- r->ur_suppgid2 = -1;
+ r->ur_uc.luc_fsuid = rec->sa_fsuid;
+ r->ur_uc.luc_fsgid = rec->sa_fsgid;
+ r->ur_uc.luc_cap = rec->sa_cap;
+#if 0
+ r->ur_uc.luc_suppgid1 = rec->sa_suppgid;
+ r->ur_uc.luc_suppgid2 = -1;
+#endif
r->ur_fid1 = &rec->sa_fid;
attr->ia_valid = rec->sa_valid;
attr->ia_mode = rec->sa_mode;
LTIME_S(attr->ia_atime) = rec->sa_atime;
LTIME_S(attr->ia_mtime) = rec->sa_mtime;
LTIME_S(attr->ia_ctime) = rec->sa_ctime;
- attr->ia_attr_flags = rec->sa_attr_flags;
+ r->ur_flags = rec->sa_attr_flags;
LASSERT_REQSWAB (req, offset + 1);
- if (req->rq_reqmsg->bufcount > offset + 1) {
- r->ur_eadata = lustre_msg_buf (req->rq_reqmsg,
- offset + 1, 0);
+ if (lustre_msg_bufcount(req->rq_reqmsg) > offset + 1) {
+ r->ur_eadata = lustre_msg_buf(req->rq_reqmsg, offset + 1, 0);
if (r->ur_eadata == NULL)
- RETURN (-EFAULT);
- r->ur_eadatalen = req->rq_reqmsg->buflens[offset + 1];
+ RETURN(-EFAULT);
+ r->ur_eadatalen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
}
- if (req->rq_reqmsg->bufcount > offset + 2) {
+ if (lustre_msg_bufcount(req->rq_reqmsg) > offset + 2) {
r->ur_logcookies = lustre_msg_buf(req->rq_reqmsg, offset + 2,0);
if (r->ur_eadata == NULL)
RETURN (-EFAULT);
- r->ur_cookielen = req->rq_reqmsg->buflens[offset + 2];
+ r->ur_cookielen = lustre_msg_buflen(req->rq_reqmsg, offset + 2);
}
RETURN(0);
struct mds_rec_create *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_create);
+ rec = lustre_swab_reqbuf(req, offset, sizeof (*rec),
+ lustre_swab_mds_rec_create);
if (rec == NULL)
RETURN (-EFAULT);
- r->ur_fsuid = rec->cr_fsuid;
- r->ur_fsgid = rec->cr_fsgid;
- r->ur_cap = rec->cr_cap;
+ r->ur_uc.luc_fsuid = rec->cr_fsuid;
+ r->ur_uc.luc_fsgid = rec->cr_fsgid;
+ r->ur_uc.luc_cap = rec->cr_cap;
+#if 0
+ r->ur_uc.luc_suppgid1 = rec->cr_suppgid;
+ r->ur_uc.luc_suppgid2 = -1;
+#endif
r->ur_fid1 = &rec->cr_fid;
r->ur_fid2 = &rec->cr_replayfid;
r->ur_mode = rec->cr_mode;
r->ur_rdev = rec->cr_rdev;
r->ur_time = rec->cr_time;
r->ur_flags = rec->cr_flags;
- r->ur_suppgid1 = rec->cr_suppgid;
- r->ur_suppgid2 = -1;
- LASSERT_REQSWAB (req, offset + 1);
- r->ur_name = lustre_msg_string (req->rq_reqmsg, offset + 1, 0);
+ LASSERT_REQSWAB(req, offset + 1);
+ r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
RETURN (-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
-
- LASSERT_REQSWAB (req, offset + 2);
- if (req->rq_reqmsg->bufcount > offset + 2) {
- if (S_ISLNK(r->ur_mode)) {
- r->ur_tgt = lustre_msg_string(req->rq_reqmsg,
- offset + 2, 0);
- if (r->ur_tgt == NULL)
- RETURN (-EFAULT);
- r->ur_tgtlen = req->rq_reqmsg->buflens[offset + 2];
- } else if (S_ISDIR(r->ur_mode)) {
- /* Stripe info for mkdir - just a 16bit integer */
- if (req->rq_reqmsg->buflens[offset + 2] != 2) {
- CERROR("mkdir stripe info does not match "
- "expected size %d vs 2\n",
- req->rq_reqmsg->buflens[offset + 2]);
- RETURN (-EINVAL);
- }
- r->ur_eadata = lustre_swab_buf (req->rq_reqmsg,
- offset + 2, 2, __swab16s);
- r->ur_eadatalen = req->rq_reqmsg->buflens[offset + 2];
- } else {
- /* Hm, no other users so far? */
- LBUG();
- }
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
+
+ LASSERT_REQSWAB(req, offset + 2);
+ if (lustre_msg_bufcount(req->rq_reqmsg) > offset + 2) {
+ /* NB for now, we only seem to pass NULL terminated symlink
+ * target strings here. If this ever changes, we'll have
+ * to stop checking for a buffer filled completely with a
+ * NULL terminated string here, and make the callers check
+ * depending on what they expect. We should probably stash
+ * it in r->ur_eadata in that case, so it's obvious... -eeb
+ */
+ r->ur_tgt = lustre_msg_string(req->rq_reqmsg, offset + 2, 0);
+ if (r->ur_tgt == NULL)
+ RETURN (-EFAULT);
+ r->ur_tgtlen = lustre_msg_buflen(req->rq_reqmsg, offset + 2);
}
RETURN(0);
}
struct mds_rec_link *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_link);
+ rec = lustre_swab_reqbuf(req, offset, sizeof (*rec),
+ lustre_swab_mds_rec_link);
if (rec == NULL)
RETURN (-EFAULT);
- r->ur_fsuid = rec->lk_fsuid;
- r->ur_fsgid = rec->lk_fsgid;
- r->ur_cap = rec->lk_cap;
- r->ur_suppgid1 = rec->lk_suppgid1;
- r->ur_suppgid2 = rec->lk_suppgid2;
+ r->ur_uc.luc_fsuid = rec->lk_fsuid;
+ r->ur_uc.luc_fsgid = rec->lk_fsgid;
+ r->ur_uc.luc_cap = rec->lk_cap;
+#if 0
+ r->ur_uc.luc_suppgid1 = rec->lk_suppgid1;
+ r->ur_uc.luc_suppgid2 = rec->lk_suppgid2;
+#endif
r->ur_fid1 = &rec->lk_fid1;
r->ur_fid2 = &rec->lk_fid2;
r->ur_time = rec->lk_time;
- LASSERT_REQSWAB (req, offset + 1);
- r->ur_name = lustre_msg_string (req->rq_reqmsg, offset + 1, 0);
+ LASSERT_REQSWAB(req, offset + 1);
+ r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
RETURN (-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
RETURN(0);
}
struct mds_rec_unlink *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_unlink);
+ rec = lustre_swab_reqbuf(req, offset, sizeof (*rec),
+ lustre_swab_mds_rec_unlink);
if (rec == NULL)
RETURN(-EFAULT);
- r->ur_fsuid = rec->ul_fsuid;
- r->ur_fsgid = rec->ul_fsgid;
- r->ur_cap = rec->ul_cap;
+ r->ur_uc.luc_fsuid = rec->ul_fsuid;
+ r->ur_uc.luc_fsgid = rec->ul_fsgid;
+ r->ur_uc.luc_cap = rec->ul_cap;
+#if 0
+ r->ur_uc.luc_suppgid1 = rec->ul_suppgid;
+ r->ur_uc.luc_suppgid2 = -1;
+#endif
r->ur_mode = rec->ul_mode;
- r->ur_suppgid1 = rec->ul_suppgid;
- r->ur_suppgid2 = -1;
r->ur_fid1 = &rec->ul_fid1;
r->ur_fid2 = &rec->ul_fid2;
r->ur_time = rec->ul_time;
- LASSERT_REQSWAB (req, offset + 1);
+ LASSERT_REQSWAB(req, offset + 1);
r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
RETURN(-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
RETURN(0);
}
struct mds_rec_rename *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_unlink);
+ rec = lustre_swab_reqbuf(req, offset, sizeof (*rec),
+ lustre_swab_mds_rec_rename);
if (rec == NULL)
RETURN(-EFAULT);
- r->ur_fsuid = rec->rn_fsuid;
- r->ur_fsgid = rec->rn_fsgid;
- r->ur_cap = rec->rn_cap;
- r->ur_suppgid1 = rec->rn_suppgid1;
- r->ur_suppgid2 = rec->rn_suppgid2;
+ r->ur_uc.luc_fsuid = rec->rn_fsuid;
+ r->ur_uc.luc_fsgid = rec->rn_fsgid;
+ r->ur_uc.luc_cap = rec->rn_cap;
+#if 0
+ r->ur_uc.luc_suppgid1 = rec->rn_suppgid1;
+ r->ur_uc.luc_suppgid2 = rec->rn_suppgid2;
+#endif
r->ur_fid1 = &rec->rn_fid1;
r->ur_fid2 = &rec->rn_fid2;
r->ur_time = rec->rn_time;
r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
RETURN(-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
LASSERT_REQSWAB (req, offset + 2);
r->ur_tgt = lustre_msg_string(req->rq_reqmsg, offset + 2, 0);
if (r->ur_tgt == NULL)
RETURN(-EFAULT);
- r->ur_tgtlen = req->rq_reqmsg->buflens[offset + 2];
+ r->ur_tgtlen = lustre_msg_buflen(req->rq_reqmsg, offset + 2);
RETURN(0);
}
struct mds_rec_create *rec;
ENTRY;
- rec = lustre_swab_reqbuf (req, offset, sizeof (*rec),
- lustre_swab_mds_rec_create);
+ rec = lustre_swab_reqbuf(req, offset, sizeof(*rec),
+ lustre_swab_mds_rec_create);
if (rec == NULL)
- RETURN (-EFAULT);
+ RETURN(-EFAULT);
- r->ur_fsuid = rec->cr_fsuid;
- r->ur_fsgid = rec->cr_fsgid;
- r->ur_cap = rec->cr_cap;
+ r->ur_uc.luc_fsuid = rec->cr_fsuid;
+ r->ur_uc.luc_fsgid = rec->cr_fsgid;
+ r->ur_uc.luc_cap = rec->cr_cap;
+#if 0
+ r->ur_uc.luc_suppgid1 = rec->cr_suppgid;
+ r->ur_uc.luc_suppgid2 = -1;
+#endif
r->ur_fid1 = &rec->cr_fid;
r->ur_fid2 = &rec->cr_replayfid;
r->ur_mode = rec->cr_mode;
r->ur_rdev = rec->cr_rdev;
r->ur_time = rec->cr_time;
r->ur_flags = rec->cr_flags;
- r->ur_suppgid1 = rec->cr_suppgid;
- r->ur_suppgid2 = -1;
- LASSERT_REQSWAB (req, offset + 1);
- r->ur_name = lustre_msg_string (req->rq_reqmsg, offset + 1, 0);
+ LASSERT_REQSWAB(req, offset + 1);
+ r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
if (r->ur_name == NULL)
- RETURN (-EFAULT);
- r->ur_namelen = req->rq_reqmsg->buflens[offset + 1];
+ RETURN(-EFAULT);
+ r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
- LASSERT_REQSWAB (req, offset + 2);
- if (req->rq_reqmsg->bufcount > offset + 2) {
+ LASSERT_REQSWAB(req, offset + 2);
+ if (lustre_msg_bufcount(req->rq_reqmsg) > offset + 2) {
r->ur_eadata = lustre_msg_buf(req->rq_reqmsg, offset + 2, 0);
if (r->ur_eadata == NULL)
RETURN (-EFAULT);
- r->ur_eadatalen = req->rq_reqmsg->buflens[offset + 2];
+ r->ur_eadatalen = lustre_msg_buflen(req->rq_reqmsg, offset + 2);
}
RETURN(0);
}
typedef int (*update_unpacker)(struct ptlrpc_request *req, int offset,
struct mds_update_record *r);
-static update_unpacker mds_unpackers[REINT_MAX + 1] = {
+static update_unpacker mds_unpackers[REINT_MAX] = {
[REINT_SETATTR] mds_setattr_unpack,
[REINT_CREATE] mds_create_unpack,
[REINT_LINK] mds_link_unpack,
int mds_update_unpack(struct ptlrpc_request *req, int offset,
struct mds_update_record *rec)
{
- __u32 *opcodep;
- __u32 opcode;
+ mds_reint_t opcode, *opcodep;
int rc;
ENTRY;
/* NB don't lustre_swab_reqbuf() here. We're just taking a peek
* and we want to leave it to the specific unpacker once we've
* identified the message type */
- opcodep = lustre_msg_buf (req->rq_reqmsg, offset, sizeof (*opcodep));
+ opcodep = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*opcodep));
if (opcodep == NULL)
RETURN(-EFAULT);
opcode = *opcodep;
- if (lustre_msg_swabbed (req->rq_reqmsg))
- __swab32s (&opcode);
+ if (lustre_msg_swabbed(req->rq_reqmsg))
+ __swab32s(&opcode);
- if (opcode > REINT_MAX ||
- mds_unpackers[opcode] == NULL) {
- CERROR ("Unexpected opcode %d\n", opcode);
+ if (opcode >= REINT_MAX || mds_unpackers[opcode] == NULL) {
+ CERROR("Unexpected opcode %d\n", opcode);
RETURN(-EFAULT);
}
rec->ur_opcode = opcode;
rc = mds_unpackers[opcode](req, offset, rec);
+
RETURN(rc);
}
+
+int mds_init_ucred(struct lvfs_ucred *ucred, struct ptlrpc_request *req,
+ int offset)
+{
+ struct mds_body *body = lustre_msg_buf(req->rq_reqmsg, offset,
+ sizeof(*body));
+#if 0
+ struct mds_obd *mds = mds_req2mds(req);
+ int rc;
+#endif
+
+ LASSERT(body != NULL); /* previously verified & swabbed by caller */
+
+#ifdef CRAY_XT3
+ if (req->rq_uid != LNET_UID_ANY) {
+ /* Non-root local cluster client */
+ LASSERT (req->rq_uid != 0);
+ ucred->luc_fsuid = req->rq_uid;
+ } else
+#endif
+ {
+ ucred->luc_fsuid = body->fsuid;
+ ucred->luc_fsgid = body->fsgid;
+ ucred->luc_cap = body->capability;
+ }
+
+#if 0
+ ucred->luc_uce = upcall_cache_get_entry(mds->mds_group_hash,
+ ucred->luc_fsuid,
+ ucred->luc_fsgid, 1,
+ &body->suppgid);
+ if (IS_ERR(ucred->luc_uce)) {
+ rc = PTR_ERR(ucred->luc_uce);
+ ucred->luc_uce = NULL;
+ return rc;
+ }
+
+#ifdef CRAY_XT3
+ if (ucred->luc_uce)
+ ucred->luc_fsgid = ucred->luc_uce->ue_primary;
+#endif
+#endif
+
+ return 0;
+}
+
+void mds_exit_ucred(struct lvfs_ucred *ucred, struct mds_obd *mds)
+{
+#if 0
+ upcall_cache_put_entry(mds->mds_group_hash, ucred->luc_uce);
+#endif
+}