summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-lock.h
blob: 0557858041e701f95b3436bb0457be23bd7f9717 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
  Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
  This file is part of GlusterFS.

  This file is licensed to you under your choice of the GNU Lesser
  General Public License, version 3 or any later version (LGPLv3 or
  later), or the GNU General Public License, version 2 (GPLv2), in all
  cases as published by the Free Software Foundation.
*/

#ifndef _DHT_LOCK_H
#define _DHT_LOCK_H

#include "xlator.h"
#include "dht-common.h"

void
dht_lock_array_free (dht_lock_t **lk_array, int count);

int32_t
dht_lock_count (dht_lock_t **lk_array, int lk_count);

dht_lock_t *
dht_lock_new (xlator_t *this, xlator_t *xl, loc_t *loc, short type,
              const char *domain, const char *basename);

int32_t
dht_unlock_entrylk_wrapper (call_frame_t *, dht_elock_wrap_t *);

void
dht_blocking_entrylk_rec (call_frame_t *frame, int i);

int
dht_blocking_entrylk (call_frame_t *frame, dht_lock_t **lk_array,
                      int lk_count, dht_reaction_type_t reaction,
                      fop_inodelk_cbk_t entrylk_cbk);

int32_t
dht_unlock_inodelk (call_frame_t *frame, dht_lock_t **lk_array, int lk_count,
                     fop_inodelk_cbk_t inodelk_cbk);

int32_t
dht_unlock_inodelk_wrapper (call_frame_t *, dht_ilock_wrap_t *);

/* Acquire non-blocking inodelk on a list of xlators.
 *
 * @lk_array: array of lock requests lock on.
 *
 * @lk_count: number of locks in @lk_array
 *
 * @inodelk_cbk: will be called after inodelk replies are received
 *
 * @retval: -1 if stack_winding inodelk fails. 0 otherwise.
 *          inodelk_cbk is called with appropriate error on errors.
 *          On failure to acquire lock on all members of list, successful
 *          locks are unlocked before invoking cbk.
 */

int
dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array,
                         int lk_count, fop_inodelk_cbk_t inodelk_cbk);

void
dht_blocking_inodelk_rec (call_frame_t *frame, int i);

/* same as dht_nonblocking_inodelk, but issues sequential blocking locks on
 * @lk_array directly. locks are issued on some order which remains same
 * for a list of xlators (irrespective of order of xlators within list).
 */

int
dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array,
                      int lk_count, dht_reaction_type_t reaction,
                      fop_inodelk_cbk_t inodelk_cbk);

int32_t
dht_blocking_entrylk_after_inodelk (call_frame_t *frame, void *cookie,
                                    xlator_t *this, int32_t op_ret,
                                    int32_t op_errno, dict_t *xdata);

int32_t
dht_blocking_entrylk_after_inodelk_rename (call_frame_t *frame, void *cookie,
                                           xlator_t *this, int32_t op_ret,
                                           int32_t op_errno, dict_t *xdata);

void
dht_unlock_namespace (call_frame_t *, dht_dir_transaction_t *);

int
dht_protect_namespace (call_frame_t *frame, loc_t *loc, xlator_t *subvol,
                       struct dht_namespace *ns,
                       fop_entrylk_cbk_t ns_cbk);

#endif   /* _DHT_LOCK_H */