Contents of /trunk/kernel26-magellan-server/patches-2.6.25-r5/0101-2.6.25.2-all-fixes.patch
Parent Directory | Revision Log
Revision 677 -
(show annotations)
(download)
Wed Sep 10 21:27:27 2008 UTC (16 years ago) by niro
File size: 1594 byte(s)
Wed Sep 10 21:27:27 2008 UTC (16 years ago) by niro
File size: 1594 byte(s)
2.6.25-magellan-r5: - updated to linux-2.6.25.17
1 | diff --git a/fs/locks.c b/fs/locks.c |
2 | index 43c0af2..159e0f6 100644 |
3 | --- a/fs/locks.c |
4 | +++ b/fs/locks.c |
5 | @@ -1750,6 +1750,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, |
6 | struct file_lock *file_lock = locks_alloc_lock(); |
7 | struct flock flock; |
8 | struct inode *inode; |
9 | + struct file *f; |
10 | int error; |
11 | |
12 | if (file_lock == NULL) |
13 | @@ -1822,7 +1823,15 @@ again: |
14 | * Attempt to detect a close/fcntl race and recover by |
15 | * releasing the lock that was just acquired. |
16 | */ |
17 | - if (!error && fcheck(fd) != filp && flock.l_type != F_UNLCK) { |
18 | + /* |
19 | + * we need that spin_lock here - it prevents reordering between |
20 | + * update of inode->i_flock and check for it done in close(). |
21 | + * rcu_read_lock() wouldn't do. |
22 | + */ |
23 | + spin_lock(¤t->files->file_lock); |
24 | + f = fcheck(fd); |
25 | + spin_unlock(¤t->files->file_lock); |
26 | + if (!error && f != filp && flock.l_type != F_UNLCK) { |
27 | flock.l_type = F_UNLCK; |
28 | goto again; |
29 | } |
30 | @@ -1878,6 +1887,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, |
31 | struct file_lock *file_lock = locks_alloc_lock(); |
32 | struct flock64 flock; |
33 | struct inode *inode; |
34 | + struct file *f; |
35 | int error; |
36 | |
37 | if (file_lock == NULL) |
38 | @@ -1950,7 +1960,10 @@ again: |
39 | * Attempt to detect a close/fcntl race and recover by |
40 | * releasing the lock that was just acquired. |
41 | */ |
42 | - if (!error && fcheck(fd) != filp && flock.l_type != F_UNLCK) { |
43 | + spin_lock(¤t->files->file_lock); |
44 | + f = fcheck(fd); |
45 | + spin_unlock(¤t->files->file_lock); |
46 | + if (!error && f != filp && flock.l_type != F_UNLCK) { |
47 | flock.l_type = F_UNLCK; |
48 | goto again; |
49 | } |