Motr  M0
fom_long_lock.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_LONG_LOCK_H__
26 #define __MOTR_LONG_LOCK_H__
27 
123 #include "fop/fop.h"
124 #include "lib/list.h"
125 #include "lib/chan.h"
126 #include "lib/mutex.h"
127 #include "lib/bob.h"
128 
136 };
137 
144 };
145 
153 };
154 
161  struct m0_fom *lll_fom;
165  uint64_t lll_magix;
170 };
171 
175 struct m0_long_lock {
177  struct m0_tl l_owners;
179  struct m0_tl l_waiters;
181  struct m0_mutex l_lock;
185  uint64_t l_magix;
186 };
187 
188 //#ifdef __KERNEL__
189 #if 1 /* XXX */
190 #define M0_BE_LONG_LOCK_PAD (264 + 88)
191 #else
192 #define M0_BE_LONG_LOCK_PAD (136 + 40)
193 #endif
194 
199  union {
202  } bll_u;
204 M0_BASSERT(sizeof(struct m0_long_lock) <=
205  sizeof(M0_FIELD_VALUE(struct m0_be_long_lock, bll_u.pad)));
206 
214 #define M0_FOM_LONG_LOCK_RETURN(rc) ((rc) ? M0_FSO_AGAIN : M0_FSO_WAIT)
215 
220 M0_INTERNAL void m0_long_lock_init(struct m0_long_lock *lock);
221 
226 M0_INTERNAL void m0_long_lock_fini(struct m0_long_lock *lock);
227 
244 M0_INTERNAL bool m0_long_read_lock(struct m0_long_lock *lock,
245  struct m0_long_lock_link *link,
246  int next_phase);
247 
264 M0_INTERNAL bool m0_long_write_lock(struct m0_long_lock *lock,
265  struct m0_long_lock_link *link,
266  int next_phase);
267 
272 M0_INTERNAL bool m0_long_lock(struct m0_long_lock *lock, bool write,
273  struct m0_long_lock_link *link,
274  int next_phase);
275 
286 M0_INTERNAL void m0_long_read_unlock(struct m0_long_lock *lock,
287  struct m0_long_lock_link *link);
288 
299 M0_INTERNAL void m0_long_write_unlock(struct m0_long_lock *lock,
300  struct m0_long_lock_link *link);
301 
305 M0_INTERNAL void m0_long_unlock(struct m0_long_lock *lock,
306  struct m0_long_lock_link *link);
307 
311 M0_INTERNAL bool m0_long_is_read_locked(struct m0_long_lock *lock,
312  const struct m0_fom *fom);
313 
317 M0_INTERNAL bool m0_long_is_write_locked(struct m0_long_lock *lock,
318  const struct m0_fom *fom);
319 
327 M0_INTERNAL void m0_long_lock_link_init(struct m0_long_lock_link *link,
328  struct m0_fom *fom,
329  struct m0_long_lock_addb2 *addb2);
330 
336 M0_INTERNAL void m0_long_lock_link_fini(struct m0_long_lock_link *link);
337 
338 M0_BOB_DECLARE(M0_EXTERN, m0_long_lock);
340 
345 M0_INTERNAL void m0_fom_ll_global_init(void);
346 
347 
350 #endif /* __MOTR_LONG_LOCK_H__ */
351 
352 /*
353  * Local variables:
354  * c-indentation-style: "K&R"
355  * c-basic-offset: 8
356  * tab-width: 8
357  * fill-column: 80
358  * scroll-step: 1
359  * End:
360  */
M0_INTERNAL void m0_long_lock_fini(struct m0_long_lock *lock)
static struct m0_mutex lock
Definition: transmit.c:326
M0_INTERNAL void m0_long_lock_link_init(struct m0_long_lock_link *link, struct m0_fom *fom, struct m0_long_lock_addb2 *addb2)
Definition: fom_long_lock.c:66
enum m0_long_lock_state l_state
#define M0_XCA_BLOB
Definition: xcode_attr.h:53
#define M0_FIELD_VALUE(type, field)
Definition: misc.h:339
struct m0_mutex l_lock
uint64_t m0_time_t
Definition: time.h:37
struct m0_tl l_owners
m0_long_lock_type
M0_INTERNAL void m0_long_write_unlock(struct m0_long_lock *lock, struct m0_long_lock_link *link)
struct m0_tl l_waiters
M0_BOB_DECLARE(M0_EXTERN, m0_long_lock)
struct m0_long_lock llock
union @191 bll_u
struct m0_be_long_lock M0_XCA_DOMAIN(be)
M0_INTERNAL bool m0_long_write_lock(struct m0_long_lock *lk, struct m0_long_lock_link *link, int next_phase)
M0_INTERNAL bool m0_long_lock(struct m0_long_lock *lock, bool write, struct m0_long_lock_link *link, int next_phase)
M0_INTERNAL void m0_long_unlock(struct m0_long_lock *lock, struct m0_long_lock_link *link)
#define M0_BE_LONG_LOCK_PAD
M0_INTERNAL void m0_long_lock_link_fini(struct m0_long_lock_link *link)
Definition: fom_long_lock.c:76
Definition: tlist.h:251
union m0_be_long_lock::@190 bll_u
Definition: dump.c:103
m0_long_lock_state
M0_INTERNAL bool m0_long_is_read_locked(struct m0_long_lock *lock, const struct m0_fom *fom)
M0_BASSERT(sizeof(struct m0_long_lock)<=sizeof(M0_FIELD_VALUE(struct m0_be_long_lock, bll_u.pad)))
M0_INTERNAL bool m0_long_is_write_locked(struct m0_long_lock *lock, const struct m0_fom *fom)
char pad[M0_BE_LONG_LOCK_PAD]
M0_INTERNAL void m0_long_lock_init(struct m0_long_lock *lock)
Definition: fom.h:481
uint64_t l_magix
M0_INTERNAL void m0_long_read_unlock(struct m0_long_lock *lock, struct m0_long_lock_link *link)
M0_INTERNAL bool m0_long_read_lock(struct m0_long_lock *lk, struct m0_long_lock_link *link, int next_phase)
M0_INTERNAL void m0_fom_ll_global_init(void)
Definition: fom_long_lock.c:60
Definition: mutex.h:47
static struct m0_be_ut_backend be
Definition: service_ut.c:59