Whamcloud - gitweb
LU-12624 lod: alloc dir stripes by QoS
[fs/lustre-release.git] / lustre / include / lustre_mdc.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*
27  * Copyright (c) 2011, 2014, Intel Corporation.
28  */
29 /*
30  * This file is part of Lustre, http://www.lustre.org/
31  * Lustre is a trademark of Sun Microsystems, Inc.
32  *
33  * lustre/include/lustre_mdc.h
34  *
35  * MDS data structures.
36  * See also lustre_idl.h for wire formats of requests.
37  */
38
39 #ifndef _LUSTRE_MDC_H
40 #define _LUSTRE_MDC_H
41
42 /** \defgroup mdc mdc
43  *
44  * @{
45  */
46
47 #include <linux/fs.h>
48 #include <linux/dcache.h>
49 #ifdef CONFIG_LUSTRE_FS_POSIX_ACL
50 # include <lustre_compat.h>
51 #endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
52 #include <lustre_handles.h>
53 #include <lustre_intent.h>
54 #include <libcfs/libcfs.h>
55 #include <obd_class.h>
56 #include <uapi/linux/lustre/lustre_idl.h>
57 #include <lustre_lib.h>
58 #include <lustre_dlm.h>
59 #include <lustre_export.h>
60
61 struct ptlrpc_client;
62 struct obd_export;
63 struct ptlrpc_request;
64 struct obd_device;
65
66 static inline void mdc_get_mod_rpc_slot(struct ptlrpc_request *req,
67                                         struct lookup_intent *it)
68 {
69         struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
70         __u32 opc;
71         __u16 tag;
72
73         opc = lustre_msg_get_opc(req->rq_reqmsg);
74         tag = obd_get_mod_rpc_slot(cli, opc, it);
75         lustre_msg_set_tag(req->rq_reqmsg, tag);
76         ptlrpc_reassign_next_xid(req);
77 }
78
79 static inline void mdc_put_mod_rpc_slot(struct ptlrpc_request *req,
80                                         struct lookup_intent *it)
81 {
82         struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
83         __u32 opc;
84         __u16 tag;
85
86         opc = lustre_msg_get_opc(req->rq_reqmsg);
87         tag = lustre_msg_get_tag(req->rq_reqmsg);
88         obd_put_mod_rpc_slot(cli, opc, it, tag);
89 }
90
91
92 /**
93  * Update the maximum possible easize.
94  *
95  * This value is learned from ptlrpc replies sent by the MDT.  The
96  * default easize is initialized to the minimum value but allowed to
97  * grow up to a single page in size if required to handle the common
98  * case.
99  *
100  * \see client_obd::cl_default_mds_easize
101  *
102  * \param[in] exp       export for MDC device
103  * \param[in] body      body of ptlrpc reply from MDT
104  *
105  */
106 static inline void mdc_update_max_ea_from_body(struct obd_export *exp,
107                                                struct mdt_body *body)
108 {
109         if (body->mbo_valid & OBD_MD_FLMODEASIZE) {
110                 struct client_obd *cli = &exp->exp_obd->u.cli;
111                 __u32 def_easize;
112
113                 if (cli->cl_max_mds_easize < body->mbo_max_mdsize)
114                         cli->cl_max_mds_easize = body->mbo_max_mdsize;
115
116                 def_easize = min_t(__u32, body->mbo_max_mdsize,
117                                    OBD_MAX_DEFAULT_EA_SIZE);
118                 cli->cl_default_mds_easize = def_easize;
119         }
120 }
121
122
123 /* mdc/mdc_locks.c */
124 int it_open_error(int phase, struct lookup_intent *it);
125
126 static inline bool cl_is_lov_delay_create(unsigned int flags)
127 {
128         return  (flags & O_LOV_DELAY_CREATE_1_8) != 0 ||
129                 (flags & O_LOV_DELAY_CREATE_MASK) == O_LOV_DELAY_CREATE_MASK;
130 }
131
132 static inline void cl_lov_delay_create_clear(unsigned int *flags)
133 {
134         if ((*flags & O_LOV_DELAY_CREATE_1_8) != 0)
135                 *flags &= ~O_LOV_DELAY_CREATE_1_8;
136         if ((*flags & O_LOV_DELAY_CREATE_MASK) == O_LOV_DELAY_CREATE_MASK)
137                 *flags &= ~O_LOV_DELAY_CREATE_MASK;
138 }
139
140 /** @} mdc */
141
142 #endif