4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 021110-1307, USA
24 * Copyright (c) 2012, Intel Corporation.
27 * lustre/target/tgt_internal.h
29 * Lustre Unified Target header file
31 * Author: Mikhail Pershin <mike.pershin@intel.com>
34 #ifndef _TG_INTERNAL_H
35 #define _TG_INTERNAL_H
37 #include <lustre_net.h>
38 #include <lustre/lustre_idl.h>
39 #include <lu_target.h>
40 #include <lustre_export.h>
41 #include <lustre_fid.h>
42 #include <lustre_fld.h>
43 #include <lustre_req_layout.h>
44 #include <lustre_sec.h>
46 extern int (*tgt_lfsck_in_notify)(const struct lu_env *env,
47 struct dt_device *key,
48 struct lfsck_request *lr);
51 typedef int (*tx_exec_func_t)(const struct lu_env *env, struct thandle *th,
55 tx_exec_func_t exec_fn;
56 tx_exec_func_t undo_fn;
57 struct dt_object *object;
59 struct update_reply *reply;
64 const struct dt_rec *rec;
65 const struct dt_key *key;
80 struct dt_allocation_hint hint;
81 struct dt_object_format dof;
89 struct ost_body *body;
95 struct thandle_exec_args {
96 struct thandle *ta_handle;
97 struct dt_device *ta_dev;
98 struct tx_arg ta_args[TX_MAX_OPS];
100 int ta_argno; /* used args */
104 * Common data shared by tg-level handlers. This is allocated per-thread to
105 * reduce stack consumption.
107 struct tgt_thread_info {
108 /* server and client data buffers */
109 struct lr_server_data tti_lsd;
110 struct lsd_client_data tti_lcd;
111 struct lu_buf tti_buf;
114 struct lu_attr tti_attr;
115 struct lu_fid tti_fid1;
117 /* transno storage during last_rcvd update */
119 __u32 tti_has_trans:1,
122 /* Updates data for OUT target */
123 struct thandle_exec_args tti_tea;
126 /* for tgt_readpage() */
127 struct lu_rdpg tti_rdpg;
128 /* for tgt_sendpage() */
129 struct l_wait_info tti_wait_info;
132 struct dt_object_format tti_update_dof;
133 struct update_reply *tti_update_reply;
134 struct update *tti_update;
135 int tti_update_reply_index;
136 struct obdo tti_obdo;
137 struct dt_object *tti_dt_object;
142 extern struct lu_context_key tgt_thread_key;
144 static inline struct tgt_thread_info *tgt_th_info(const struct lu_env *env)
146 struct tgt_thread_info *tti;
148 tti = lu_context_key_get(&env->le_ctx, &tgt_thread_key);
153 #define MGS_SERVICE_WATCHDOG_FACTOR (2)
155 int tgt_request_handle(struct ptlrpc_request *req);
157 /* check if request's xid is equal to last one or not*/
158 static inline int req_xid_is_last(struct ptlrpc_request *req)
160 struct lsd_client_data *lcd = req->rq_export->exp_target_data.ted_lcd;
162 LASSERT(lcd != NULL);
163 return (req->rq_xid == lcd->lcd_last_xid ||
164 req->rq_xid == lcd->lcd_last_close_xid);
167 static inline char *dt_obd_name(struct dt_device *dt)
169 return dt->dd_lu_dev.ld_obd->obd_name;
172 /* Update handlers */
173 int out_handle(struct tgt_session_info *tsi);
175 #define out_tx_create(info, obj, attr, fid, dof, th, reply, idx) \
176 __out_tx_create(info, obj, attr, fid, dof, th, reply, idx, \
179 #define out_tx_attr_set(info, obj, attr, th, reply, idx) \
180 __out_tx_attr_set(info, obj, attr, th, reply, idx, \
183 #define out_tx_xattr_set(info, obj, buf, name, fl, th, reply, idx) \
184 __out_tx_xattr_set(info, obj, buf, name, fl, th, reply, idx, \
187 #define out_tx_ref_add(info, obj, th, reply, idx) \
188 __out_tx_ref_add(info, obj, th, reply, idx, __FILE__, __LINE__)
190 #define out_tx_ref_del(info, obj, th, reply, idx) \
191 __out_tx_ref_del(info, obj, th, reply, idx, __FILE__, __LINE__)
193 #define out_tx_index_insert(info, obj, th, name, fid, reply, idx) \
194 __out_tx_index_insert(info, obj, th, name, fid, reply, idx, \
197 #define out_tx_index_delete(info, obj, th, name, reply, idx) \
198 __out_tx_index_delete(info, obj, th, name, reply, idx, \
201 #define out_tx_destroy(info, obj, th, reply, idx) \
202 __out_tx_destroy(info, obj, th, reply, idx, __FILE__, __LINE__)
204 extern struct page *tgt_page_to_corrupt;
206 struct tgt_thread_big_cache {
207 struct niobuf_local local[PTLRPC_MAX_BRW_PAGES];
210 int tgt_server_data_init(const struct lu_env *env, struct lu_target *tgt);
211 int tgt_txn_start_cb(const struct lu_env *env, struct thandle *th,
213 int tgt_txn_stop_cb(const struct lu_env *env, struct thandle *th,
216 #endif /* _TG_INTERNAL_H */