* lustre/mds/mds_extN.c
* Lustre Metadata Server (mds) journal abstraction routines
*
- * Copyright (c) 2002 Cluster File Systems, Inc.
+ * Copyright (C) 2002 Cluster File Systems, Inc.
* Author: Andreas Dilger <adilger@clusterfs.com>
*
* This file is part of Lustre, http://www.lustre.org.
#include <linux/obd_lov.h>
static struct mds_fs_operations mds_extN_fs_ops;
-static kmem_cache_t *jcb_cache;
-static int jcb_cache_count;
+static kmem_cache_t *mcb_cache;
+static int mcb_cache_count;
struct mds_cb_data {
struct journal_callback cb_jcb;
{
/* For updates to the last recieved file */
int nblocks = EXTN_DATA_TRANS_BLOCKS;
+ void *handle;
switch(op) {
case MDS_FSOP_RMDIR:
LBUG();
}
- return journal_start(EXTN_JOURNAL(inode), nblocks);
+ lock_kernel();
+ handle = journal_start(EXTN_JOURNAL(inode), nblocks);
+ unlock_kernel();
+
+ return handle;
}
static int mds_extN_commit(struct inode *inode, void *handle)
{
- return journal_stop((handle_t *)handle);
+ int rc;
+
+ lock_kernel();
+ rc = journal_stop((handle_t *)handle);
+ unlock_kernel();
+
+ return rc;
}
-/* Assumes BKL is held */
static int mds_extN_setattr(struct dentry *dentry, void *handle,
struct iattr *iattr)
{
struct inode *inode = dentry->d_inode;
+ int rc;
+ lock_kernel();
if (inode->i_op->setattr)
- return inode->i_op->setattr(dentry, iattr);
+ rc = inode->i_op->setattr(dentry, iattr);
else
- return inode_setattr(inode, iattr);
+ rc = inode_setattr(inode, iattr);
+
+ unlock_kernel();
+
+ return rc;
}
static int mds_extN_set_md(struct inode *inode, void *handle,
down(&inode->i_sem);
lock_kernel();
- if (lmm == NULL)
- rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE,
- XATTR_LUSTRE_MDS_OBJID, NULL, 0, 0);
- else {
- lmm->lmm_magic = cpu_to_le32(XATTR_MDS_MO_MAGIC);
- rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE,
- XATTR_LUSTRE_MDS_OBJID, lmm,
- lmm->lmm_easize, XATTR_CREATE);
- if (rc == -EEXIST)
- rc = extN_xattr_set(handle, inode,
- EXTN_XATTR_INDEX_LUSTRE,
- XATTR_LUSTRE_MDS_OBJID, lmm,
- lmm->lmm_easize, 0);
- }
+ rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE,
+ XATTR_LUSTRE_MDS_OBJID, lmm,
+ lmm ? lmm->lmm_easize : 0, 0);
unlock_kernel();
up(&inode->i_sem);
if (rc) {
CERROR("error adding objectid "LPX64" to inode %ld: %d\n",
lmm->lmm_object_id, inode->i_ino, rc);
- LBUG();
+ if (rc != -ENOSPC) LBUG();
}
return rc;
}
return rc;
}
- if (lmm->lmm_magic != cpu_to_le32(XATTR_MDS_MO_MAGIC)) {
- CERROR("MDS striping md for ino %ld has bad magic\n",
- inode->i_ino);
- rc = -EINVAL;
- } else {
- /* This field is byteswapped because it appears in the
- * catalogue. All others are opaque to the MDS */
- lmm->lmm_object_id = le64_to_cpu(lmm->lmm_object_id);
- }
+ /* This field is byteswapped because it appears in the
+ * catalogue. All others are opaque to the MDS */
+ lmm->lmm_object_id = le64_to_cpu(lmm->lmm_object_id);
return rc;
}
return;
}
if (mds_extN_set_md(inode, handle, NULL))
- CERROR("error clearing obdo on %ld\n", inode->i_ino);
+ CERROR("error clearing objid on %ld\n", inode->i_ino);
if (mds_extN_fs_ops.cl_delete_inode)
mds_extN_fs_ops.cl_delete_inode(inode);
mds_extN_fs_ops.cl_delete_inode(inode);
}
-static void mds_extN_callback_status(void *jcb, int error)
+static void mds_extN_callback_status(struct journal_callback *jcb, int error)
{
struct mds_cb_data *mcb = (struct mds_cb_data *)jcb;
if (!error && mcb->cb_last_rcvd > mcb->cb_mds->mds_last_committed)
mcb->cb_mds->mds_last_committed = mcb->cb_last_rcvd;
- kmem_cache_free(jcb_cache, jcb);
- --jcb_cache_count;
+ kmem_cache_free(mcb_cache, mcb);
+ --mcb_cache_count;
}
static int mds_extN_set_last_rcvd(struct mds_obd *mds, void *handle)
{
struct mds_cb_data *mcb;
- mcb = kmem_cache_alloc(jcb_cache, GFP_NOFS);
+ mcb = kmem_cache_alloc(mcb_cache, GFP_NOFS);
if (!mcb)
RETURN(-ENOMEM);
- ++jcb_cache_count;
+ ++mcb_cache_count;
mcb->cb_mds = mds;
mcb->cb_last_rcvd = mds->mds_last_rcvd;
#ifdef HAVE_JOURNAL_CALLBACK_STATUS
- CDEBUG(D_EXT2, "set callback for last_rcvd: %Ld\n",
- (unsigned long long)mcb->cb_last_rcvd);
+ CDEBUG(D_EXT2, "set callback for last_rcvd: "LPD64"\n",
+ mcb->cb_last_rcvd);
+ lock_kernel();
+ /* Note that an "incompatible pointer" warning here is OK for now */
journal_callback_set(handle, mds_extN_callback_status,
- (void *)mcb);
+ (struct journal_callback *)mcb);
+ unlock_kernel();
#else
#warning "no journal callback kernel patch, faking it..."
{
CERROR("no journal callback kernel patch, faking it...\n");
next = jiffies + 300 * HZ;
}
- }
+
mds_extN_callback_status((struct journal_callback *)mcb, 0);
#endif
int rc;
//rc = extN_xattr_register();
- jcb_cache = kmem_cache_create("mds_extN_jcb",
+ mcb_cache = kmem_cache_create("mds_extN_mcb",
sizeof(struct mds_cb_data), 0,
0, NULL, NULL);
- if (!jcb_cache) {
+ if (!mcb_cache) {
CERROR("error allocating MDS journal callback cache\n");
GOTO(out, rc = -ENOMEM);
}
+
rc = mds_register_fs_type(&mds_extN_fs_ops, "extN");
if (rc)
- kmem_cache_destroy(jcb_cache);
+ kmem_cache_destroy(mcb_cache);
out:
return rc;
}
int rc;
mds_unregister_fs_type("extN");
- rc = kmem_cache_destroy(jcb_cache);
+ rc = kmem_cache_destroy(mcb_cache);
- if (rc || jcb_cache_count) {
+ if (rc || mcb_cache_count) {
CERROR("can't free MDS callback cache: count %d, rc = %d\n",
- jcb_cache_count, rc);
+ mcb_cache_count, rc);
}
//rc = extN_xattr_unregister();