-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
+/*
+ * GPL HEADER START
*
- * Lustre Light name resolution
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * Copyright (c) 2002-2004 Cluster File Systems, Inc.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
- * This file is part of Lustre, http://www.lustre.org.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
*
- * 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.
+ * Copyright (c) 2011, 2012, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
*
- * 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.
+ * lustre/liblustre/namei.c
*
- * 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.
+ * Lustre Light name resolution
*/
#define DEBUG_SUBSYSTEM S_LLITE
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
-#include <time.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/queue.h>
-
-#include <sysio.h>
-#ifdef HAVE_XTIO_H
-#include <xtio.h>
-#endif
-#include <fs.h>
-#include <mount.h>
-#include <inode.h>
-#ifdef HAVE_FILE_H
-#include <file.h>
-#endif
-
-#undef LIST_HEAD
-
+#include <sys/types.h>
+#include <libcfs/libcfs.h>
+#include <lustre/lustre_idl.h>
+#include <liblustre.h>
+#include <lclient.h>
+#include <lustre_dlm.h>
+#include <lustre_fid.h>
+#include <lustre_mdc.h>
+#include <lustre_net.h>
+#include <obd.h>
+#include <obd_class.h>
+#include <obd_support.h>
#include "llite_lib.h"
-void ll_intent_drop_lock(struct lookup_intent *it)
+static void ll_intent_drop_lock(struct lookup_intent *it)
{
struct lustre_handle *handle;
}
}
-void ll_intent_release(struct lookup_intent *it)
+static void ll_intent_release(struct lookup_intent *it)
{
ENTRY;
EXIT;
}
-void llu_lookup_finish_locks(struct lookup_intent *it, struct pnode *pnode)
+static void
+llu_lookup_finish_locks(struct lookup_intent *it, struct pnode *pnode)
{
struct inode *inode;
LASSERT(it);
sbi = llu_i2sbi(inode);
md_set_lock_data(sbi->ll_md_exp,
- &it->d.lustre.it_lock_handle, inode);
+ &it->d.lustre.it_lock_handle, inode, NULL);
}
/* drop lookup/getattr locks */
switch (flag) {
case LDLM_CB_BLOCKING:
ldlm_lock2handle(lock, &lockh);
- rc = ldlm_cli_cancel(&lockh);
+ rc = ldlm_cli_cancel(&lockh, 0);
if (rc < 0) {
CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc);
RETURN(rc);
}
break;
case LDLM_CB_CANCELING: {
- struct inode *inode = llu_inode_from_lock(lock);
+ struct inode *inode = llu_inode_from_resource_lock(lock);
struct llu_inode_info *lli;
struct intnl_stat *st;
__u64 bits = lock->l_policy_data.l_inodebits.bits;
struct lu_fid *fid;
+ /* Inode is set to lock->l_resource->lr_lvb_inode
+ * for mdc - bug 24555 */
+ LASSERT(lock->l_ast_data == NULL);
+
/* Invalidate all dentries associated with this inode */
if (inode == NULL)
break;
if (bits & MDS_INODELOCK_UPDATE)
lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
- fid = &lli->lli_fid;
- if (lock->l_resource->lr_name.name[0] != fid_seq(fid) ||
- lock->l_resource->lr_name.name[1] != fid_oid(fid) ||
- lock->l_resource->lr_name.name[2] != fid_ver(fid)) {
- LDLM_ERROR(lock,"data mismatch with ino %llu/%llu/%llu",
- (long long)fid_seq(fid),
- (long long)fid_oid(fid),
- (long long)fid_ver(fid));
- }
+ fid = &lli->lli_fid;
+ if (!fid_res_name_eq(fid, &lock->l_resource->lr_name))
+ LDLM_ERROR(lock, "data mismatch with object "
+ DFID" (%p)", PFID(fid), inode);
if (S_ISDIR(st->st_mode) &&
(bits & MDS_INODELOCK_UPDATE)) {
CDEBUG(D_INODE, "invalidating inode %llu\n",
}
static int pnode_revalidate_finish(struct ptlrpc_request *req,
- int offset,
struct lookup_intent *it,
struct pnode *pnode)
{
RETURN(-ENOENT);
rc = md_get_lustre_md(llu_i2sbi(inode)->ll_md_exp, req,
- offset, llu_i2sbi(inode)->ll_dt_exp,
+ llu_i2sbi(inode)->ll_dt_exp,
llu_i2sbi(inode)->ll_md_exp, &md);
if (rc)
RETURN(rc);
- llu_update_inode(inode, md.body, md.lsm);
+ llu_update_inode(inode, &md);
RETURN(rc);
}
struct lookup_intent *it)
{
struct pnode_base *pb = pnode->p_base;
- struct it_cb_data icbd;
struct md_op_data op_data = {{ 0 }};
struct ptlrpc_request *req = NULL;
struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
}
exp = llu_i2mdexp(pb->pb_ino);
- icbd.icbd_parent = pnode->p_parent->p_base->pb_ino;
- icbd.icbd_child = pnode;
if (!it) {
it = &lookup_it;
pb->pb_ino, pb->pb_name.name, pb->pb_name.len,
0, LUSTRE_OPC_ANY);
- rc = md_intent_lock(exp, &op_data, NULL, 0, it, flags,
- &req, llu_md_blocking_ast,
- LDLM_FL_CANCEL_ON_BLOCK);
+ rc = md_intent_lock(exp, &op_data, it, &req, &llu_md_blocking_ast,
+ LDLM_FL_CANCEL_ON_BLOCK);
/* If req is NULL, then md_intent_lock only tried to do a lock match;
* if all was well, it will return 1 if it found locks, 0 otherwise. */
if (req == NULL && rc >= 0)
if (rc < 0)
GOTO(out, rc = 0);
- rc = pnode_revalidate_finish(req, DLM_REPLY_REC_OFF, it, pnode);
+ rc = pnode_revalidate_finish(req, it, pnode);
if (rc != 0) {
ll_intent_release(it);
GOTO(out, rc = 0);
}
static int lookup_it_finish(struct ptlrpc_request *request, int offset,
- struct lookup_intent *it, void *data)
+ struct lookup_intent *it,
+ struct inode *parent, struct pnode *child)
{
- struct it_cb_data *icbd = data;
- struct pnode *child = icbd->icbd_child;
- struct inode *parent = icbd->icbd_parent;
struct llu_sb_info *sbi = llu_i2sbi(parent);
struct inode *inode = NULL;
int rc;
/* undo which did by md_intent_lock */
if (it_disposition(it, DISP_OPEN_CREATE) &&
!it_open_error(DISP_OPEN_CREATE, it)) {
- LASSERT(request);
- LASSERT(atomic_read(&request->rq_refcount) > 1);
- CDEBUG(D_INODE, "dec a ref of req %p\n", request);
- ptlrpc_req_finished(request);
+ LASSERT(request);
+ LASSERT(atomic_read(&request->rq_refcount) > 1);
+ CDEBUG(D_INODE, "dec a ref of req %p\n", request);
+ ptlrpc_req_finished(request);
}
return it_open_error(DISP_OPEN_OPEN, it);
}
if (it_disposition(it, DISP_OPEN_CREATE))
ptlrpc_req_finished(request);
- rc = md_get_lustre_md(sbi->ll_md_exp, request, offset,
+ rc = md_get_lustre_md(sbi->ll_md_exp, request,
sbi->ll_dt_exp, sbi->ll_md_exp, &md);
if (rc)
RETURN(rc);
if (md.lsm != NULL)
obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
RETURN(inode ? PTR_ERR(inode) : -ENOMEM);
- } else if (md.lsm != NULL &&
- llu_i2info(inode)->lli_smd != md.lsm) {
+ } else if (md.lsm != NULL) {
obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
}
/* If this is a stat, get the authoritative file size */
if (it->it_op == IT_GETATTR && S_ISREG(st->st_mode) &&
- lli->lli_smd != NULL) {
- struct lov_stripe_md *lsm = lli->lli_smd;
+ lli->lli_has_smd) {
ldlm_error_t rc;
- LASSERT(lsm->lsm_object_id != 0);
-
/* bug 2334: drop MDS lock before acquiring OST lock */
ll_intent_drop_lock(it);
- rc = llu_glimpse_size(inode);
+ rc = cl_glimpse_size(inode);
if (rc) {
I_RELE(inode);
RETURN(rc);
RETURN(0);
}
-struct inode *llu_inode_from_lock(struct ldlm_lock *lock)
+struct inode *llu_inode_from_resource_lock(struct ldlm_lock *lock)
{
- struct inode *inode;
- lock_res_and_lock(lock);
+ struct inode *inode;
+ lock_res_and_lock(lock);
- if (lock->l_ast_data) {
- inode = (struct inode *)lock->l_ast_data;
- I_REF(inode);
- } else
- inode = NULL;
+ if (lock->l_resource->lr_lvb_inode) {
+ inode = (struct inode *)lock->l_resource->lr_lvb_inode;
+ I_REF(inode);
+ } else
+ inode = NULL;
- unlock_res_and_lock(lock);
- return inode;
+ unlock_res_and_lock(lock);
+ return inode;
}
static int llu_lookup_it(struct inode *parent, struct pnode *pnode,
struct lookup_intent *it, int flags)
{
struct md_op_data op_data = {{ 0 }};
- struct it_cb_data icbd;
struct ptlrpc_request *req = NULL;
struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
__u32 opc;
it->it_op_release = ll_intent_release;
}
- icbd.icbd_child = pnode;
- icbd.icbd_parent = parent;
+ if (it->it_op & IT_CREAT)
+ opc = LUSTRE_OPC_CREATE;
+ else
+ opc = LUSTRE_OPC_ANY;
- if (it->it_op & IT_CREAT ||
- (it->it_op & IT_OPEN && it->it_create_mode & O_CREAT)) {
- opc = LUSTRE_OPC_CREATE;
- } else {
- opc = LUSTRE_OPC_ANY;
- }
-
llu_prep_md_op_data(&op_data, parent, NULL,
pnode->p_base->pb_name.name,
pnode->p_base->pb_name.len, flags, opc);
- rc = md_intent_lock(llu_i2mdexp(parent), &op_data, NULL, 0, it,
- flags, &req, llu_md_blocking_ast,
- LDLM_FL_CANCEL_ON_BLOCK);
+ rc = md_intent_lock(llu_i2mdexp(parent), &op_data, it, &req,
+ &llu_md_blocking_ast, LDLM_FL_CANCEL_ON_BLOCK);
if (rc < 0)
GOTO(out, rc);
- rc = lookup_it_finish(req, DLM_REPLY_REC_OFF, it, &icbd);
+ rc = lookup_it_finish(req, DLM_REPLY_REC_OFF, it, parent, pnode);
if (rc != 0) {
ll_intent_release(it);
GOTO(out, rc);
}
out:
+ if (it)
+ OBD_FREE(it, sizeof(*it));
liblustre_wait_event(0);
RETURN(rc);
}