#include <linux/lustre_dlm.h>
#include <linux/init.h>
#include <linux/obd_class.h>
+#include <linux/random.h>
+#include <linux/locks.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+#include <linux/buffer_head.h>
+#endif
+#include <linux/lprocfs_status.h>
+
+static kmem_cache_t *mds_file_cache;
-extern int mds_get_lovtgts(struct obd_device *obd, int tgt_count,
+extern int mds_get_lovtgts(struct mds_obd *obd, int tgt_count,
obd_uuid_t *uuidarray);
-extern int mds_get_lovdesc(struct obd_device *obd, struct lov_desc *desc);
+extern int mds_get_lovdesc(struct mds_obd *obd, struct lov_desc *desc);
extern int mds_update_last_rcvd(struct mds_obd *mds, void *handle,
struct ptlrpc_request *req);
static int mds_cleanup(struct obd_device * obddev);
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
+
inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
{
return &req->rq_export->exp_obd->u.mds;
int dir_lock_mode)
{
struct dentry *dchild;
- int flags, rc;
+ int flags = 0, rc;
__u64 res_id[3] = {0};
ENTRY;
RETURN(dchild);
res_id[0] = dchild->d_inode->i_ino;
+ res_id[1] = dchild->d_inode->i_generation;
rc = ldlm_match_or_enqueue(NULL, NULL, obd->obd_namespace, NULL,
res_id, LDLM_PLAIN, NULL, 0, lock_mode,
&flags, ldlm_completion_ast,
{
struct mds_obd *mds = &obd->u.mds;
struct dentry *de = mds_fid2dentry(mds, fid, mnt), *retval = de;
- int flags, rc;
+ int flags = 0, rc;
__u64 res_id[3] = {0};
ENTRY;
RETURN(de);
res_id[0] = de->d_inode->i_ino;
+ res_id[1] = de->d_inode->i_generation;
rc = ldlm_match_or_enqueue(NULL, NULL, obd->obd_namespace, NULL,
res_id, LDLM_PLAIN, NULL, 0, lock_mode,
&flags, ldlm_completion_ast,
RETURN(retval);
}
+#ifndef DCACHE_DISCONNECTED
+#define DCACHE_DISCONNECTED DCACHE_NFSD_DISCONNECTED
+#endif
+
/* Look up an entry by inode number. */
struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
struct vfsmount **mnt)
spin_lock(&dcache_lock);
list_for_each(lp, &inode->i_dentry) {
result = list_entry(lp, struct dentry, d_alias);
- if (!(result->d_flags & DCACHE_NFSD_DISCONNECTED)) {
+ if (!(result->d_flags & DCACHE_DISCONNECTED)) {
dget_locked(result);
result->d_vfs_flags |= DCACHE_REFERENCED;
spin_unlock(&dcache_lock);
}
if (mnt)
mntget(*mnt);
- result->d_flags |= DCACHE_NFSD_DISCONNECTED;
+ result->d_flags |= DCACHE_DISCONNECTED;
return result;
}
* on the server, etc.
*/
static int mds_connect(struct lustre_handle *conn, struct obd_device *obd,
- obd_uuid_t cluuid)
+ obd_uuid_t cluuid, struct recovd_obd *recovd,
+ ptlrpc_recovery_cb_t recover)
{
struct obd_export *exp;
+ struct mds_export_data *med;
struct mds_client_data *mcd;
struct list_head *p;
int rc;
if (!list_empty(&exp->exp_conn_chain)) {
CERROR("existing uuid/export, list not empty!\n");
spin_unlock(&obd->obd_dev_lock);
+ /* XXX should we MOD_DEC_USE_COUNT; here? */
RETURN(-EALREADY);
}
conn->addr = (__u64) (unsigned long)exp;
cluuid, exp);
CDEBUG(D_IOCTL,"connect: addr %Lx cookie %Lx\n",
(long long)conn->addr, (long long)conn->cookie);
+ MOD_DEC_USE_COUNT;
RETURN(0);
}
}
GOTO(out_dec, rc);
exp = class_conn2export(conn);
LASSERT(exp);
+ med = &exp->exp_mds_data;
OBD_ALLOC(mcd, sizeof(*mcd));
if (!mcd) {
CERROR("mds: out of memory for client data\n");
GOTO(out_export, rc = -ENOMEM);
}
+
memcpy(mcd->mcd_uuid, cluuid, sizeof(mcd->mcd_uuid));
- exp->exp_mds_data.med_mcd = mcd;
- rc = mds_client_add(&exp->exp_mds_data, -1);
+ med->med_mcd = mcd;
+
+ INIT_LIST_HEAD(&med->med_open_head);
+ spin_lock_init(&med->med_open_lock);
+
+ rc = mds_client_add(med, -1);
if (rc)
GOTO(out_mdc, rc);
return rc;
}
+/* Call with med->med_open_lock held, please. */
+inline int mds_close_mfd(struct mds_file_data *mfd, struct mds_export_data *med)
+{
+ struct file *file = mfd->mfd_file;
+ LASSERT(file->private_data == mfd);
+
+ list_del(&mfd->mfd_list);
+ mfd->mfd_servercookie = DEAD_HANDLE_MAGIC;
+ kmem_cache_free(mds_file_cache, mfd);
+
+ return filp_close(file, 0);
+}
+
static int mds_disconnect(struct lustre_handle *conn)
{
- int rc;
struct obd_export *export = class_conn2export(conn);
+ struct list_head *tmp, *n;
+ struct mds_export_data *med = &export->exp_mds_data;
+ int rc;
+ ENTRY;
+
+ /*
+ * Close any open files.
+ */
+ spin_lock(&med->med_open_lock);
+ list_for_each_safe(tmp, n, &med->med_open_head) {
+ struct mds_file_data *mfd =
+ list_entry(tmp, struct mds_file_data, mfd_list);
+ rc = mds_close_mfd(mfd, med);
+ if (rc) {
+ /* XXX better diagnostics, with file path and stuff */
+ CDEBUG(D_INODE, "Error %d closing mfd %p\n", rc, mfd);
+ }
+ }
+ spin_unlock(&med->med_open_lock);
ldlm_cancel_locks_for_export(export);
mds_client_free(export);
if (!rc)
MOD_DEC_USE_COUNT;
- return rc;
+ RETURN(rc);
+}
+
+/*
+ * XXX This is NOT guaranteed to flush all transactions to disk (even though
+ * it is equivalent to calling sync()) because it only _starts_ the flush
+ * and does not wait for completion. It's better than nothing though.
+ * What we really want is a mild form of fsync_dev_lockfs(), but it is
+ * non-standard, or enabling do_sync_supers in ext3, just for this call.
+ */
+static void mds_fsync_super(struct super_block *sb)
+{
+ lock_kernel();
+ lock_super(sb);
+ if (sb->s_dirt && sb->s_op && sb->s_op->write_super)
+ sb->s_op->write_super(sb);
+ unlock_super(sb);
+ unlock_kernel();
}
static int mds_getstatus(struct ptlrpc_request *req)
RETURN(0);
}
- /* Anything we need to do here with the client's trans no or so? */
+ /* Flush any outstanding transactions to disk so the client will
+ * get the latest last_committed value and can drop their local
+ * requests if they have any. This would be fsync_super() if it
+ * was exported.
+ */
+ mds_fsync_super(mds->mds_sb);
+
body = lustre_msg_buf(req->rq_repmsg, 0);
memcpy(&body->fid1, &mds->mds_rootfid, sizeof(body->fid1));
}
desc = lustre_msg_buf(req->rq_repmsg, 0);
- rc = mds_get_lovdesc(req->rq_obd, desc);
- if (rc != 0 ) {
+ rc = mds_get_lovdesc(mds, desc);
+ if (rc) {
CERROR("mds_get_lovdesc error %d", rc);
req->rq_status = rc;
RETURN(0);
mds->mds_max_mdsize = sizeof(struct lov_mds_md) +
tgt_count * sizeof(struct lov_object_id);
- rc = mds_get_lovtgts(req->rq_obd, tgt_count,
+ rc = mds_get_lovtgts(mds, tgt_count,
lustre_msg_buf(req->rq_repmsg, 1));
if (rc) {
CERROR("get_lovtgts error %d\n", rc);
RETURN(0);
}
+ /* XXX layering violation! -phil */
l_lock(&lock->l_resource->lr_namespace->ns_lock);
lock->l_flags |= LDLM_FL_CBPENDING;
do_ast = (!lock->l_readers && !lock->l_writers);
struct inode *dir;
struct lustre_handle lockh;
char *name;
- int namelen, flags, lock_mode, rc = 0;
+ int namelen, flags = 0, lock_mode, rc = 0;
struct obd_ucred uc;
__u64 res_id[3] = {0, 0, 0};
ENTRY;
lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
res_id[0] = dir->i_ino;
+ res_id[1] = dir->i_generation;
rc = ldlm_lock_match(obd->obd_namespace, res_id, LDLM_PLAIN,
NULL, 0, lock_mode, &lockh);
push_ctxt(&saved, &mds->mds_ctxt, &uc);
de = mds_fid2dentry(mds, &body->fid1, NULL);
if (IS_ERR(de)) {
- req->rq_status = -ENOENT;
- rc = 0;
+ rc = req->rq_status = -ENOENT;
GOTO(out_pop, PTR_ERR(de));
}
RETURN(0);
}
+static struct mds_file_data *mds_handle2mfd(struct lustre_handle *handle)
+{
+ struct mds_file_data *mfd = NULL;
+
+ if (!handle || !handle->addr)
+ RETURN(NULL);
+
+ mfd = (struct mds_file_data *)(unsigned long)(handle->addr);
+ if (!kmem_cache_validate(mds_file_cache, mfd))
+ RETURN(NULL);
+
+ if (mfd->mfd_servercookie != handle->cookie)
+ RETURN(NULL);
+
+ return mfd;
+}
+
+static int mds_store_ea(struct mds_obd *mds, struct ptlrpc_request *req,
+ struct mds_body *body, struct dentry *de,
+ struct lov_mds_md *lmm)
+{
+ struct obd_run_ctxt saved;
+ struct obd_ucred uc;
+ void *handle;
+ int rc, rc2;
+
+ uc.ouc_fsuid = body->fsuid;
+ uc.ouc_fsgid = body->fsgid;
+ push_ctxt(&saved, &mds->mds_ctxt, &uc);
+ handle = mds_fs_start(mds, de->d_inode, MDS_FSOP_SETATTR);
+ if (!handle)
+ GOTO(out_ea, rc = -ENOMEM);
+
+ rc = mds_fs_set_md(mds, de->d_inode, handle, lmm);
+ if (!rc)
+ rc = mds_update_last_rcvd(mds, handle, req);
+
+ rc2 = mds_fs_commit(mds, de->d_inode, handle);
+ if (rc2 && !rc)
+ rc = rc2;
+out_ea:
+ pop_ctxt(&saved);
+
+ return rc;
+}
+
static int mds_open(struct ptlrpc_request *req)
{
- struct dentry *de;
+ struct mds_obd *mds = mds_req2mds(req);
struct mds_body *body;
+ struct mds_export_data *med;
+ struct mds_file_data *mfd;
+ struct dentry *de;
struct file *file;
struct vfsmount *mnt;
- struct mds_obd *mds = mds_req2mds(req);
- struct mds_export_data *med;
__u32 flags;
struct list_head *tmp;
- struct mds_file_data *mfd;
int rc, size = sizeof(*body);
ENTRY;
- rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
- if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK)) {
- CERROR("mds: out of memory\n");
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK)) {
+ CERROR("test case OBD_FAIL_MDS_OPEN_PACK\n");
req->rq_status = -ENOMEM;
- RETURN(0);
+ RETURN(-ENOMEM);
+ }
+
+ rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
+ if (rc) {
+ CERROR("mds: pack error: rc = %d\n", rc);
+ req->rq_status = rc;
+ RETURN(rc);
}
body = lustre_msg_buf(req->rq_reqmsg, 0);
- /* was this animal open already? */
- /* XXX we should only check on re-open, or do a refcount... */
+ /* was this animal open already and the client lost the reply? */
+ /* XXX need some way to detect a reopen, to avoid locked list walks */
med = &req->rq_export->exp_mds_data;
+ spin_lock(&med->med_open_lock);
list_for_each(tmp, &med->med_open_head) {
- struct mds_file_data *fd;
- fd = list_entry(tmp, struct mds_file_data, mfd_list);
- if (body->extra == fd->mfd_clientfd &&
- body->fid1.id == fd->mfd_file->f_dentry->d_inode->i_ino) {
+ mfd = list_entry(tmp, typeof(*mfd), mfd_list);
+ if (!memcmp(&mfd->mfd_clienthandle, &body->handle,
+ sizeof(mfd->mfd_clienthandle)) &&
+ body->fid1.id == mfd->mfd_file->f_dentry->d_inode->i_ino) {
+ de = mfd->mfd_file->f_dentry;
+ spin_unlock(&med->med_open_lock);
CERROR("Re opening "LPD64"\n", body->fid1.id);
- RETURN(0);
+ GOTO(out_pack, rc = 0);
}
}
+ spin_unlock(&med->med_open_lock);
- OBD_ALLOC(mfd, sizeof(*mfd));
+ mfd = kmem_cache_alloc(mds_file_cache, GFP_KERNEL);
if (!mfd) {
CERROR("mds: out of memory\n");
req->rq_status = -ENOMEM;
}
de = mds_fid2dentry(mds, &body->fid1, &mnt);
- if (IS_ERR(de)) {
- req->rq_status = -ENOENT;
- RETURN(0);
- }
+ if (IS_ERR(de))
+ GOTO(out_free, rc = PTR_ERR(de));
/* check if this inode has seen a delayed object creation */
- if (req->rq_reqmsg->bufcount > 1) {
- void *handle;
- struct lov_mds_md *lmm;
- struct inode *inode = de->d_inode;
- int rc;
+ if (lustre_msg_get_op_flags(req->rq_reqmsg) & MDS_OPEN_HAS_EA) {
+ struct lov_mds_md *lmm = lustre_msg_buf(req->rq_reqmsg, 1);
- lmm = lustre_msg_buf(req->rq_reqmsg, 1);
-
- handle = mds_fs_start(mds, de->d_inode, MDS_FSOP_SETATTR);
- if (!handle) {
- req->rq_status = -ENOMEM;
- RETURN(0);
- }
-
- /* XXX error handling */
- rc = mds_fs_set_md(mds, inode, handle, lmm);
- if (!rc) {
- struct obd_run_ctxt saved;
- struct obd_ucred uc;
- uc.ouc_fsuid = body->fsuid;
- uc.ouc_fsgid = body->fsgid;
- push_ctxt(&saved, &mds->mds_ctxt, &uc);
- rc = mds_update_last_rcvd(mds, handle, req);
- pop_ctxt(&saved);
- } else {
- req->rq_status = rc;
- RETURN(0);
- }
- /* FIXME: need to return last_rcvd, last_committed */
-
- /* FIXME: keep rc intact */
- rc = mds_fs_commit(mds, de->d_inode, handle);
+ rc = mds_store_ea(mds, req, body, de, lmm);
if (rc) {
- req->rq_status = rc;
- RETURN(0);
+ l_dput(de);
+ mntput(mnt);
+ GOTO(out_free, rc);
}
}
flags = body->flags;
+ /* dentry_open does a dput(de) and mntput(mnt) on error */
file = dentry_open(de, mnt, flags & ~O_DIRECT);
- if (!file || IS_ERR(file)) {
- req->rq_status = -EINVAL;
- OBD_FREE(mfd, sizeof(*mfd));
- RETURN(0);
+ if (IS_ERR(file)) {
+ rc = PTR_ERR(file);
+ GOTO(out_free, 0);
}
file->private_data = mfd;
mfd->mfd_file = file;
- mfd->mfd_clientfd = body->extra;
+ memcpy(&mfd->mfd_clienthandle, &body->handle, sizeof(body->handle));
+ get_random_bytes(&mfd->mfd_servercookie, sizeof(mfd->mfd_servercookie));
+ spin_lock(&med->med_open_lock);
list_add(&mfd->mfd_list, &med->med_open_head);
+ spin_unlock(&med->med_open_lock);
+out_pack:
body = lustre_msg_buf(req->rq_repmsg, 0);
- /* FIXME: need to have cookies involved here */
- body->extra = (__u64) (unsigned long)file;
+ mds_pack_inode2fid(&body->fid1, de->d_inode);
+ mds_pack_inode2body(body, de->d_inode);
+ body->handle.addr = (__u64)(unsigned long)mfd;
+ body->handle.cookie = mfd->mfd_servercookie;
+ CDEBUG(D_INODE, "llite file "LPX64": addr %p, cookie "LPX64"\n",
+ mfd->mfd_clienthandle.addr, mfd, mfd->mfd_servercookie);
+ RETURN(0);
+
+out_free:
+ mfd->mfd_servercookie = DEAD_HANDLE_MAGIC;
+ kmem_cache_free(mds_file_cache, mfd);
+ req->rq_status = rc;
RETURN(0);
}
static int mds_close(struct ptlrpc_request *req)
{
- struct dentry *de;
+ struct mds_export_data *med = &req->rq_export->exp_mds_data;
struct mds_body *body;
- struct file *file;
- struct mds_obd *mds = mds_req2mds(req);
- struct vfsmount *mnt;
struct mds_file_data *mfd;
int rc;
ENTRY;
- rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg);
- if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK)) {
- CERROR("mds: out of memory\n");
- req->rq_status = -ENOMEM;
- RETURN(0);
- }
-
body = lustre_msg_buf(req->rq_reqmsg, 0);
- de = mds_fid2dentry(mds, &body->fid1, &mnt);
- if (IS_ERR(de)) {
- req->rq_status = -ENOENT;
- RETURN(0);
+
+ mfd = mds_handle2mfd(&body->handle);
+ if (!mfd) {
+ CERROR("no handle for file close "LPD64
+ ": addr "LPX64", cookie "LPX64"\n",
+ body->fid1.id, body->handle.addr, body->handle.cookie);
+ RETURN(-ESTALE);
}
- /* FIXME: need to have cookies involved here */
- file = (struct file *)(unsigned long)body->extra;
- if (!file->f_dentry)
- LBUG();
- mfd = (struct mds_file_data *)file->private_data;
- list_del(&mfd->mfd_list);
- OBD_FREE(mfd, sizeof(*mfd));
+ spin_lock(&med->med_open_lock);
+ req->rq_status = mds_close_mfd(mfd, med);
+ spin_unlock(&med->med_open_lock);
- req->rq_status = filp_close(file, 0);
- l_dput(de);
- mntput(mnt);
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK)) {
+ CERROR("test case OBD_FAIL_MDS_CLOSE_PACK\n");
+ req->rq_status = -ENOMEM;
+ RETURN(-ENOMEM);
+ }
+
+ rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg);
+ if (rc) {
+ CERROR("mds: lustre_pack_msg: rc = %d\n", rc);
+ req->rq_status = rc;
+ }
RETURN(0);
}
if (req->rq_reqmsg->opc != MDS_CONNECT && req->rq_export == NULL)
GOTO(out, rc = -ENOTCONN);
- if (strcmp(req->rq_obd->obd_type->typ_name, "mds") != 0)
- GOTO(out, rc = -EINVAL);
+ LASSERT(!strcmp(req->rq_obd->obd_type->typ_name, LUSTRE_MDT_NAME));
switch (req->rq_reqmsg->opc) {
case MDS_CONNECT:
if (rc)
break;
RETURN(0);
-
case LDLM_CONVERT:
CDEBUG(D_INODE, "convert\n");
OBD_FAIL_RETURN(OBD_FAIL_LDLM_CONVERT, 0);
if (rc)
break;
RETURN(0);
-
- case LDLM_CANCEL:
- CDEBUG(D_INODE, "cancel\n");
- OBD_FAIL_RETURN(OBD_FAIL_LDLM_CANCEL, 0);
- rc = ldlm_handle_cancel(req);
- if (rc)
- break;
- RETURN(0);
case LDLM_BL_CALLBACK:
case LDLM_CP_CALLBACK:
CDEBUG(D_INODE, "callback\n");
RETURN(-EIO);
RETURN(rc);
}
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
rc = fsync_dev(filp->f_dentry->d_inode->i_rdev);
+#else
+ rc = file_fsync(filp, filp->f_dentry, 1);
+#endif
if (rc)
CERROR("error flushing MDS server data: rc = %d\n", rc);
return rc;
}
-#define MDS_NUM_THREADS 8
/* mount the file system (secretly) */
static int mds_setup(struct obd_device *obddev, obd_count len, void *buf)
{
- int i;
struct obd_ioctl_data* data = buf;
struct mds_obd *mds = &obddev->u.mds;
struct vfsmount *mnt;
GOTO(err_kfree, rc);
}
+ CERROR("%s: mnt is %p\n", data->ioc_inlbuf1, mnt);
mds->mds_sb = mnt->mnt_root->d_inode->i_sb;
if (!mds->mds_sb)
GOTO(err_put, rc = -ENODEV);
GOTO(err_put, rc);
}
- mds->mds_service = ptlrpc_init_svc(MDS_NEVENTS, MDS_NBUFS,
- MDS_BUFSIZE, MDS_MAXREQSIZE,
- MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL,
- "self", mds_handle, "mds");
- if (!mds->mds_service) {
- CERROR("failed to start service\n");
- GOTO(err_fs, rc = -EINVAL);
- }
-
obddev->obd_namespace =
ldlm_namespace_new("mds_server", LDLM_NAMESPACE_SERVER);
if (obddev->obd_namespace == NULL) {
mds_cleanup(obddev);
- GOTO(err_svc, rc = -ENOMEM);
+ GOTO(err_fs, rc = -ENOMEM);
}
- for (i = 0; i < MDS_NUM_THREADS; i++) {
- char name[32];
- sprintf(name, "lustre_MDS_%02d", i);
- rc = ptlrpc_start_thread(obddev, mds->mds_service, name);
- if (rc) {
- CERROR("cannot start MDS thread #%d: rc %d\n", i, rc);
- GOTO(err_thread, rc);
- }
- }
rc = mds_recover(obddev);
if (rc)
- GOTO(err_thread, rc);
+ GOTO(err_fs, rc);
ptlrpc_init_client(LDLM_REQUEST_PORTAL, LDLM_REPLY_PORTAL,
"mds_ldlm_client", &obddev->obd_ldlm_client);
RETURN(0);
-err_thread:
- ptlrpc_stop_all_threads(mds->mds_service);
-err_svc:
- ptlrpc_unregister_service(mds->mds_service);
err_fs:
mds_fs_cleanup(obddev);
err_put:
kfree(mds->mds_fstype);
err_dec:
MOD_DEC_USE_COUNT;
- return rc;
+ RETURN(rc);
}
static int mds_cleanup(struct obd_device *obddev)
struct obd_run_ctxt saved;
ENTRY;
- ptlrpc_stop_all_threads(mds->mds_service);
- ptlrpc_unregister_service(mds->mds_service);
-
sb = mds->mds_sb;
if (!mds->mds_sb)
RETURN(0);
}
static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
- ldlm_mode_t mode, void *data)
+ ldlm_mode_t mode, int flags, void *data)
{
struct ptlrpc_request *req = req_cookie;
int rc = 0;
}
}
+ if (flags & LDLM_FL_INTENT_ONLY) {
+ LDLM_DEBUG(lock, "INTENT_ONLY, aborting lock");
+ RETURN(ELDLM_LOCK_ABORTED);
+ }
/* Give the client a lock on the child object, instead of the
* parent that it requested. */
new_resid[0] = NTOH__u32(mds_rep->ino);
+ new_resid[1] = NTOH__u32(mds_rep->generation);
if (new_resid[0] == 0)
LBUG();
old_res = lock->l_resource->lr_name[0];
RETURN(rc);
}
+int mds_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ int rc;
+ rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return rc;
+}
+
+int mds_detach(struct obd_device *dev)
+{
+ int rc;
+ rc = lprocfs_dereg_obd(dev);
+ return rc;
+
+}
+
+#define MDT_NUM_THREADS 8
+static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
+{
+ int i;
+ // struct obd_ioctl_data* data = buf;
+ struct mds_obd *mds = &obddev->u.mds;
+ int rc = 0;
+ ENTRY;
+
+ MOD_INC_USE_COUNT;
+
+ mds->mds_service = ptlrpc_init_svc(MDS_NEVENTS, MDS_NBUFS,
+ MDS_BUFSIZE, MDS_MAXREQSIZE,
+ MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL,
+ "self", mds_handle, "mds");
+ if (!mds->mds_service) {
+ CERROR("failed to start service\n");
+ GOTO(err_dec, rc = -EINVAL);
+ }
+
+ for (i = 0; i < MDT_NUM_THREADS; i++) {
+ char name[32];
+ sprintf(name, "lustre_MDT_%02d", i);
+ rc = ptlrpc_start_thread(obddev, mds->mds_service, name);
+ if (rc) {
+ CERROR("cannot start MDT thread #%d: rc %d\n", i, rc);
+ GOTO(err_thread, rc);
+ }
+ }
+
+ RETURN(0);
+
+err_thread:
+ ptlrpc_stop_all_threads(mds->mds_service);
+ ptlrpc_unregister_service(mds->mds_service);
+err_dec:
+ MOD_DEC_USE_COUNT;
+ RETURN(rc);
+}
+
+
+static int mdt_cleanup(struct obd_device *obddev)
+{
+ struct mds_obd *mds = &obddev->u.mds;
+ ENTRY;
+
+ ptlrpc_stop_all_threads(mds->mds_service);
+ ptlrpc_unregister_service(mds->mds_service);
+
+ MOD_DEC_USE_COUNT;
+ RETURN(0);
+}
extern int mds_iocontrol(long cmd, struct lustre_handle *conn,
int len, void *karg, void *uarg);
/* use obd ops to offer management infrastructure */
static struct obd_ops mds_obd_ops = {
+ o_attach: mds_attach,
+ o_detach: mds_detach,
o_connect: mds_connect,
o_disconnect: mds_disconnect,
o_setup: mds_setup,
o_iocontrol: mds_iocontrol
};
+static struct obd_ops mdt_obd_ops = {
+ o_setup: mdt_setup,
+ o_cleanup: mdt_cleanup,
+};
+
+
static int __init mds_init(void)
{
- class_register_type(&mds_obd_ops, LUSTRE_MDS_NAME);
+
+ mds_file_cache = kmem_cache_create("ll_mds_file_data",
+ sizeof(struct mds_file_data),
+ 0, 0, NULL, NULL);
+ if (mds_file_cache == NULL)
+ return -ENOMEM;
+
+ class_register_type(&mds_obd_ops, (lprocfs_vars_t*)status_class_var,
+ LUSTRE_MDS_NAME);
+ class_register_type(&mdt_obd_ops, 0, LUSTRE_MDT_NAME);
+
ldlm_register_intent(ldlm_intent_policy);
+
return 0;
+
}
static void __exit mds_exit(void)
{
+
+
ldlm_unregister_intent();
class_unregister_type(LUSTRE_MDS_NAME);
+ class_unregister_type(LUSTRE_MDT_NAME);
+ if (kmem_cache_destroy(mds_file_cache))
+ CERROR("couldn't free MDS file cache\n");
+
}
MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");