#define MDS_DISCONNECT 8
#define MDS_GETSTATUS 9
#define MDS_STATFS 10
-#define MDS_LOVINFO 11
+#define MDS_GETLOVINFO 11
#define REINT_SETATTR 1
#define REINT_CREATE 2
/* mds/mds_fs.c */
struct mds_fs_operations {
+ struct module *fs_owner;
void *(* fs_start)(struct inode *inode, int op);
int (* fs_commit)(struct inode *inode, void *handle);
int (* fs_setattr)(struct dentry *dentry, void *handle,
mdc_con2cl(mdc_connh, &cl, &connection, &rconn);
req = ptlrpc_prep_req2(cl, connection, rconn,
- MDS_LOVINFO, 1, size, NULL);
+ MDS_GETLOVINFO, 1, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
req->rq_replen = lustre_msg_size(3, repsize);
} else if (it->it_op == IT_GETATTR || it->it_op == IT_RENAME ||
it->it_op == IT_OPEN || it->it_op == IT_SETATTR ||
- it->it_op == IT_LOOKUP) {
+ it->it_op == IT_LOOKUP || it->it_op == IT_READLINK) {
size[2] = sizeof(struct mds_body);
size[3] = de->d_name.len + 1;
#include <linux/module.h>
#include <linux/lustre_mds.h>
#include <linux/lustre_dlm.h>
-extern int mds_get_lovtgts(struct obd_device *obd, uuid_t *uuidarray);
+extern int mds_get_lovtgts(struct obd_device *obd, int tgt_count,
+ uuid_t *uuidarray);
extern int mds_get_lovdesc(struct obd_device *obd, struct lov_desc *desc);
extern int mds_update_last_rcvd(struct mds_obd *mds, void *handle,
struct ptlrpc_request *req);
RETURN(0);
}
-static int mds_lovinfo(struct ptlrpc_request *req)
+static int mds_getlovinfo(struct ptlrpc_request *req)
{
struct mds_obd *mds = mds_req2mds(req);
struct mds_status_req *streq;
struct lov_desc *desc;
+ int tgt_count;
int rc, size[2] = {sizeof(*desc)};
ENTRY;
desc = lustre_msg_buf(req->rq_repmsg, 0);
rc = mds_get_lovdesc(req->rq_obd, desc);
if (rc != 0 ) {
- CERROR("get_lovdesc error %d", rc);
+ CERROR("mds_get_lovdesc error %d", rc);
req->rq_status = rc;
RETURN(0);
}
- if (desc->ld_tgt_count * sizeof(uuid_t) > streq->repbuf) {
+ tgt_count = NTOH__u32(desc->ld_tgt_count);
+ if (tgt_count * sizeof(uuid_t) > streq->repbuf) {
CERROR("too many targets, enlarge client buffers\n");
req->rq_status = -ENOSPC;
RETURN(0);
}
- mds->mds_max_mdsize = sizeof(desc) +
- desc->ld_tgt_count * sizeof(uuid_t);
- rc = mds_get_lovtgts(req->rq_obd, lustre_msg_buf(req->rq_repmsg, 1));
- if (rc) {
+ mds->mds_max_mdsize = sizeof(desc) + tgt_count * sizeof(uuid_t);
+ rc = mds_get_lovtgts(req->rq_obd, tgt_count,
+ lustre_msg_buf(req->rq_repmsg, 1));
+ if (rc) {
CERROR("get_lovtgts error %d", rc);
req->rq_status = rc;
RETURN(0);
rc = mds_getstatus(req);
break;
- case MDS_LOVINFO:
- CDEBUG(D_INODE, "lovinfo\n");
- rc = mds_lovinfo(req);
+ case MDS_GETLOVINFO:
+ CDEBUG(D_INODE, "getlovinfo\n");
+ rc = mds_getlovinfo(req);
break;
case MDS_GETATTR:
}
static struct mds_fs_operations mds_ext2_fs_ops = {
- fs_start: mds_ext2_start,
- fs_commit: mds_ext2_stop,
- fs_setattr: mds_ext2_setattr,
- fs_set_objid: mds_ext2_set_objid,
- fs_get_objid: mds_ext2_get_objid,
- fs_readpage: mds_ext2_readpage,
- fs_delete_inode:mds_ext2_delete_inode,
- cl_delete_inode:clear_inode,
- fs_journal_data:mds_ext2_journal_data,
- fs_set_last_rcvd:mds_ext2_set_last_rcvd,
+ fs_owner: THIS_MODULE,
+ fs_start: mds_ext2_start,
+ fs_commit: mds_ext2_stop,
+ fs_setattr: mds_ext2_setattr,
+ fs_set_objid: mds_ext2_set_objid,
+ fs_get_objid: mds_ext2_get_objid,
+ fs_readpage: mds_ext2_readpage,
+ fs_delete_inode: mds_ext2_delete_inode,
+ cl_delete_inode: clear_inode,
+ fs_journal_data: mds_ext2_journal_data,
+ fs_set_last_rcvd: mds_ext2_set_last_rcvd,
};
static int __init mds_ext2_init(void)
}
static struct mds_fs_operations mds_ext3_fs_ops = {
- fs_start: mds_ext3_start,
- fs_commit: mds_ext3_commit,
- fs_setattr: mds_ext3_setattr,
- fs_set_objid: mds_ext3_set_objid,
- fs_get_objid: mds_ext3_get_objid,
- fs_readpage: mds_ext3_readpage,
- fs_delete_inode:mds_ext3_delete_inode,
- cl_delete_inode:clear_inode,
- fs_journal_data:mds_ext3_journal_data,
- fs_set_last_rcvd:mds_ext3_set_last_rcvd,
+ fs_owner: THIS_MODULE,
+ fs_start: mds_ext3_start,
+ fs_commit: mds_ext3_commit,
+ fs_setattr: mds_ext3_setattr,
+ fs_set_objid: mds_ext3_set_objid,
+ fs_get_objid: mds_ext3_get_objid,
+ fs_readpage: mds_ext3_readpage,
+ fs_delete_inode: mds_ext3_delete_inode,
+ cl_delete_inode: clear_inode,
+ fs_journal_data: mds_ext3_journal_data,
+ fs_set_last_rcvd: mds_ext3_set_last_rcvd,
};
static int __init mds_ext3_init(void)
}
static struct mds_fs_operations mds_extN_fs_ops = {
+ fs_owner: THIS_MODULE,
fs_start: mds_extN_start,
fs_commit: mds_extN_commit,
fs_setattr: mds_extN_setattr,
/* unlock mds_fs_types list */
}
-int mds_fs_setup(struct mds_obd *mds, struct vfsmount *mnt)
+struct mds_fs_operations *mds_fs_get_ops(char *fstype)
{
struct mds_fs_operations *fs_ops;
- int rc;
- if (!(fs_ops = mds_search_fs_type(mds->mds_fstype))) {
+ if (!(fs_ops = mds_search_fs_type(fstype))) {
char name[32];
+ int rc;
- snprintf(name, sizeof(name) - 1, "mds_%s", mds->mds_fstype);
+ snprintf(name, sizeof(name) - 1, "mds_%s", fstype);
name[sizeof(name) - 1] = '\0';
if ((rc = request_module(name))) {
- fs_ops = mds_search_fs_type(mds->mds_fstype);
+ fs_ops = mds_search_fs_type(fstype);
CDEBUG(D_INFO, "Loaded module '%s'\n", name);
if (!fs_ops)
rc = -ENOENT;
if (rc) {
CERROR("Can't find MDS fs interface '%s'\n", name);
- RETURN(rc);
+ RETURN(ERR_PTR(rc));
}
}
+ __MOD_INC_USE_COUNT(fs_ops->fs_owner);
+
+ return fs_ops;
+}
+
+void mds_fs_put_ops(struct mds_fs_operations *fs_ops)
+{
+ __MOD_DEC_USE_COUNT(fs_ops->fs_owner);
+}
+
+int mds_fs_setup(struct mds_obd *mds, struct vfsmount *mnt)
+{
+ int rc;
+
+ mds->mds_fsops = mds_fs_get_ops(mds->mds_fstype);
+ if (IS_ERR(mds->mds_fsops))
+ RETURN(PTR_ERR(mds->mds_fsops));
- mds->mds_fsops = fs_ops;
mds->mds_vfsmnt = mnt;
OBD_SET_CTXT_MAGIC(&mds->mds_ctxt);
*/
OBD_ALLOC(mds->mds_sop, sizeof(*mds->mds_sop));
if (!mds->mds_sop)
- RETURN(-ENOMEM);
+ GOTO(out_dec, rc = -ENOMEM);
memcpy(mds->mds_sop, mds->mds_sb->s_op, sizeof(*mds->mds_sop));
mds->mds_fsops->cl_delete_inode = mds->mds_sop->delete_inode;
rc = mds_fs_prep(mds);
if (rc)
- OBD_FREE(mds->mds_sop, sizeof(*mds->mds_sop));
+ GOTO(out_free, rc);
+
+ return 0;
+out_free:
+ OBD_FREE(mds->mds_sop, sizeof(*mds->mds_sop));
+out_dec:
+ mds_fs_put_ops(mds->mds_fsops);
return rc;
}
mds_server_free_data(mds);
OBD_FREE(mds->mds_sop, sizeof(*mds->mds_sop));
+ mds_fs_put_ops(mds->mds_fsops);
}
EXPORT_SYMBOL(mds_register_fs_type);
#include <linux/lustre_idl.h>
#include <linux/obd_lov.h>
-int mds_configure_lov(struct obd_device *obd, struct lov_desc *desc,
+int mds_configure_lov(struct obd_device *obd, struct lov_desc *desc,
uuid_t *uuidarray)
{
struct mds_obd *mds = &obd->u.mds;
struct obd_run_ctxt saved;
struct file *f;
- loff_t off = 0;
- int count;
+ int tgt_count;
int rc;
int i;
- count = desc->ld_tgt_count;
- lov_packdesc(desc);
+ tgt_count = desc->ld_tgt_count;
+ lov_packdesc(desc);
push_ctxt(&saved, &mds->mds_ctxt);
f = filp_open("LOVDESC", O_CREAT|O_RDWR, 0644);
- if (!f || IS_ERR(f)) {
- pop_ctxt(&saved);
+ if (IS_ERR(f)) {
CERROR("Cannot open/create LOVDESC file\n");
- RETURN(-EIO);
+ GOTO(out, rc = PTR_ERR(f));
}
-
- rc = lustre_fwrite(f, (char *)desc, sizeof(*desc), &off);
- filp_close(f, 0);
- if (rc != sizeof(*desc)) {
- pop_ctxt(&saved);
+
+ rc = lustre_fwrite(f, (char *)desc, sizeof(*desc), &f->f_pos);
+ if (filp_close(f, 0))
+ CERROR("Error closing LOVDESC file\n");
+ if (rc != sizeof(*desc)) {
CERROR("Cannot open/create LOVDESC file\n");
- RETURN(-EIO);
+ GOTO(out, rc = PTR_ERR(f));
}
- off = 0;
f = filp_open("LOVTGTS", O_CREAT|O_RDWR, 0644);
- if (!f || IS_ERR(f)) {
- pop_ctxt(&saved);
- CERROR("Cannot open/create LOVDESC file\n");
- RETURN(-EIO);
+ if (IS_ERR(f)) {
+ CERROR("Cannot open/create LOVTGTS file\n");
+ GOTO(out, rc = PTR_ERR(f));
}
- for (i=0 ; i < count ; i++) {
- rc = lustre_fwrite(f, uuidarray[i],
- sizeof(uuidarray[i]), &off);
- if (rc != sizeof(uuidarray[i])) {
+ rc = 0;
+ for (i = 0; i < tgt_count ; i++) {
+ rc = lustre_fwrite(f, uuidarray[i],
+ sizeof(uuidarray[i]), &f->f_pos);
+ if (rc != sizeof(uuidarray[i])) {
CERROR("cannot write LOV UUID %s (%d)\n",
uuidarray[i], i);
+ if (rc >= 0)
+ rc = -EIO;
break;
}
- rc = 0;
}
- filp_close(f, 0);
- pop_ctxt(&saved);
+ if (filp_close(f, 0))
+ CERROR("Error closing LOVTGTS file\n");
- RETURN(rc);
+out:
+ pop_ctxt(&saved);
+ RETURN(rc);
}
int mds_get_lovdesc(struct obd_device *obd, struct lov_desc *desc)
struct mds_obd *mds = &obd->u.mds;
struct obd_run_ctxt saved;
struct file *f;
- loff_t off = 0;
- int rc, rc2;
+ int rc;
push_ctxt(&saved, &mds->mds_ctxt);
f = filp_open("LOVDESC", O_RDONLY, 0644);
- if (!f || IS_ERR(f)) {
+ if (!f || IS_ERR(f)) {
CERROR("Cannot open LOVDESC file\n");
- pop_ctxt(&saved);
+ pop_ctxt(&saved);
RETURN(-EIO);
}
-
- rc = lustre_fread(f, (char *)desc, sizeof(*desc), &off);
- rc2 = filp_close(f, 0);
- if (rc2) {
- CERROR("Error closing LOVDESC file %d\n", rc);
- }
- if (rc != sizeof(*desc)) {
+
+ rc = lustre_fread(f, (char *)desc, sizeof(*desc), &f->f_pos);
+ if (filp_close(f, 0))
+ CERROR("Error closing LOVDESC file\n");
+
+ if (rc != sizeof(*desc)) {
CERROR("Cannot read LOVDESC file\n");
- pop_ctxt(&saved);
+ pop_ctxt(&saved);
RETURN(-EIO);
}
- pop_ctxt(&saved);
+ pop_ctxt(&saved);
- RETURN(0);
+ RETURN(0);
}
-int mds_get_lovtgts(struct obd_device *obd, uuid_t *uuidarray)
+int mds_get_lovtgts(struct obd_device *obd, int tgt_count, uuid_t *uuidarray)
{
struct mds_obd *mds = &obd->u.mds;
struct obd_run_ctxt saved;
- struct lov_desc desc;
struct file *f;
- loff_t off = 0;
int rc;
int rc2;
int count;
- rc = mds_get_lovdesc(obd, &desc);
- if (rc) {
- CERROR("cannot get descriptor\n");
- RETURN(-EIO);
- }
-
push_ctxt(&saved, &mds->mds_ctxt);
f = filp_open("LOVTGTS", O_RDONLY, 0644);
- if (!f || IS_ERR(f)) {
+ if (IS_ERR(f)) {
CERROR("Cannot open LOVTGTS file\n");
- pop_ctxt(&saved);
- RETURN(-EIO);
+ GOTO(out, rc = PTR_ERR(f));
}
- lov_unpackdesc(&desc);
- count = desc.ld_tgt_count;
-
- off = 0;
- rc = lustre_fread(f, (char *)uuidarray, count * sizeof(uuid_t),
- &off);
+ rc = lustre_fread(f, (char *)uuidarray, tgt_count * sizeof(uuid_t),
+ &f->f_pos);
rc2 = filp_close(f, 0);
- if (rc2) {
- CERROR("Error closing LOVTGTS file %d\n", rc);
- }
- if (rc != count * sizeof(uuid_t)) {
- CERROR("Error reading LOVTGTS file\n");
- pop_ctxt(&saved);
- RETURN(-EIO);
+ if (rc2)
+ CERROR("Error closing LOVTGTS file: rc = %d\n", rc2);
+
+ if (rc != count * sizeof(uuid_t)) {
+ CERROR("Error reading LOVTGTS file: rc = %d\n", rc);
+ if (rc >= 0)
+ rc = -EIO;
+ GOTO(out, rc);
}
- pop_ctxt(&saved);
+ EXIT;
+out:
+ pop_ctxt(&saved);
- RETURN(0);
+ RETURN(rc);
}
-int mds_iocontrol(long cmd, struct lustre_handle *conn,
+int mds_iocontrol(long cmd, struct lustre_handle *conn,
int len, void *karg, void *uarg)
{
struct obd_device *obd = class_conn2obd(conn);
struct obd_ioctl_data *data = karg;
- struct lov_desc *desc;
- int count;
- int rc;
+ struct lov_desc *desc;
+ int count;
+ int rc;
- switch (cmd) {
+ switch (cmd) {
case OBD_IOC_LOV_CONFIG:
desc = (struct lov_desc *)data->ioc_inlbuf1;
- if (sizeof(*desc) > data->ioc_inllen1) {
+ if (sizeof(*desc) > data->ioc_inllen1) {
CERROR("descriptor size wrong\n");
- RETURN(-EINVAL);
+ RETURN(-EINVAL);
}
count = desc->ld_tgt_count;
- if (sizeof(uuid_t) * count != data->ioc_inllen2) {
+ if (sizeof(uuid_t) * count != data->ioc_inllen2) {
CERROR("UUID array size wrong\n");
- RETURN(-EINVAL);
+ RETURN(-EINVAL);
}
rc = mds_configure_lov(obd, desc, (uuid_t *)data->ioc_inlbuf2);
- RETURN(rc);
+ RETURN(rc);
default:
- RETURN(-EINVAL);
+ RETURN(-EINVAL);
}
RETURN(0);