~ubuntu-branches/ubuntu/trusty/glusterfs/trusty

« back to all changes in this revision

Viewing changes to xlators/features/locks/src/locks.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2010-02-09 18:53:10 UTC
  • mfrom: (1.2.4 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100209185310-ww8p82lsbosorg2u
* New upstream release.
* Uploading to unstable.
* Bump Standards-Version to 3.8.4 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
   Copyright (c) 2006, 2007, 2008 Gluster, Inc. <http://www.gluster.com>
3
 
   This file is part of GlusterFS.
4
 
 
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.
9
 
 
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.
14
 
 
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.
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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/>.
18
18
*/
19
19
 
20
20
#ifndef __POSIX_LOCKS_H__
33
33
struct __pl_fd;
34
34
 
35
35
struct __posix_lock {
36
 
        struct list_head   list;
37
 
 
38
 
        short              fl_type;
39
 
        off_t              fl_start;
40
 
        off_t              fl_end;
41
 
 
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 */
45
 
        fd_t              *fd;
46
 
 
47
 
        call_frame_t      *frame;
48
 
 
49
 
        /* These two together serve to uniquely identify each process
50
 
           across nodes */
51
 
 
52
 
        transport_t       *transport;     /* to identify client node */
53
 
        pid_t              client_pid;    /* pid of client process */
 
36
        struct list_head   list;
 
37
 
 
38
        short              fl_type;
 
39
        off_t              fl_start;
 
40
        off_t              fl_end;
 
41
 
 
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 */
 
45
        unsigned long      fd_num;
 
46
 
 
47
        call_frame_t      *frame;
 
48
 
 
49
        /* These two together serve to uniquely identify each process
 
50
           across nodes */
 
51
 
 
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 */
54
55
};
55
56
typedef struct __posix_lock posix_lock_t;
56
57
 
 
58
struct __pl_inode_lock {
 
59
        struct list_head   list;
 
60
        struct list_head   blocked_locks; /* list_head pointing to blocked_inodelks */
 
61
 
 
62
        short              fl_type;
 
63
        off_t              fl_start;
 
64
        off_t              fl_end;
 
65
 
 
66
        const char        *volume;
 
67
 
 
68
        struct flock       user_flock; /* the flock supplied by the user */
 
69
        xlator_t          *this;       /* required for blocked locks */
 
70
        fd_t              *fd;
 
71
 
 
72
        call_frame_t      *frame;
 
73
 
 
74
        /* These two together serve to uniquely identify each process
 
75
           across nodes */
 
76
 
 
77
        transport_t       *transport;     /* to identify client node */
 
78
        pid_t              client_pid;    /* pid of client process */
 
79
        uint64_t           owner;
 
80
};
 
81
typedef struct __pl_inode_lock pl_inode_lock_t;
 
82
 
57
83
struct __pl_rw_req_t {
58
 
        struct list_head      list;
59
 
        call_stub_t          *stub;
60
 
        posix_lock_t          region;
 
84
        struct list_head      list;
 
85
        call_stub_t          *stub;
 
86
        posix_lock_t          region;
61
87
};
62
88
typedef struct __pl_rw_req_t pl_rw_req_t;
63
89
 
 
90
struct __pl_dom_list_t {
 
91
        struct list_head   inode_list;       /* list_head back to pl_inode_t */
 
92
        const char        *domain;
 
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 */
 
97
};
 
98
typedef struct __pl_dom_list_t pl_dom_list_t;
64
99
 
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 */
68
 
 
69
 
        call_frame_t     *frame;
70
 
        xlator_t         *this;
71
 
        int               blocked;
72
 
        
73
 
        const char       *basename;
74
 
        entrylk_type      type;
75
 
        unsigned int      read_count;    /* number of read locks */
76
 
        transport_t      *trans;
 
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 */
 
103
 
 
104
        call_frame_t     *frame;
 
105
        xlator_t         *this;
 
106
 
 
107
        const char       *volume;
 
108
 
 
109
        const char       *basename;
 
110
        entrylk_type      type;
 
111
 
 
112
        transport_t      *trans;
 
113
        pid_t             client_pid;    /* pid of client process */
 
114
        uint64_t          owner;
77
115
};
78
116
typedef struct __entry_lock pl_entry_lock_t;
79
117
 
80
118
 
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
82
120
   with this file */
83
121
 
84
122
struct __pl_inode {
85
 
        pthread_mutex_t  mutex;
 
123
        pthread_mutex_t  mutex;
86
124
 
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 */
92
129
 
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;
97
134
 
98
135
 
99
 
#define LOCKS_FOR_DOMAIN(inode,domain) (domain == GF_LOCK_POSIX \
100
 
                                        ? inode->fcntl_locks    \
101
 
                                        : inode->inodelk_locks)
102
 
 
103
136
struct __pl_fd {
104
 
        gf_boolean_t nonblocking;       /* whether O_NONBLOCK has been set */
 
137
        gf_boolean_t nonblocking;       /* whether O_NONBLOCK has been set */
105
138
};
106
139
typedef struct __pl_fd pl_fd_t;
107
140
 
108
141
 
109
142
typedef struct {
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;
113
146