1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36#define DEBUG_SUBSYSTEM S_LLITE
37#include "../include/obd_class.h"
38#include "../include/obd_support.h"
39#include "../include/obd.h"
40#include "../include/cl_object.h"
41
42#include "llite_internal.h"
43
44
45
46
47
48
49int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
50{
51 u32 val_size, max_easize, def_easize;
52 int rc;
53
54 val_size = sizeof(max_easize);
55 rc = obd_get_info(NULL, dt_exp, sizeof(KEY_MAX_EASIZE), KEY_MAX_EASIZE,
56 &val_size, &max_easize);
57 if (rc)
58 return rc;
59
60 val_size = sizeof(def_easize);
61 rc = obd_get_info(NULL, dt_exp, sizeof(KEY_DEFAULT_EASIZE),
62 KEY_DEFAULT_EASIZE, &val_size, &def_easize);
63 if (rc)
64 return rc;
65
66
67
68
69
70 CDEBUG(D_HA, "updating def/max_easize: %d/%d\n",
71 def_easize, max_easize);
72
73 rc = md_init_ea_size(md_exp, max_easize, def_easize);
74 return rc;
75}
76
77
78
79
80
81
82
83int cl_ocd_update(struct obd_device *host,
84 struct obd_device *watched,
85 enum obd_notify_event ev, void *owner, void *data)
86{
87 struct lustre_client_ocd *lco;
88 struct client_obd *cli;
89 __u64 flags;
90 int result;
91
92 if (!strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME) &&
93 watched->obd_set_up && !watched->obd_stopping) {
94 cli = &watched->u.cli;
95 lco = owner;
96 flags = cli->cl_import->imp_connect_data.ocd_connect_flags;
97 CDEBUG(D_SUPER, "Changing connect_flags: %#llx -> %#llx\n",
98 lco->lco_flags, flags);
99 mutex_lock(&lco->lco_lock);
100 lco->lco_flags &= flags;
101
102 if (lco->lco_dt_exp)
103 cl_init_ea_size(lco->lco_md_exp, lco->lco_dt_exp);
104
105 mutex_unlock(&lco->lco_lock);
106 result = 0;
107 } else {
108 CERROR("unexpected notification from %s %s (setup:%d,stopping:%d)!\n",
109 watched->obd_type->typ_name,
110 watched->obd_name, watched->obd_set_up,
111 watched->obd_stopping);
112 result = -EINVAL;
113 }
114 return result;
115}
116
117#define GROUPLOCK_SCOPE "grouplock"
118
119int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock,
120 struct ll_grouplock *cg)
121{
122 struct lu_env *env;
123 struct cl_io *io;
124 struct cl_lock *lock;
125 struct cl_lock_descr *descr;
126 __u32 enqflags;
127 u16 refcheck;
128 int rc;
129
130 env = cl_env_get(&refcheck);
131 if (IS_ERR(env))
132 return PTR_ERR(env);
133
134 io = vvp_env_thread_io(env);
135 io->ci_obj = obj;
136
137 rc = cl_io_init(env, io, CIT_MISC, io->ci_obj);
138 if (rc != 0) {
139 cl_io_fini(env, io);
140 cl_env_put(env, &refcheck);
141
142 if (rc > 0)
143 rc = -ENOTSUPP;
144 return rc;
145 }
146
147 lock = vvp_env_lock(env);
148 descr = &lock->cll_descr;
149 descr->cld_obj = obj;
150 descr->cld_start = 0;
151 descr->cld_end = CL_PAGE_EOF;
152 descr->cld_gid = gid;
153 descr->cld_mode = CLM_GROUP;
154
155 enqflags = CEF_MUST | (nonblock ? CEF_NONBLOCK : 0);
156 descr->cld_enq_flags = enqflags;
157
158 rc = cl_lock_request(env, io, lock);
159 if (rc < 0) {
160 cl_io_fini(env, io);
161 cl_env_put(env, &refcheck);
162 return rc;
163 }
164
165 cg->lg_env = env;
166 cg->lg_io = io;
167 cg->lg_lock = lock;
168 cg->lg_gid = gid;
169
170 return 0;
171}
172
173void cl_put_grouplock(struct ll_grouplock *cg)
174{
175 struct lu_env *env = cg->lg_env;
176 struct cl_io *io = cg->lg_io;
177 struct cl_lock *lock = cg->lg_lock;
178
179 LASSERT(cg->lg_env);
180 LASSERT(cg->lg_gid);
181
182 cl_lock_release(env, lock);
183 cl_io_fini(env, io);
184 cl_env_put(env, NULL);
185}
186