diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-20 13:44:05 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-20 13:44:05 -0500 |
commit | 47831f35b83e43c804215712dd0c834c92e8a441 (patch) | |
tree | 3345007cf56b73495386a59deb6e3d7caf01f875 | |
parent | 1dd594b21b2d98e56f2b1fe92bb222276b28de41 (diff) |
VFS: Fix __posix_lock_file() copy of private lock area
The struct file_lock->fl_u area must be copied using the fl_copy_lock()
operation.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/locks.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/fs/locks.c b/fs/locks.c index 909eab8fb1d0..d2c5306e3db0 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -153,6 +153,21 @@ static struct file_lock *locks_alloc_lock(void) | |||
153 | return kmem_cache_alloc(filelock_cache, SLAB_KERNEL); | 153 | return kmem_cache_alloc(filelock_cache, SLAB_KERNEL); |
154 | } | 154 | } |
155 | 155 | ||
156 | static void locks_release_private(struct file_lock *fl) | ||
157 | { | ||
158 | if (fl->fl_ops) { | ||
159 | if (fl->fl_ops->fl_release_private) | ||
160 | fl->fl_ops->fl_release_private(fl); | ||
161 | fl->fl_ops = NULL; | ||
162 | } | ||
163 | if (fl->fl_lmops) { | ||
164 | if (fl->fl_lmops->fl_release_private) | ||
165 | fl->fl_lmops->fl_release_private(fl); | ||
166 | fl->fl_lmops = NULL; | ||
167 | } | ||
168 | |||
169 | } | ||
170 | |||
156 | /* Free a lock which is not in use. */ | 171 | /* Free a lock which is not in use. */ |
157 | static void locks_free_lock(struct file_lock *fl) | 172 | static void locks_free_lock(struct file_lock *fl) |
158 | { | 173 | { |
@@ -169,18 +184,7 @@ static void locks_free_lock(struct file_lock *fl) | |||
169 | if (!list_empty(&fl->fl_link)) | 184 | if (!list_empty(&fl->fl_link)) |
170 | panic("Attempting to free lock on active lock list"); | 185 | panic("Attempting to free lock on active lock list"); |
171 | 186 | ||
172 | if (fl->fl_ops) { | 187 | locks_release_private(fl); |
173 | if (fl->fl_ops->fl_release_private) | ||
174 | fl->fl_ops->fl_release_private(fl); | ||
175 | fl->fl_ops = NULL; | ||
176 | } | ||
177 | |||
178 | if (fl->fl_lmops) { | ||
179 | if (fl->fl_lmops->fl_release_private) | ||
180 | fl->fl_lmops->fl_release_private(fl); | ||
181 | fl->fl_lmops = NULL; | ||
182 | } | ||
183 | |||
184 | kmem_cache_free(filelock_cache, fl); | 188 | kmem_cache_free(filelock_cache, fl); |
185 | } | 189 | } |
186 | 190 | ||
@@ -218,11 +222,27 @@ static void init_once(void *foo, kmem_cache_t *cache, unsigned long flags) | |||
218 | locks_init_lock(lock); | 222 | locks_init_lock(lock); |
219 | } | 223 | } |
220 | 224 | ||
225 | static void locks_copy_private(struct file_lock *new, struct file_lock *fl) | ||
226 | { | ||
227 | if (fl->fl_ops) { | ||
228 | if (fl->fl_ops->fl_copy_lock) | ||
229 | fl->fl_ops->fl_copy_lock(new, fl); | ||
230 | new->fl_ops = fl->fl_ops; | ||
231 | } | ||
232 | if (fl->fl_lmops) { | ||
233 | if (fl->fl_lmops->fl_copy_lock) | ||
234 | fl->fl_lmops->fl_copy_lock(new, fl); | ||
235 | new->fl_lmops = fl->fl_lmops; | ||
236 | } | ||
237 | } | ||
238 | |||
221 | /* | 239 | /* |
222 | * Initialize a new lock from an existing file_lock structure. | 240 | * Initialize a new lock from an existing file_lock structure. |
223 | */ | 241 | */ |
224 | void locks_copy_lock(struct file_lock *new, struct file_lock *fl) | 242 | void locks_copy_lock(struct file_lock *new, struct file_lock *fl) |
225 | { | 243 | { |
244 | locks_release_private(new); | ||
245 | |||
226 | new->fl_owner = fl->fl_owner; | 246 | new->fl_owner = fl->fl_owner; |
227 | new->fl_pid = fl->fl_pid; | 247 | new->fl_pid = fl->fl_pid; |
228 | new->fl_file = fl->fl_file; | 248 | new->fl_file = fl->fl_file; |
@@ -232,10 +252,8 @@ void locks_copy_lock(struct file_lock *new, struct file_lock *fl) | |||
232 | new->fl_end = fl->fl_end; | 252 | new->fl_end = fl->fl_end; |
233 | new->fl_ops = fl->fl_ops; | 253 | new->fl_ops = fl->fl_ops; |
234 | new->fl_lmops = fl->fl_lmops; | 254 | new->fl_lmops = fl->fl_lmops; |
235 | if (fl->fl_ops && fl->fl_ops->fl_copy_lock) | 255 | |
236 | fl->fl_ops->fl_copy_lock(new, fl); | 256 | locks_copy_private(new, fl); |
237 | if (fl->fl_lmops && fl->fl_lmops->fl_copy_lock) | ||
238 | fl->fl_lmops->fl_copy_lock(new, fl); | ||
239 | } | 257 | } |
240 | 258 | ||
241 | EXPORT_SYMBOL(locks_copy_lock); | 259 | EXPORT_SYMBOL(locks_copy_lock); |
@@ -904,7 +922,8 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request) | |||
904 | fl->fl_start = request->fl_start; | 922 | fl->fl_start = request->fl_start; |
905 | fl->fl_end = request->fl_end; | 923 | fl->fl_end = request->fl_end; |
906 | fl->fl_type = request->fl_type; | 924 | fl->fl_type = request->fl_type; |
907 | fl->fl_u = request->fl_u; | 925 | locks_release_private(fl); |
926 | locks_copy_private(fl, request); | ||
908 | request = fl; | 927 | request = fl; |
909 | added = 1; | 928 | added = 1; |
910 | } | 929 | } |