#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;
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;
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,
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,
}
}
spin_unlock(&med->med_open_lock);
-
+
ldlm_cancel_locks_for_export(export);
mds_client_free(export);
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)
{
struct mds_obd *mds = mds_req2mds(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));
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);
}
}
-
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)
/* 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,
static int __init mds_init(void)
{
+
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, LUSTRE_MDS_NAME);
- class_register_type(&mdt_obd_ops, LUSTRE_MDT_NAME);
+ 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>");