/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * lustre/mdt/mdt_handler.c
- * Lustre Metadata Target (mdt) request handler
+ * GPL HEADER START
*
- * Copyright (c) 2006 Cluster File Systems, Inc.
- * Author: Peter Braam <braam@clusterfs.com>
- * Author: Andreas Dilger <adilger@clusterfs.com>
- * Author: Phil Schwan <phil@clusterfs.com>
- * Author: Mike Shaver <shaver@clusterfs.com>
- * Author: Nikita Danilov <nikita@clusterfs.com>
- * Author: Huang Hua <huanghua@clusterfs.com>
- * Author: Yury Umanets <umka@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * This file is part of the Lustre file system, http://www.lustre.org
- * Lustre is a trademark of Cluster File Systems, Inc.
+ * 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.
*
- * You may have signed or agreed to another license before downloading
- * this software. If so, you are bound by the terms and conditions
- * of that agreement, and the following does not apply to you. See the
- * LICENSE file included with this distribution for more information.
+ * 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).
*
- * If you did not agree to a different license, then this copy of Lustre
- * is open source 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.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see [sun.com URL with a
+ * copy of GPLv2].
*
- * In either case, 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
- * license text for more details.
+ * 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 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/mdt/mdt_handler.c
+ *
+ * Lustre Metadata Target (mdt) request handler
+ *
+ * Author: Peter Braam <braam@clusterfs.com>
+ * Author: Andreas Dilger <adilger@clusterfs.com>
+ * Author: Phil Schwan <phil@clusterfs.com>
+ * Author: Mike Shaver <shaver@clusterfs.com>
+ * Author: Nikita Danilov <nikita@clusterfs.com>
+ * Author: Huang Hua <huanghua@clusterfs.com>
+ * Author: Yury Umanets <umka@clusterfs.com>
*/
#ifndef EXPORT_SYMTAB
static int mdt_statfs(struct mdt_thread_info *info)
{
- struct md_device *next = info->mti_mdt->mdt_child;
- struct obd_statfs *osfs;
- int rc;
+ struct md_device *next = info->mti_mdt->mdt_child;
+ struct ptlrpc_service *svc;
+ struct obd_statfs *osfs;
+ int rc;
ENTRY;
+ svc = info->mti_pill->rc_req->rq_rqbd->rqbd_service;
+
/* This will trigger a watchdog timeout */
OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_STATFS_LCW_SLEEP,
- (MDT_SERVICE_WATCHDOG_TIMEOUT / 1000) + 1);
+ (MDT_SERVICE_WATCHDOG_FACTOR *
+ at_get(&svc->srv_at_estimate) / 1000) + 1);
rc = mdt_check_ucred(info);
if (rc)
LDLM_LOCK_PUT(lock);
rc = 0;
} else {
- struct md_attr *ma = &info->mti_attr;
+ struct md_attr *ma;
relock:
+ ma = &info->mti_attr;
+
mdt_lock_handle_init(lhc);
mdt_lock_reg_init(lhc, LCK_PR);
lock = ldlm_handle2lock(&lhc->mlh_reg_lh);
if (lock) {
struct mdt_body *repbody;
- struct lu_attr *ma;
/* Debugging code. */
res_id = &lock->l_resource->lr_name;
*/
repbody = req_capsule_server_get(info->mti_pill,
&RMF_MDT_BODY);
- ma = &info->mti_attr.ma_attr;
if (lock->l_policy_data.l_inodebits.bits &
MDS_INODELOCK_UPDATE)
mdt_pack_size2body(info, child);
RETURN(-EFAULT);
}
- if (keylen != (sizeof(KEY_READ_ONLY) - 1) ||
- memcmp(key, KEY_READ_ONLY, keylen) != 0)
+ if (!KEY_IS(KEY_READ_ONLY))
RETURN(-EINVAL);
req->rq_status = 0;
struct l_wait_info *lwi = &info->mti_u.rdpg.mti_wait_info;
int tmpcount;
int tmpsize;
+ int timeout;
int i;
int rc;
ENTRY;
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE))
GOTO(abort_bulk, rc = 0);
- *lwi = LWI_TIMEOUT(obd_timeout * HZ / 4, NULL, NULL);
+ timeout = (int) req->rq_deadline - cfs_time_current_sec();
+ if (timeout < 0)
+ CERROR("Req deadline already passed %lu (now: %lu)\n",
+ req->rq_deadline, cfs_time_current_sec());
+ *lwi = LWI_TIMEOUT(max(timeout, 1) * HZ, NULL, NULL);
rc = l_wait_event(desc->bd_waitq, !ptlrpc_bulk_active(desc), lwi);
LASSERT (rc == 0 || rc == -ETIMEDOUT);
sptlrpc_svc_ctx_invalidate(req);
}
+ OBD_FAIL_TIMEOUT(OBD_FAIL_SEC_CTX_HDL_PAUSE, obd_fail_val);
+
return rc;
}
procfs_entry = m->mdt_md_dev.md_lu_dev.ld_obd->obd_proc_entry;
conf = (typeof(conf)) {
- .psc_nbufs = MDS_NBUFS,
- .psc_bufsize = MDS_BUFSIZE,
- .psc_max_req_size = MDS_MAXREQSIZE,
- .psc_max_reply_size = MDS_MAXREPSIZE,
- .psc_req_portal = MDS_REQUEST_PORTAL,
- .psc_rep_portal = MDC_REPLY_PORTAL,
- .psc_watchdog_timeout = MDT_SERVICE_WATCHDOG_TIMEOUT,
+ .psc_nbufs = MDS_NBUFS,
+ .psc_bufsize = MDS_BUFSIZE,
+ .psc_max_req_size = MDS_MAXREQSIZE,
+ .psc_max_reply_size = MDS_MAXREPSIZE,
+ .psc_req_portal = MDS_REQUEST_PORTAL,
+ .psc_rep_portal = MDC_REPLY_PORTAL,
+ .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
/*
* We'd like to have a mechanism to set this on a per-device
* basis, but alas...
*/
- .psc_min_threads = min(max(mdt_num_threads, MDT_MIN_THREADS),
- MDT_MAX_THREADS),
- .psc_max_threads = MDT_MAX_THREADS,
- .psc_ctx_tags = LCT_MD_THREAD
+ .psc_min_threads = min(max(mdt_num_threads, MDT_MIN_THREADS),
+ MDT_MAX_THREADS),
+ .psc_max_threads = MDT_MAX_THREADS,
+ .psc_ctx_tags = LCT_MD_THREAD
};
m->mdt_ldlm_client = &m->mdt_md_dev.md_lu_dev.ld_obd->obd_ldlm_client;
m->mdt_regular_service =
ptlrpc_init_svc_conf(&conf, mdt_regular_handle, LUSTRE_MDT_NAME,
- procfs_entry, NULL, LUSTRE_MDT_NAME);
+ procfs_entry, target_print_req,
+ LUSTRE_MDT_NAME);
if (m->mdt_regular_service == NULL)
RETURN(-ENOMEM);
* ideally.
*/
conf = (typeof(conf)) {
- .psc_nbufs = MDS_NBUFS,
- .psc_bufsize = MDS_BUFSIZE,
- .psc_max_req_size = MDS_MAXREQSIZE,
- .psc_max_reply_size = MDS_MAXREPSIZE,
- .psc_req_portal = MDS_READPAGE_PORTAL,
- .psc_rep_portal = MDC_REPLY_PORTAL,
- .psc_watchdog_timeout = MDT_SERVICE_WATCHDOG_TIMEOUT,
- .psc_min_threads = min(max(mdt_num_threads, MDT_MIN_THREADS),
- MDT_MAX_THREADS),
- .psc_max_threads = MDT_MAX_THREADS,
- .psc_ctx_tags = LCT_MD_THREAD
+ .psc_nbufs = MDS_NBUFS,
+ .psc_bufsize = MDS_BUFSIZE,
+ .psc_max_req_size = MDS_MAXREQSIZE,
+ .psc_max_reply_size = MDS_MAXREPSIZE,
+ .psc_req_portal = MDS_READPAGE_PORTAL,
+ .psc_rep_portal = MDC_REPLY_PORTAL,
+ .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
+ .psc_min_threads = min(max(mdt_num_threads, MDT_MIN_THREADS),
+ MDT_MAX_THREADS),
+ .psc_max_threads = MDT_MAX_THREADS,
+ .psc_ctx_tags = LCT_MD_THREAD
};
m->mdt_readpage_service =
ptlrpc_init_svc_conf(&conf, mdt_readpage_handle,
LUSTRE_MDT_NAME "_readpage",
- procfs_entry, NULL, "mdt_rdpg");
+ procfs_entry, target_print_req,"mdt_rdpg");
if (m->mdt_readpage_service == NULL) {
CERROR("failed to start readpage service\n");
* setattr service configuration.
*/
conf = (typeof(conf)) {
- .psc_nbufs = MDS_NBUFS,
- .psc_bufsize = MDS_BUFSIZE,
- .psc_max_req_size = MDS_MAXREQSIZE,
- .psc_max_reply_size = MDS_MAXREPSIZE,
- .psc_req_portal = MDS_SETATTR_PORTAL,
- .psc_rep_portal = MDC_REPLY_PORTAL,
- .psc_watchdog_timeout = MDT_SERVICE_WATCHDOG_TIMEOUT,
+ .psc_nbufs = MDS_NBUFS,
+ .psc_bufsize = MDS_BUFSIZE,
+ .psc_max_req_size = MDS_MAXREQSIZE,
+ .psc_max_reply_size = MDS_MAXREPSIZE,
+ .psc_req_portal = MDS_SETATTR_PORTAL,
+ .psc_rep_portal = MDC_REPLY_PORTAL,
+ .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
.psc_min_threads = min(max(mdt_num_threads, MDT_MIN_THREADS),
- MDT_MAX_THREADS),
- .psc_max_threads = MDT_MAX_THREADS,
- .psc_ctx_tags = LCT_MD_THREAD
+ MDT_MAX_THREADS),
+ .psc_max_threads = MDT_MAX_THREADS,
+ .psc_ctx_tags = LCT_MD_THREAD
};
m->mdt_setattr_service =
ptlrpc_init_svc_conf(&conf, mdt_regular_handle,
LUSTRE_MDT_NAME "_setattr",
- procfs_entry, NULL, "mdt_attr");
+ procfs_entry, target_print_req,"mdt_attr");
if (!m->mdt_setattr_service) {
CERROR("failed to start setattr service\n");
* sequence controller service configuration
*/
conf = (typeof(conf)) {
- .psc_nbufs = MDS_NBUFS,
- .psc_bufsize = MDS_BUFSIZE,
- .psc_max_req_size = SEQ_MAXREQSIZE,
- .psc_max_reply_size = SEQ_MAXREPSIZE,
- .psc_req_portal = SEQ_CONTROLLER_PORTAL,
- .psc_rep_portal = MDC_REPLY_PORTAL,
- .psc_watchdog_timeout = MDT_SERVICE_WATCHDOG_TIMEOUT,
- .psc_min_threads = SEQ_NUM_THREADS,
- .psc_max_threads = SEQ_NUM_THREADS,
- .psc_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD
+ .psc_nbufs = MDS_NBUFS,
+ .psc_bufsize = MDS_BUFSIZE,
+ .psc_max_req_size = SEQ_MAXREQSIZE,
+ .psc_max_reply_size = SEQ_MAXREPSIZE,
+ .psc_req_portal = SEQ_CONTROLLER_PORTAL,
+ .psc_rep_portal = MDC_REPLY_PORTAL,
+ .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
+ .psc_min_threads = SEQ_NUM_THREADS,
+ .psc_max_threads = SEQ_NUM_THREADS,
+ .psc_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD
};
m->mdt_mdsc_service =
ptlrpc_init_svc_conf(&conf, mdt_mdsc_handle,
LUSTRE_MDT_NAME"_mdsc",
- procfs_entry, NULL, "mdt_mdsc");
+ procfs_entry, target_print_req,"mdt_mdsc");
if (!m->mdt_mdsc_service) {
CERROR("failed to start seq controller service\n");
GOTO(err_mdt_svc, rc = -ENOMEM);
* metadata sequence server service configuration
*/
conf = (typeof(conf)) {
- .psc_nbufs = MDS_NBUFS,
- .psc_bufsize = MDS_BUFSIZE,
- .psc_max_req_size = SEQ_MAXREQSIZE,
- .psc_max_reply_size = SEQ_MAXREPSIZE,
- .psc_req_portal = SEQ_METADATA_PORTAL,
- .psc_rep_portal = MDC_REPLY_PORTAL,
- .psc_watchdog_timeout = MDT_SERVICE_WATCHDOG_TIMEOUT,
- .psc_min_threads = SEQ_NUM_THREADS,
- .psc_max_threads = SEQ_NUM_THREADS,
- .psc_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD
+ .psc_nbufs = MDS_NBUFS,
+ .psc_bufsize = MDS_BUFSIZE,
+ .psc_max_req_size = SEQ_MAXREQSIZE,
+ .psc_max_reply_size = SEQ_MAXREPSIZE,
+ .psc_req_portal = SEQ_METADATA_PORTAL,
+ .psc_rep_portal = MDC_REPLY_PORTAL,
+ .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
+ .psc_min_threads = SEQ_NUM_THREADS,
+ .psc_max_threads = SEQ_NUM_THREADS,
+ .psc_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD
};
m->mdt_mdss_service =
ptlrpc_init_svc_conf(&conf, mdt_mdss_handle,
LUSTRE_MDT_NAME"_mdss",
- procfs_entry, NULL, "mdt_mdss");
+ procfs_entry, target_print_req,"mdt_mdss");
if (!m->mdt_mdss_service) {
CERROR("failed to start metadata seq server service\n");
GOTO(err_mdt_svc, rc = -ENOMEM);
* controller which manages space.
*/
conf = (typeof(conf)) {
- .psc_nbufs = MDS_NBUFS,
- .psc_bufsize = MDS_BUFSIZE,
- .psc_max_req_size = SEQ_MAXREQSIZE,
- .psc_max_reply_size = SEQ_MAXREPSIZE,
- .psc_req_portal = SEQ_DATA_PORTAL,
- .psc_rep_portal = OSC_REPLY_PORTAL,
- .psc_watchdog_timeout = MDT_SERVICE_WATCHDOG_TIMEOUT,
- .psc_min_threads = SEQ_NUM_THREADS,
- .psc_max_threads = SEQ_NUM_THREADS,
- .psc_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD
+ .psc_nbufs = MDS_NBUFS,
+ .psc_bufsize = MDS_BUFSIZE,
+ .psc_max_req_size = SEQ_MAXREQSIZE,
+ .psc_max_reply_size = SEQ_MAXREPSIZE,
+ .psc_req_portal = SEQ_DATA_PORTAL,
+ .psc_rep_portal = OSC_REPLY_PORTAL,
+ .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
+ .psc_min_threads = SEQ_NUM_THREADS,
+ .psc_max_threads = SEQ_NUM_THREADS,
+ .psc_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD
};
m->mdt_dtss_service =
ptlrpc_init_svc_conf(&conf, mdt_dtss_handle,
LUSTRE_MDT_NAME"_dtss",
- procfs_entry, NULL, "mdt_dtss");
+ procfs_entry, target_print_req,"mdt_dtss");
if (!m->mdt_dtss_service) {
CERROR("failed to start data seq server service\n");
GOTO(err_mdt_svc, rc = -ENOMEM);
/* FLD service start */
conf = (typeof(conf)) {
- .psc_nbufs = MDS_NBUFS,
- .psc_bufsize = MDS_BUFSIZE,
- .psc_max_req_size = FLD_MAXREQSIZE,
- .psc_max_reply_size = FLD_MAXREPSIZE,
- .psc_req_portal = FLD_REQUEST_PORTAL,
- .psc_rep_portal = MDC_REPLY_PORTAL,
- .psc_watchdog_timeout = MDT_SERVICE_WATCHDOG_TIMEOUT,
- .psc_min_threads = FLD_NUM_THREADS,
- .psc_max_threads = FLD_NUM_THREADS,
- .psc_ctx_tags = LCT_DT_THREAD|LCT_MD_THREAD
+ .psc_nbufs = MDS_NBUFS,
+ .psc_bufsize = MDS_BUFSIZE,
+ .psc_max_req_size = FLD_MAXREQSIZE,
+ .psc_max_reply_size = FLD_MAXREPSIZE,
+ .psc_req_portal = FLD_REQUEST_PORTAL,
+ .psc_rep_portal = MDC_REPLY_PORTAL,
+ .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
+ .psc_min_threads = FLD_NUM_THREADS,
+ .psc_max_threads = FLD_NUM_THREADS,
+ .psc_ctx_tags = LCT_DT_THREAD|LCT_MD_THREAD
};
m->mdt_fld_service =
ptlrpc_init_svc_conf(&conf, mdt_fld_handle,
LUSTRE_MDT_NAME"_fld",
- procfs_entry, NULL, "mdt_fld");
+ procfs_entry, target_print_req, "mdt_fld");
if (!m->mdt_fld_service) {
CERROR("failed to start fld service\n");
GOTO(err_mdt_svc, rc = -ENOMEM);
* mds-mds requests be not blocked during recovery.
*/
conf = (typeof(conf)) {
- .psc_nbufs = MDS_NBUFS,
- .psc_bufsize = MDS_BUFSIZE,
- .psc_max_req_size = MDS_MAXREQSIZE,
- .psc_max_reply_size = MDS_MAXREPSIZE,
- .psc_req_portal = MDS_MDS_PORTAL,
- .psc_rep_portal = MDC_REPLY_PORTAL,
- .psc_watchdog_timeout = MDT_SERVICE_WATCHDOG_TIMEOUT,
- .psc_min_threads = min(max(mdt_num_threads, MDT_MIN_THREADS),
- MDT_MAX_THREADS),
- .psc_max_threads = MDT_MAX_THREADS,
- .psc_ctx_tags = LCT_MD_THREAD
+ .psc_nbufs = MDS_NBUFS,
+ .psc_bufsize = MDS_BUFSIZE,
+ .psc_max_req_size = MDS_MAXREQSIZE,
+ .psc_max_reply_size = MDS_MAXREPSIZE,
+ .psc_req_portal = MDS_MDS_PORTAL,
+ .psc_rep_portal = MDC_REPLY_PORTAL,
+ .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
+ .psc_min_threads = min(max(mdt_num_threads, MDT_MIN_THREADS),
+ MDT_MAX_THREADS),
+ .psc_max_threads = MDT_MAX_THREADS,
+ .psc_ctx_tags = LCT_MD_THREAD
};
- m->mdt_xmds_service = ptlrpc_init_svc_conf(&conf, mdt_xmds_handle,
- LUSTRE_MDT_NAME "_mds",
- procfs_entry, NULL, "mdt_xmds");
+ m->mdt_xmds_service =
+ ptlrpc_init_svc_conf(&conf, mdt_xmds_handle,
+ LUSTRE_MDT_NAME "_mds",
+ procfs_entry, target_print_req,"mdt_xmds");
if (m->mdt_xmds_service == NULL) {
CERROR("failed to start readpage service\n");
mdt_init_capa_ctxt(env, m);
+ /* Reduce the initial timeout on an MDS because it doesn't need such
+ * a long timeout as an OST does. Adaptive timeouts will adjust this
+ * value appropriately. */
if (ldlm_timeout == LDLM_TIMEOUT_DEFAULT)
- ldlm_timeout = 6;
+ ldlm_timeout = MDS_LDLM_TIMEOUT_DEFAULT;
RETURN(0);
switch (ev) {
case OBD_NOTIFY_CONFIG:
- mdt_allow_cli(mdt_dev(host->obd_lu_dev), (unsigned int)data);
+ mdt_allow_cli(mdt_dev(host->obd_lu_dev), (unsigned long)data);
break;
default:
CDEBUG(D_INFO, "Unhandled notification %#x\n", ev);
}
};
-MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
MODULE_DESCRIPTION("Lustre Meta-data Target ("LUSTRE_MDT_NAME")");
MODULE_LICENSE("GPL");