Whamcloud - gitweb
LU-19098 hsm: don't print progname twice with lhsmtool
[fs/lustre-release.git] / lustre / include / lustre_mdc.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2
3 /*
4  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
5  * Use is subject to license terms.
6  *
7  * Copyright (c) 2011, 2014, Intel Corporation.
8  */
9
10 /*
11  * This file is part of Lustre, http://www.lustre.org/
12  *
13  * MDS data structures.
14  * See also lustre_idl.h for wire formats of requests.
15  */
16
17 #ifndef _LUSTRE_MDC_H
18 #define _LUSTRE_MDC_H
19
20 /** \defgroup mdc mdc
21  *
22  * @{
23  */
24
25 #include <linux/fs.h>
26 #include <linux/dcache.h>
27 #ifdef CONFIG_LUSTRE_FS_POSIX_ACL
28 # include <lustre_compat.h>
29 #endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
30 #include <lustre_handles.h>
31 #include <lustre_intent.h>
32 #include <libcfs/libcfs.h>
33 #include <obd_class.h>
34 #include <uapi/linux/lustre/lustre_idl.h>
35 #include <lustre_lib.h>
36 #include <lustre_dlm.h>
37 #include <lustre_export.h>
38
39 struct ptlrpc_client;
40 struct obd_export;
41 struct ptlrpc_request;
42 struct obd_device;
43
44 /**
45  * Update the maximum possible easize.
46  *
47  * This value is learned from ptlrpc replies sent by the MDT.  The
48  * default easize is initialized to the minimum value but allowed to
49  * grow up to a single page in size if required to handle the common
50  * case.
51  *
52  * \see client_obd::cl_default_mds_easize
53  *
54  * \param[in] exp       export for MDC device
55  * \param[in] body      body of ptlrpc reply from MDT
56  *
57  */
58 static inline void mdc_update_max_ea_from_body(struct obd_export *exp,
59                                                struct mdt_body *body)
60 {
61         if (body->mbo_valid & OBD_MD_FLMODEASIZE) {
62                 struct client_obd *cli = &exp->exp_obd->u.cli;
63                 __u32 def_easize;
64
65                 if (cli->cl_max_mds_easize < body->mbo_max_mdsize)
66                         cli->cl_max_mds_easize = body->mbo_max_mdsize;
67
68                 def_easize = min_t(__u32, body->mbo_max_mdsize,
69                                    OBD_MAX_DEFAULT_EA_SIZE);
70                 cli->cl_default_mds_easize = def_easize;
71         }
72 }
73
74
75 /* mdc/mdc_locks.c */
76 int it_open_error(int phase, struct lookup_intent *it);
77
78 static inline bool cl_is_lov_delay_create(enum mds_open_flags flags)
79 {
80         return (flags & O_LOV_DELAY_CREATE) == O_LOV_DELAY_CREATE;
81 }
82
83 static inline void cl_lov_delay_create_clear(unsigned int *flags)
84 {
85         if ((*flags & O_LOV_DELAY_CREATE) == O_LOV_DELAY_CREATE)
86                 *flags &= ~O_LOV_DELAY_CREATE;
87 }
88
89 static inline unsigned long hash_x_index(__u64 hash, int hash64)
90 {
91         if (BITS_PER_LONG == 32 && hash64)
92                 hash >>= 32;
93         /* save hash 0 with hash 1 */
94         return ~0UL - (hash + !hash);
95 }
96
97
98 /** @} mdc */
99
100 #endif