Merge branches 'acpi-ec' and 'acpi-button'
[cascardo/linux.git] / drivers / staging / lustre / lustre / include / lustre_fld.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  * Copyright (c) 2011, 2015, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  * Lustre is a trademark of Sun Microsystems, Inc.
31  */
32
33 #ifndef __LINUX_FLD_H
34 #define __LINUX_FLD_H
35
36 /** \defgroup fld fld
37  *
38  * @{
39  */
40
41 #include "lustre/lustre_idl.h"
42 #include "../../include/linux/libcfs/libcfs.h"
43
44 struct lu_client_fld;
45 struct lu_server_fld;
46 struct lu_fld_hash;
47 struct fld_cache;
48
49 extern const struct dt_index_features fld_index_features;
50 extern const char fld_index_name[];
51
52 /*
53  * FLD (Fid Location Database) interface.
54  */
55 enum {
56         LUSTRE_CLI_FLD_HASH_DHT = 0,
57         LUSTRE_CLI_FLD_HASH_RRB
58 };
59
60 struct lu_fld_target {
61         struct list_head               ft_chain;
62         struct obd_export       *ft_exp;
63         struct lu_server_fld    *ft_srv;
64         __u64               ft_idx;
65 };
66
67 struct lu_server_fld {
68         /**
69          * super sequence controller export, needed to forward fld
70          * lookup  request.
71          */
72         struct obd_export       *lsf_control_exp;
73
74         /** Client FLD cache. */
75         struct fld_cache        *lsf_cache;
76
77         /** Protect index modifications */
78         struct mutex            lsf_lock;
79
80         /** Fld service name in form "fld-srv-lustre-MDTXXX" */
81         char                 lsf_name[LUSTRE_MDT_MAXNAMELEN];
82
83 };
84
85 struct lu_client_fld {
86         /** Client side debugfs entry. */
87         struct dentry           *lcf_debugfs_entry;
88
89         /** List of exports client FLD knows about. */
90         struct list_head               lcf_targets;
91
92         /** Current hash to be used to chose an export. */
93         struct lu_fld_hash      *lcf_hash;
94
95         /** Exports count. */
96         int                   lcf_count;
97
98         /** Lock protecting exports list and fld_hash. */
99         spinlock_t               lcf_lock;
100
101         /** Client FLD cache. */
102         struct fld_cache        *lcf_cache;
103
104         /** Client fld debugfs entry name. */
105         char                     lcf_name[LUSTRE_MDT_MAXNAMELEN];
106
107         int                      lcf_flags;
108 };
109
110 /* Client methods */
111 int fld_client_init(struct lu_client_fld *fld,
112                     const char *prefix, int hash);
113
114 void fld_client_fini(struct lu_client_fld *fld);
115
116 void fld_client_flush(struct lu_client_fld *fld);
117
118 int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds,
119                       __u32 flags, const struct lu_env *env);
120
121 int fld_client_create(struct lu_client_fld *fld,
122                       struct lu_seq_range *range,
123                       const struct lu_env *env);
124
125 int fld_client_delete(struct lu_client_fld *fld, u64 seq,
126                       const struct lu_env *env);
127
128 int fld_client_add_target(struct lu_client_fld *fld,
129                           struct lu_fld_target *tar);
130
131 int fld_client_del_target(struct lu_client_fld *fld,
132                           __u64 idx);
133
134 void fld_client_debugfs_fini(struct lu_client_fld *fld);
135
136 /** @} fld */
137
138 #endif