#define LDLM_LOCK_PUT(lock) \
do { \
- LDLM_DEBUG(lock, "put"); \
+ /*LDLM_DEBUG(lock, "put");*/ \
ldlm_lock_put(lock); \
} while (0)
#define LDLM_LOCK_GET(lock) \
({ \
ldlm_lock_get(lock); \
- LDLM_DEBUG(lock, "get"); \
+ /*LDLM_DEBUG(lock, "get");*/ \
lock; \
})
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2002 Cluster File Systems, Inc.
+ * Copyright (c) 2002 Cluster File Systems, Inc.
+ * Author: Peter Braam <braam@clusterfs.com>
+ * Author: Phil Schwan <phil@clusterfs.com>
*
- * This code is issued under the GNU General Public License.
- * See the file COPYING in this distribution
+ * This file is part of Lustre, http://www.lustre.org.
*
- * by Cluster File Systems, Inc.
- * authors, Peter Braam <braam@clusterfs.com> &
- * Phil Schwan <phil@clusterfs.com>
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
*/
#define DEBUG_SUBSYSTEM S_LDLM
ldlm_res_policy_table[LDLM_MDSINTENT] = arg;
}
-void ldlm_unregister_intent()
+void ldlm_unregister_intent(void)
{
ldlm_res_policy_table[LDLM_MDSINTENT] = NULL;
}
l_lock(nslock);
lock->l_refc--;
- LDLM_DEBUG(lock, "after refc--");
+ //LDLM_DEBUG(lock, "after refc--");
if (lock->l_refc < 0)
LBUG();
/* Must be called with no resource or lock locks held.
*
* Returns 1 if it finds an already-existing lock that is compatible; in this
- * case, lockh is filled in with a addref()ed lock
+ * case, lockh is filled in with a addref()ed lock
*/
int ldlm_lock_match(struct ldlm_namespace *ns, __u64 * res_id, __u32 type,
void *cookie, int cookielen, ldlm_mode_t mode,
* vim:expandtab:shiftwidth=8:tabstop=8:
*
* Copyright (C) 2002 Cluster File Systems, Inc.
+ * Author: Peter Braam <braam@clusterfs.com>
+ * Author: Phil Schwan <phil@clusterfs.com>
*
- * This code is issued under the GNU General Public License.
- * See the file COPYING in this distribution
+ * This file is part of Lustre, http://www.lustre.org.
*
- * by 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.
+ *
+ * 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.
+ *
+ * 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.
*/
#define EXPORT_SYMTAB
lock = ldlm_handle2lock(&dlm_req->lock_handle1);
if (!lock) {
- LDLM_DEBUG_NOLOCK("server-side cancel handler stale lock (lock %p)",
- (void *)(unsigned long) dlm_req->lock_handle1.addr);
+ LDLM_DEBUG_NOLOCK("server-side cancel handler stale lock (lock "
+ "%p)", (void *)(unsigned long)
+ dlm_req->lock_handle1.addr);
req->rq_status = ESTALE;
} else {
LDLM_DEBUG(lock, "server-side cancel handler START");
LDLM_DEBUG(lock, "client completion callback handler START");
l_lock(&lock->l_resource->lr_namespace->ns_lock);
- lock->l_req_mode = dlm_req->lock_desc.l_granted_mode;
/* If we receive the completion AST before the actual enqueue returned,
- * then we might need to switch resources. */
+ * then we might need to switch resources or lock modes. */
+ if (dlm_req->lock_desc.l_granted_mode != lock->l_req_mode) {
+ lock->l_req_mode = dlm_req->lock_desc.l_granted_mode;
+ LDLM_DEBUG(lock, "completion AST, new lock mode");
+ }
ldlm_resource_unlink_lock(lock);
if (memcmp(dlm_req->lock_desc.l_resource.lr_name,
lock->l_resource->lr_name,
memset(fd, 0, sizeof(*fd));
rc = mdc_open(&sbi->ll_mdc_conn, inode->i_ino, S_IFREG | inode->i_mode,
- file->f_flags, md,
- (__u64)(unsigned long)file, &fd->fd_mdshandle, &req);
+ file->f_flags, md, (__u64)(unsigned long)file,
+ &fd->fd_mdshandle, &req);
fd->fd_req = req;
ptlrpc_req_finished(req);
if (rc)
ssize_t retval;
ENTRY;
-
-
if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK)) {
OBD_ALLOC(lockhs, md->lmd_stripe_count * sizeof(*lockhs));
if (!lockhs)
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * linux/mds/handler.c
- *
+ * lustre/mds/handler.c
* Lustre Metadata Server (mds) request handler
*
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+ * Copyright (c) 2001, 2002 Cluster File Systems, Inc.
+ * Author: Peter Braam <braam@clusterfs.com>
+ * Author: Andreas Dilger <adilger@clusterfs.com>
+ * Author: Phil Schwan <phil@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
*
- * This code is issued under the GNU General Public License.
- * See the file COPYING in this distribution
+ * 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.
*
- * by Peter Braam <braam@clusterfs.com> &
- * Andreas Dilger <braam@clusterfs.com>
+ * 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.
*
+ * 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.
*/
#define EXPORT_SYMTAB
__u64 offset)
{
int rc = 0;
- struct mds_obd *mds = mds_req2mds(req);
+ struct mds_obd *mds = mds_req2mds(req);
struct ptlrpc_bulk_desc *desc;
struct ptlrpc_bulk_page *bulk;
char *buf;
{
struct obd_export *exp;
struct mds_client_data *mcd;
+ struct list_head *p;
int rc;
+ ENTRY;
+
+ if (!cluuid)
+ RETURN(-EINVAL);
MOD_INC_USE_COUNT;
- if (cluuid) {
- struct list_head *p;
- list_for_each(p, &obd->obd_exports) {
- exp = list_entry(p, struct obd_export, exp_chain);
- mcd = exp->exp_mds_data.med_mcd;
- if (mcd && !memcmp(cluuid, mcd->mcd_uuid,
- sizeof(mcd->mcd_uuid))) {
- CDEBUG(D_INFO,
- "existing export for UUID '%s' at %p\n",
- cluuid, exp);
- LASSERT(exp->exp_obd == obd);
- exp->exp_rconnh.addr = conn->addr;
- exp->exp_rconnh.cookie = conn->cookie;
- conn->addr = (__u64) (unsigned long)exp;
- conn->cookie = exp->exp_cookie;
- CDEBUG(D_IOCTL,"connect: addr %Lx cookie %Lx\n",
- (long long)conn->addr,
- (long long)conn->cookie);
- RETURN(0);
- }
+ list_for_each(p, &obd->obd_exports) {
+ exp = list_entry(p, struct obd_export, exp_chain);
+ mcd = exp->exp_mds_data.med_mcd;
+ if (mcd && !memcmp(cluuid, mcd->mcd_uuid,
+ sizeof(mcd->mcd_uuid))) {
+ CDEBUG(D_INFO, "existing export for UUID '%s' at %p\n",
+ cluuid, exp);
+ LASSERT(exp->exp_obd == obd);
+ exp->exp_rconnh.addr = conn->addr;
+ exp->exp_rconnh.cookie = conn->cookie;
+ conn->addr = (__u64) (unsigned long)exp;
+ conn->cookie = exp->exp_cookie;
+ CDEBUG(D_IOCTL,"connect: addr %Lx cookie %Lx\n",
+ (long long)conn->addr, (long long)conn->cookie);
+ RETURN(0);
}
}
#warning shaver: we might need a real cluuid here
if (rc)
GOTO(out_mdc, rc);
- return 0;
+ RETURN(0);
out_mdc:
OBD_FREE(mcd, sizeof(*mcd));
out_dec:
MOD_DEC_USE_COUNT;
- RETURN(rc);
+ return rc;
}
static int mds_disconnect(struct lustre_handle *conn)
int rc, size[2] = {sizeof(*desc)};
ENTRY;
- streq = lustre_msg_buf(req->rq_reqmsg, 0);
- streq->flags = NTOH__u32(streq->flags);
- streq->repbuf = NTOH__u32(streq->repbuf);
+ streq = lustre_msg_buf(req->rq_reqmsg, 0);
+ streq->flags = NTOH__u32(streq->flags);
+ streq->repbuf = NTOH__u32(streq->repbuf);
size[1] = streq->repbuf;
rc = lustre_pack_msg(2, size, NULL, &req->rq_replen, &req->rq_repmsg);
- if (rc) {
+ if (rc) {
CERROR("mds: out of memory for message: size=%d\n", size[1]);
req->rq_status = -ENOMEM;
RETURN(0);
}
- desc = lustre_msg_buf(req->rq_repmsg, 0);
+ desc = lustre_msg_buf(req->rq_repmsg, 0);
rc = mds_get_lovdesc(req->rq_obd, desc);
- if (rc != 0 ) {
+ if (rc != 0 ) {
CERROR("mds_get_lovdesc error %d", rc);
req->rq_status = rc;
RETURN(0);
struct lov_stripe_md *md;
md = lustre_msg_buf(req->rq_repmsg, offset + 1);
md->lmd_easize = mds->mds_max_mdsize;
+ /* FIXME: why don't we check (or use) rc of get_md? */
mds_fs_get_md(mds, inode, md);
}
/* now a normal case for intent locking */
if (S_ISREG(inode->i_mode)) {
rc = mds_fs_get_md(mds, inode,
- lustre_msg_buf(req->rq_repmsg, 1));
+ lustre_msg_buf(req->rq_repmsg, 1));
if (rc < 0) {
CERROR("mds_fs_get_md failed: %d\n", rc);
GOTO(out, rc);
EXIT;
- if (!rc) {
+ if (!rc) {
struct mds_obd *mds = mds_req2mds(req);
req->rq_repmsg->last_xid = HTON__u64(mds->mds_last_rcvd);
req->rq_repmsg->last_committed =
rep->lock_policy_res2 = req->rq_status;
mds_rep = lustre_msg_buf(req->rq_repmsg, 1);
+
+ /* If the client is about to open a file that doesn't have an MD
+ * stripe record, it's going to need a write lock. */
+ if (it->opc & IT_OPEN) {
+ struct lov_stripe_md *md =
+ lustre_msg_buf(req->rq_repmsg, 2);
+ if (md->lmd_easize == 0) {
+ LDLM_DEBUG(lock, "open with no EA; returning PW"
+ " lock");
+ lock->l_req_mode = LCK_PW;
+ }
+ }
+
+ /* Give the client a lock on the child object, instead of the
+ * parent that it requested. */
new_resid[0] = NTOH__u32(mds_rep->ino);
if (new_resid[0] == 0)
LBUG();
old_res = lock->l_resource->lr_name[0];
- CDEBUG(D_INFO, "remote intent: locking %d instead of"
- "%ld\n", mds_rep->ino, (long)old_res);
-
ldlm_lock_change_resource(lock, new_resid);
if (lock->l_resource == NULL) {
LBUG();
rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen,
&req->rq_repmsg);
if (rc) {
- CERROR("out of memory\n");
LBUG();
RETURN(-ENOMEM);
}
}
-extern int mds_iocontrol(long cmd, struct lustre_handle *conn,
+extern int mds_iocontrol(long cmd, struct lustre_handle *conn,
int len, void *karg, void *uarg);
/* use obd ops to offer management infrastructure */
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * linux/mds/mds_extN.c
- *
+ * lustre/mds/mds_extN.c
* Lustre Metadata Server (mds) journal abstraction routines
*
- * Copyright (C) 2002 Cluster File Systems, Inc.
- * author: Andreas Dilger <adilger@clusterfs.com>
+ * Copyright (c) 2002 Cluster File Systems, Inc.
+ * Author: Andreas Dilger <adilger@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * 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.
*
- * This code is issued under the GNU General Public License.
- * See the file COPYING in this distribution
+ * 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.
*
+ * 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.
*/
#define DEBUG_SUBSYSTEM S_MDS
if (md == NULL)
rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE,
XATTR_LUSTRE_MDS_OBJID, NULL, 0, 0);
- else {
+ else {
md->lmd_magic = cpu_to_le32(XATTR_MDS_MO_MAGIC);
rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE,
- XATTR_LUSTRE_MDS_OBJID, md,
+ XATTR_LUSTRE_MDS_OBJID, md,
md->lmd_easize, XATTR_CREATE);
}
up(&inode->i_sem);
if (rc < 0) {
CDEBUG(D_INFO, "error getting EA %s from MDS inode %ld: "
"rc = %d\n", XATTR_LUSTRE_MDS_OBJID, inode->i_ino, rc);
- memset(md, 0, size);
- } else if (md->lmd_magic != cpu_to_le32(XATTR_MDS_MO_MAGIC)) {
+ memset(md, 0, size);
+ return rc;
+ } else if (md == NULL)
+ return rc;
+
+ if (md->lmd_magic != cpu_to_le32(XATTR_MDS_MO_MAGIC)) {
CERROR("MDS striping md for ino %ld has bad magic\n",
inode->i_ino);
rc = -EINVAL;
int *flags, void *callback, void *data, int datalen,
struct lustre_handle *lockh)
{
- __u64 res_id = { md->lmd_object_id };
+ __u64 res_id[RES_NAME_SIZE] = { md->lmd_object_id };
struct obd_device *obddev = class_conn2obd(connh);
struct ldlm_extent *extent = extentp;
int rc;
/* Next, search for already existing extent locks that will cover us */
//osc_con2dlmcl(conn, &cl, &connection, &rconn);
- rc = ldlm_lock_match(obddev->obd_namespace, &res_id, type, extent,
+ rc = ldlm_lock_match(obddev->obd_namespace, res_id, type, extent,
sizeof(extent), mode, lockh);
if (rc == 1) {
/* We already have a lock, and it's referenced */
else
mode2 = LCK_PW;
- rc = ldlm_lock_match(obddev->obd_namespace, &res_id, type, extent,
+ rc = ldlm_lock_match(obddev->obd_namespace, res_id, type, extent,
sizeof(extent), mode2, lockh);
if (rc == 1) {
int flags;
}
rc = ldlm_cli_enqueue(connh, NULL,obddev->obd_namespace,
- parent_lock, &res_id, type, extent,
+ parent_lock, res_id, type, extent,
sizeof(extent), mode, flags, ldlm_completion_ast,
callback, data, datalen, lockh);
return rc;
setlinebuf(stdout);
- if (ptl_initialize(argc, argv) < 0)
- exit(1);
+ ptl_initialize(argc, argv);
if (obd_initialize(argc, argv) < 0)
exit(2);
if (dbg_initialize(argc, argv) < 0)