1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Lustre Metadata Target (mdt) request handler
7 * Copyright (c) 2006 Cluster File Systems, Inc.
8 * Author: Peter Braam <braam@clusterfs.com>
9 * Author: Andreas Dilger <adilger@clusterfs.com>
10 * Author: Phil Schwan <phil@clusterfs.com>
11 * Author: Mike Shaver <shaver@clusterfs.com>
12 * Author: Nikita Danilov <nikita@clusterfs.com>
14 * This file is part of the Lustre file system, http://www.lustre.org
15 * Lustre is a trademark of Cluster File Systems, Inc.
17 * You may have signed or agreed to another license before downloading
18 * this software. If so, you are bound by the terms and conditions
19 * of that agreement, and the following does not apply to you. See the
20 * LICENSE file included with this distribution for more information.
22 * If you did not agree to a different license, then this copy of Lustre
23 * is open source software; you can redistribute it and/or modify it
24 * under the terms of version 2 of the GNU General Public License as
25 * published by the Free Software Foundation.
27 * In either case, Lustre is distributed in the hope that it will be
28 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
29 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * license text for more details.
33 #ifndef _MDT_INTERNAL_H
34 #define _MDT_INTERNAL_H
36 #if defined(__KERNEL__)
39 * struct ptlrpc_client
41 #include <linux/lustre_net.h>
42 #include <linux/obd.h>
44 * struct obd_connect_data
45 * struct lustre_handle
47 #include <linux/lustre_idl.h>
48 #include <linux/md_object.h>
49 #include <linux/lustre_fid.h>
51 struct ptlrpc_service_conf {
55 int psc_max_reply_size;
58 int psc_watchdog_timeout; /* in ms */
64 struct md_device mdt_md_dev;
65 struct ptlrpc_service *mdt_service;
66 struct ptlrpc_service *mdt_fld_service;
67 struct ptlrpc_service_conf mdt_service_conf;
68 /* DLM name-space for meta-data locks maintained by this server */
69 struct ldlm_namespace *mdt_namespace;
70 /* ptlrpc handle for MDS->client connections (for lock ASTs). */
71 struct ptlrpc_client mdt_ldlm_client;
72 /* underlying device */
73 struct md_device *mdt_child;
75 * Device flags, taken from enum mdt_flags. No locking (so far) is
78 unsigned long mdt_flags;
80 /* Seq management related stuff */
81 struct lu_seq_mgr *mdt_seq_mgr;
84 static inline struct md_device_operations *mdt_child_ops(struct mdt_device * m)
86 LASSERT(m->mdt_child);
87 return m->mdt_child->md_ops;
92 * This mdt works with legacy clients with different resource name
93 * encoding (pre-fid, etc.).
95 MDT_CL_COMPAT_RESNAME = 1 << 0,
99 struct lu_object_header mot_header;
100 struct md_object mot_obj;
103 static inline struct md_object *mdt_object_child(struct mdt_object *o)
105 return lu2md(lu_object_next(&o->mot_obj.mo_lu));
108 static inline struct mdt_object *lu2mdt_obj(struct lu_object *o)
110 return (container_of(lu2md(o),struct mdt_object, mot_obj));
113 struct mdt_lock_handle {
114 struct lustre_handle mlh_lh;
115 ldlm_mode_t mlh_mode;
118 void mdt_lock_handle_init(struct mdt_lock_handle *lh);
119 void mdt_lock_handle_fini(struct mdt_lock_handle *lh);
121 int md_device_init(struct md_device *md, struct lu_device_type *t);
122 void md_device_fini(struct md_device *md);
125 MDT_REP_BUF_NR_MAX = 8
135 * Common data shared by mdt-level handlers. This is allocated per-thread to
136 * reduce stack consumption.
138 struct mdt_thread_info {
139 struct lu_context *mti_ctxt;
140 struct mdt_device *mti_mdt;
142 * number of buffers in reply message.
146 * sizes of reply buffers.
148 int mti_rep_buf_size[MDT_REP_BUF_NR_MAX];
150 * Body for "habeo corpus" operations.
152 struct mdt_body *mti_body;
154 * Lock request for "habeo clavis" operations.
156 struct ldlm_request *mti_dlm_req;
158 * Host object. This is released at the end of mdt_handler().
160 struct mdt_object *mti_object;
162 * Additional fail id that can be set by handler. Passed to
163 * target_send_reply().
167 * A couple of lock handles.
169 struct mdt_lock_handle mti_lh[MDT_LH_NR];
173 int fid_lock(struct ldlm_namespace *, const struct lu_fid *,
174 struct lustre_handle *, ldlm_mode_t,
175 ldlm_policy_data_t *);
177 void fid_unlock(struct ldlm_namespace *, const struct lu_fid *,
178 struct lustre_handle *, ldlm_mode_t);
180 struct mdt_object *mdt_object_find(struct lu_context *, struct mdt_device *,
182 void mdt_object_put(struct lu_context *ctxt, struct mdt_object *);
184 struct lu_fid *mdt_object_fid(struct mdt_object *);
186 int mdt_object_lock(struct ldlm_namespace *, struct mdt_object *,
187 struct mdt_lock_handle *, __u64);
189 void mdt_object_unlock(struct ldlm_namespace *, struct mdt_object *,
190 struct mdt_lock_handle *);
192 struct mdt_object *mdt_object_find_lock(struct lu_context *, struct mdt_device *,
194 struct mdt_lock_handle *, __u64);
195 #endif /* __KERNEL__ */