2
Copyright (c) 2006, 2007, 2008 Gluster, Inc. <http://www.gluster.com>
3
This file is part of GlusterFS.
5
GlusterFS is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published
7
by the Free Software Foundation; either version 3 of the License,
8
or (at your option) any later version.
10
GlusterFS 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 for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see
17
<http://www.gnu.org/licenses/>.
2
Copyright (c) 2006, 2007, 2008 Gluster, Inc. <http://www.gluster.com>
3
This file is part of GlusterFS.
5
GlusterFS is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published
7
by the Free Software Foundation; either version 3 of the License,
8
or (at your option) any later version.
10
GlusterFS 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 for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see
17
<http://www.gnu.org/licenses/>.
20
20
#ifndef __POSIX_LOCKS_H__
35
35
struct __posix_lock {
36
struct list_head list;
42
short blocked; /* waiting to acquire */
43
struct flock user_flock; /* the flock supplied by the user */
44
xlator_t *this; /* required for blocked locks */
49
/* These two together serve to uniquely identify each process
52
transport_t *transport; /* to identify client node */
53
pid_t client_pid; /* pid of client process */
36
struct list_head list;
42
short blocked; /* waiting to acquire */
43
struct flock user_flock; /* the flock supplied by the user */
44
xlator_t *this; /* required for blocked locks */
49
/* These two together serve to uniquely identify each process
52
transport_t *transport; /* to identify client node */
53
pid_t client_pid; /* pid of client process */
54
uint64_t owner; /* lock owner from fuse */
55
56
typedef struct __posix_lock posix_lock_t;
58
struct __pl_inode_lock {
59
struct list_head list;
60
struct list_head blocked_locks; /* list_head pointing to blocked_inodelks */
68
struct flock user_flock; /* the flock supplied by the user */
69
xlator_t *this; /* required for blocked locks */
74
/* These two together serve to uniquely identify each process
77
transport_t *transport; /* to identify client node */
78
pid_t client_pid; /* pid of client process */
81
typedef struct __pl_inode_lock pl_inode_lock_t;
57
83
struct __pl_rw_req_t {
58
struct list_head list;
84
struct list_head list;
62
88
typedef struct __pl_rw_req_t pl_rw_req_t;
90
struct __pl_dom_list_t {
91
struct list_head inode_list; /* list_head back to pl_inode_t */
93
struct list_head entrylk_list; /* List of entry locks */
94
struct list_head blocked_entrylks; /* List of all blocked entrylks */
95
struct list_head inodelk_list; /* List of inode locks */
96
struct list_head blocked_inodelks; /* List of all blocked inodelks */
98
typedef struct __pl_dom_list_t pl_dom_list_t;
65
100
struct __entry_lock {
66
struct list_head inode_list; /* list_head back to pl_inode_t */
67
struct list_head blocked_locks; /* locks blocked due to this lock */
75
unsigned int read_count; /* number of read locks */
101
struct list_head domain_list; /* list_head back to pl_dom_list_t */
102
struct list_head blocked_locks; /* list_head back to blocked_entrylks */
109
const char *basename;
113
pid_t client_pid; /* pid of client process */
78
116
typedef struct __entry_lock pl_entry_lock_t;
81
/* The "simulated" inode. This contains a list of all the locks associated
119
/* The "simulated" inode. This contains a list of all the locks associated
84
122
struct __pl_inode {
85
pthread_mutex_t mutex;
123
pthread_mutex_t mutex;
87
struct list_head dir_list; /* list of entry locks */
88
struct list_head ext_list; /* list of fcntl locks */
89
struct list_head int_list; /* list of internal locks */
90
struct list_head rw_list; /* list of waiting r/w requests */
91
int mandatory; /* if mandatory locking is enabled */
125
struct list_head dom_list; /* list of domains */
126
struct list_head ext_list; /* list of fcntl locks */
127
struct list_head rw_list; /* list of waiting r/w requests */
128
int mandatory; /* if mandatory locking is enabled */
93
130
inode_t *refkeeper; /* hold refs on an inode while locks are
94
131
held to prevent pruning */
96
133
typedef struct __pl_inode pl_inode_t;
99
#define LOCKS_FOR_DOMAIN(inode,domain) (domain == GF_LOCK_POSIX \
100
? inode->fcntl_locks \
101
: inode->inodelk_locks)
104
gf_boolean_t nonblocking; /* whether O_NONBLOCK has been set */
137
gf_boolean_t nonblocking; /* whether O_NONBLOCK has been set */
106
139
typedef struct __pl_fd pl_fd_t;
110
gf_boolean_t mandatory; /* if mandatory locking is enabled */
143
gf_boolean_t mandatory; /* if mandatory locking is enabled */
111
144
gf_boolean_t trace; /* trace lock requests in and out */
112
145
} posix_locks_private_t;