From 649ae0c92113ec0ea79a603fe493a4ccb09ac864 Mon Sep 17 00:00:00 2001 From: lincent Date: Mon, 10 Oct 2005 11:25:21 +0000 Subject: [PATCH] new llog_ldlm process and mgc_enqueue --- lustre/include/linux/lustre_idl.h | 6 +-- lustre/mgc/mgc_lock.c | 91 +++++++++++++++++++++++++++++++++++++++ lustre/mgc/mgc_request.c | 16 +++---- 3 files changed, 100 insertions(+), 13 deletions(-) diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index cf94497..d601ebd 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -811,6 +811,7 @@ typedef enum { LDLM_EXTENT = 11, LDLM_FLOCK = 12, // LDLM_IBITS = 13, + LDLM_LLOG = 14, LDLM_MAX_TYPE } ldlm_type_t; @@ -830,9 +831,7 @@ struct ldlm_flock { __u32 pid; }; -struct ldlm_llog { - /*FIXME*/ -}; + /* it's important that the fields of the ldlm_extent structure match * the first fields of the ldlm_flock structure because there is only * one ldlm_swab routine to process the ldlm_policy_data_t union. if @@ -842,7 +841,6 @@ struct ldlm_llog { typedef union { struct ldlm_extent l_extent; struct ldlm_flock l_flock; - struct ldlm_llog l_llog; } ldlm_policy_data_t; extern void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d); diff --git a/lustre/mgc/mgc_lock.c b/lustre/mgc/mgc_lock.c index e69de29..7e3398b 100644 --- a/lustre/mgc/mgc_lock.c +++ b/lustre/mgc/mgc_lock.c @@ -0,0 +1,91 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (C) 2001-2005 Cluster File Systems, Inc. + * Author LinSongTao + * + * 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. + * + * 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. + * + * For testing and management it is treated as an obd_device, + * although * it does not export a full OBD method table (the + * requests are coming * in over the wire, so object target modules + * do not have a full * method table.) + */ +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif +#define DEBUG_SUBSYSTEM S_MGC + +#ifdef __KERNEL__ +# include +# include +# include +# include +#else +# include +#endif + +#include +#include +#include +#include +#include + +#include "mgc_internal.h" + +int mgc_enqueue(struct obd_export *exp, int lock_mode, + struct mgc_op_data *data, struct lustre_handle *lockh, + ldlm_completion_callback cb_completion, + ldlm_blocking_callback cb_blocking, + void *cb_data) +{ + struct ptlrpc_request *req; + struct obd_device *obddev = class_exp2obd(exp); + struct ldlm_res_id res_id = + { .name = {data->obj_id, + data->obj_version} + }; + int rc = 0, flags = 0; + struct ldlm_reply *dlm_rep; + struct ldlm_request *lockreq; + unsigned long irqflags; + int reply_buffers = 0; + ENTRY; + + /* Search for already existing locks.*/ + rc = ldlm_lock_match(obd->obd_namespace, 0, &res_id, LDLM_LLOG, + NULL, mode, lockh); + if (rc == 1) + RETURN(ELDLM_OK); + + rc = ldlm_cli_enqueue(exp, req, obd->obd_namespace, res_id, LDLM_LLOG, + NULL, mode, flags, bl_cb, cp_cb, gl_cb, data, + &lvb, sizeof(lvb), lustre_swab_ost_lvb, lockh); + + if (req != NULL) { + if (rc == ELDLM_LOCK_ABORTED) { + /* swabbed by ldlm_cli_enqueue() */ + LASSERT_REPSWABBED(req, 0); + rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep)); + LASSERT(rep != NULL); + if (rep->lock_policy_res1) + rc = rep->lock_policy_res1; + } + ptlrpc_req_finished(req); + } + + RETURN(rc); +} diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 3cd773b..2a04d12 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -29,7 +29,7 @@ #ifndef EXPORT_SYMTAB # define EXPORT_SYMTAB #endif -#define DEBUG_SUBSYSTEM S_CONFOBD +#define DEBUG_SUBSYSTEM S_MGC #ifdef __KERNEL__ # include @@ -58,7 +58,6 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, struct dentry *dentry; int err = 0; - LASSERT(sbi); obd->obd_fsops = fsfilt_get_ops(MT_STR(sbi->lsi_ldd)); @@ -181,16 +180,15 @@ static int mgc_setup(struct obd_device *obd, obd_count len, void *buf) CERROR("fs setup failed %d\n", rc); mgc_cleanup(obd); RETURN(-ENOENT); - } - } else { - CERROR("mgc does not have local disk (client only)\n"); - rc = mgc_obd_setup(obd, len, buf); - if (rc) { - mgc_cleanup(obd); - RETURN(-ENOENT); } } + CERROR("mgc does not have local disk (client only)\n"); + rc = mgc_obd_setup(obd, len, buf); + if (rc) { + mgc_cleanup(obd); + RETURN(-ENOENT); + } RETURN(rc); err_rpc_lock: -- 1.8.3.1