1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/mdc/mdc_internal.h
38 * MDC internal definitions.
41 #include <lustre_mds.h>
43 void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars);
45 static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
47 memset(lvars, 0, sizeof(*lvars));
50 void mdc_pack_req_body(struct ptlrpc_request *req, int offset,
51 __u64 valid, struct ll_fid *fid, int ea_size, int flags);
52 void mdc_pack_rep_body(struct ptlrpc_request *);
53 void mdc_readdir_pack(struct ptlrpc_request *req, int offset, __u64 pg_off,
54 __u32 size, struct ll_fid *mdc_fid);
55 void mdc_getattr_pack(struct ptlrpc_request *req, int offset, __u64 valid,
56 int flags, struct mdc_op_data *data);
57 void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
58 struct mdc_op_data *data,
59 struct iattr *iattr, void *ea, int ealen,
60 void *ea2, int ea2len);
61 void mdc_create_pack(struct ptlrpc_request *req, int offset,
62 struct mdc_op_data *op_data, const void *data, int datalen,
63 __u32 mode, __u32 uid, __u32 gid, cfs_cap_t cap_effective,
65 void mdc_open_pack(struct ptlrpc_request *req, int offset,
66 struct mdc_op_data *op_data, __u32 mode, __u64 rdev,
67 __u32 flags, const void *data, int datalen);
68 void mdc_join_pack(struct ptlrpc_request *req, int offset,
69 struct mdc_op_data *op_data, __u64 head_size);
70 void mdc_unlink_pack(struct ptlrpc_request *req, int offset,
71 struct mdc_op_data *data);
72 void mdc_link_pack(struct ptlrpc_request *req, int offset,
73 struct mdc_op_data *data);
74 void mdc_rename_pack(struct ptlrpc_request *req, int offset,
75 struct mdc_op_data *data,
76 const char *old, int oldlen, const char *new, int newlen);
77 void mdc_close_pack(struct ptlrpc_request *req, int offset,
78 struct mdc_op_data *data,
80 __u64 valid, struct obd_client_handle *och);
81 void mdc_exit_request(struct client_obd *cli);
82 void mdc_enter_request(struct client_obd *cli);
84 int seq_client_init(struct lu_client_seq *seq,
85 struct obd_export *exp,
86 enum lu_cli_type type,
90 void seq_client_fini(struct lu_client_seq *seq);
92 int mdc_fid_alloc(struct lu_client_seq *seq, struct lu_fid *fid);
94 struct mdc_open_data {
95 struct obd_client_handle *mod_och;
96 struct ptlrpc_request *mod_open_req;
97 struct ptlrpc_request *mod_close_req;
100 struct mdc_rpc_lock {
101 struct semaphore rpcl_sem;
102 struct lookup_intent *rpcl_it;
105 static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck)
107 sema_init(&lck->rpcl_sem, 1);
111 static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,
112 struct lookup_intent *it)
115 if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
116 down(&lck->rpcl_sem);
117 LASSERT(lck->rpcl_it == NULL);
122 static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck,
123 struct lookup_intent *it)
125 if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
126 LASSERT(it == lck->rpcl_it);
133 static inline int mdc_exp_is_2_0_server(struct obd_export *exp) {
135 return !!(exp->exp_connect_flags & OBD_CONNECT_FID);
138 static inline int mdc_req_is_2_0_server(struct ptlrpc_request *req) {
140 return mdc_exp_is_2_0_server(req->rq_export);