diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/locks.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/fs/locks.c b/fs/locks.c index 2344f241c687..e588e1c265f7 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -1896,15 +1896,14 @@ out: | |||
1896 | */ | 1896 | */ |
1897 | void locks_remove_posix(struct file *filp, fl_owner_t owner) | 1897 | void locks_remove_posix(struct file *filp, fl_owner_t owner) |
1898 | { | 1898 | { |
1899 | struct file_lock lock, **before; | 1899 | struct file_lock lock; |
1900 | 1900 | ||
1901 | /* | 1901 | /* |
1902 | * If there are no locks held on this file, we don't need to call | 1902 | * If there are no locks held on this file, we don't need to call |
1903 | * posix_lock_file(). Another process could be setting a lock on this | 1903 | * posix_lock_file(). Another process could be setting a lock on this |
1904 | * file at the same time, but we wouldn't remove that lock anyway. | 1904 | * file at the same time, but we wouldn't remove that lock anyway. |
1905 | */ | 1905 | */ |
1906 | before = &filp->f_dentry->d_inode->i_flock; | 1906 | if (!filp->f_dentry->d_inode->i_flock) |
1907 | if (*before == NULL) | ||
1908 | return; | 1907 | return; |
1909 | 1908 | ||
1910 | lock.fl_type = F_UNLCK; | 1909 | lock.fl_type = F_UNLCK; |
@@ -1917,25 +1916,11 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner) | |||
1917 | lock.fl_ops = NULL; | 1916 | lock.fl_ops = NULL; |
1918 | lock.fl_lmops = NULL; | 1917 | lock.fl_lmops = NULL; |
1919 | 1918 | ||
1920 | if (filp->f_op && filp->f_op->lock != NULL) { | 1919 | if (filp->f_op && filp->f_op->lock != NULL) |
1921 | filp->f_op->lock(filp, F_SETLK, &lock); | 1920 | filp->f_op->lock(filp, F_SETLK, &lock); |
1922 | goto out; | 1921 | else |
1923 | } | 1922 | posix_lock_file(filp, &lock); |
1924 | 1923 | ||
1925 | /* Can't use posix_lock_file here; we need to remove it no matter | ||
1926 | * which pid we have. | ||
1927 | */ | ||
1928 | lock_kernel(); | ||
1929 | while (*before != NULL) { | ||
1930 | struct file_lock *fl = *before; | ||
1931 | if (IS_POSIX(fl) && posix_same_owner(fl, &lock)) { | ||
1932 | locks_delete_lock(before); | ||
1933 | continue; | ||
1934 | } | ||
1935 | before = &fl->fl_next; | ||
1936 | } | ||
1937 | unlock_kernel(); | ||
1938 | out: | ||
1939 | if (lock.fl_ops && lock.fl_ops->fl_release_private) | 1924 | if (lock.fl_ops && lock.fl_ops->fl_release_private) |
1940 | lock.fl_ops->fl_release_private(&lock); | 1925 | lock.fl_ops->fl_release_private(&lock); |
1941 | } | 1926 | } |