From: pschwan Date: Wed, 14 Aug 2002 22:45:18 +0000 (+0000) Subject: - comment out the noisy get/put LDLM_DEBUGs; I'll remove them when I'm sure X-Git-Tag: v1_7_100~5099 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=38f9481dbd1f3d2f2b6d801f117fa874b204343f;p=fs%2Flustre-release.git - comment out the noisy get/put LDLM_DEBUGs; I'll remove them when I'm sure that we're free of refcount bugs - make mds_connect not crash when cluuid is NULL - in ldlm_intent_policy, return a write lock if the client is opening a file with no EA - in mds_extN_get_md, allow MD to be NULL - fix resource ID corruption leading to infinite locks (b=595247) - in lctl, make ptl_initialize failure non-fatal, so that I can run debugctl functions on non-Lustre systems --- diff --git a/lustre/include/linux/lustre_dlm.h b/lustre/include/linux/lustre_dlm.h index 22b6553..e98475c3 100644 --- a/lustre/include/linux/lustre_dlm.h +++ b/lustre/include/linux/lustre_dlm.h @@ -249,14 +249,14 @@ void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh); #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; \ }) diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 0167255..07aab31 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -1,14 +1,24 @@ /* -*- 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 + * Author: Phil Schwan * - * 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 & - * Phil Schwan + * 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 @@ -98,7 +108,7 @@ void ldlm_register_intent(int (*arg) (struct ldlm_lock * lock, void *req_cookie, ldlm_res_policy_table[LDLM_MDSINTENT] = arg; } -void ldlm_unregister_intent() +void ldlm_unregister_intent(void) { ldlm_res_policy_table[LDLM_MDSINTENT] = NULL; } @@ -130,7 +140,7 @@ void ldlm_lock_put(struct ldlm_lock *lock) l_lock(nslock); lock->l_refc--; - LDLM_DEBUG(lock, "after refc--"); + //LDLM_DEBUG(lock, "after refc--"); if (lock->l_refc < 0) LBUG(); @@ -520,7 +530,7 @@ static struct ldlm_lock *search_queue(struct list_head *queue, ldlm_mode_t mode, /* 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, diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 457a420..4828c9e 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -2,11 +2,23 @@ * vim:expandtab:shiftwidth=8:tabstop=8: * * Copyright (C) 2002 Cluster File Systems, Inc. + * Author: Peter Braam + * Author: Phil Schwan * - * 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 @@ -228,8 +240,9 @@ int ldlm_handle_cancel(struct ptlrpc_request *req) 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"); @@ -322,10 +335,13 @@ static int ldlm_handle_cp_callback(struct ptlrpc_request *req) 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, diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 319ef37..7d14d45f 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -82,8 +82,8 @@ static int ll_file_open(struct inode *inode, struct file *file) 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) @@ -263,8 +263,6 @@ static ssize_t ll_file_read(struct file *filp, char *buf, size_t count, ssize_t retval; ENTRY; - - if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK)) { OBD_ALLOC(lockhs, md->lmd_stripe_count * sizeof(*lockhs)); if (!lockhs) diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 351191d..e4448e7 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1,18 +1,28 @@ /* -*- 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 + * Author: Andreas Dilger + * Author: Phil Schwan + * + * 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 & - * Andreas Dilger + * 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 @@ -41,7 +51,7 @@ static int mds_sendpage(struct ptlrpc_request *req, struct file *file, __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; @@ -241,29 +251,29 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd, { 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 @@ -284,7 +294,7 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd, if (rc) GOTO(out_mdc, rc); - return 0; + RETURN(0); out_mdc: OBD_FREE(mcd, sizeof(*mcd)); @@ -293,7 +303,7 @@ out_export: out_dec: MOD_DEC_USE_COUNT; - RETURN(rc); + return rc; } static int mds_disconnect(struct lustre_handle *conn) @@ -356,21 +366,21 @@ static int mds_getlovinfo(struct ptlrpc_request *req) 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); @@ -484,6 +494,7 @@ static int mds_getattr_name(int offset, struct ptlrpc_request *req) 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 */ @@ -567,7 +578,7 @@ static int mds_getattr(int offset, struct ptlrpc_request *req) 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); @@ -949,7 +960,7 @@ int mds_handle(struct ptlrpc_request *req) 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 = @@ -1274,14 +1285,26 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie, 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(); @@ -1295,7 +1318,6 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie, rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); if (rc) { - CERROR("out of memory\n"); LBUG(); RETURN(-ENOMEM); } @@ -1304,7 +1326,7 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie, } -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 */ diff --git a/lustre/mds/mds_extN.c b/lustre/mds/mds_extN.c index f9ee992..7f6b198 100644 --- a/lustre/mds/mds_extN.c +++ b/lustre/mds/mds_extN.c @@ -1,16 +1,26 @@ /* -*- 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 + * Copyright (c) 2002 Cluster File Systems, Inc. + * Author: Andreas Dilger + * + * 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 @@ -107,10 +117,10 @@ static int mds_extN_set_md(struct inode *inode, void *handle, 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); @@ -140,8 +150,12 @@ static int mds_extN_get_md(struct inode *inode, struct lov_stripe_md *md) 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; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index cc0d794..1f41284 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -587,7 +587,7 @@ static int osc_enqueue(struct lustre_handle *connh, struct lov_stripe_md *md, 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; @@ -600,7 +600,7 @@ static int osc_enqueue(struct lustre_handle *connh, struct lov_stripe_md *md, /* 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 */ @@ -616,7 +616,7 @@ static int osc_enqueue(struct lustre_handle *connh, struct lov_stripe_md *md, 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; @@ -637,7 +637,7 @@ static int osc_enqueue(struct lustre_handle *connh, struct lov_stripe_md *md, } 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; diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 717ac5d..bcd723a 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -186,8 +186,7 @@ int main(int argc, char **argv) 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)