diff options
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/fs/locks.c b/fs/locks.c index 13fc7a6d380a..e663aeac579e 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -135,7 +135,7 @@ | |||
135 | #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) | 135 | #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) |
136 | #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) | 136 | #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) |
137 | #define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG)) | 137 | #define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG)) |
138 | #define IS_FILE_PVT(fl) (fl->fl_flags & FL_FILE_PVT) | 138 | #define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) |
139 | 139 | ||
140 | static bool lease_breaking(struct file_lock *fl) | 140 | static bool lease_breaking(struct file_lock *fl) |
141 | { | 141 | { |
@@ -564,7 +564,7 @@ static void __locks_insert_block(struct file_lock *blocker, | |||
564 | BUG_ON(!list_empty(&waiter->fl_block)); | 564 | BUG_ON(!list_empty(&waiter->fl_block)); |
565 | waiter->fl_next = blocker; | 565 | waiter->fl_next = blocker; |
566 | list_add_tail(&waiter->fl_block, &blocker->fl_block); | 566 | list_add_tail(&waiter->fl_block, &blocker->fl_block); |
567 | if (IS_POSIX(blocker) && !IS_FILE_PVT(blocker)) | 567 | if (IS_POSIX(blocker) && !IS_OFDLCK(blocker)) |
568 | locks_insert_global_blocked(waiter); | 568 | locks_insert_global_blocked(waiter); |
569 | } | 569 | } |
570 | 570 | ||
@@ -759,12 +759,12 @@ EXPORT_SYMBOL(posix_test_lock); | |||
759 | * of tasks (such as posix threads) sharing the same open file table. | 759 | * of tasks (such as posix threads) sharing the same open file table. |
760 | * To handle those cases, we just bail out after a few iterations. | 760 | * To handle those cases, we just bail out after a few iterations. |
761 | * | 761 | * |
762 | * For FL_FILE_PVT locks, the owner is the filp, not the files_struct. | 762 | * For FL_OFDLCK locks, the owner is the filp, not the files_struct. |
763 | * Because the owner is not even nominally tied to a thread of | 763 | * Because the owner is not even nominally tied to a thread of |
764 | * execution, the deadlock detection below can't reasonably work well. Just | 764 | * execution, the deadlock detection below can't reasonably work well. Just |
765 | * skip it for those. | 765 | * skip it for those. |
766 | * | 766 | * |
767 | * In principle, we could do a more limited deadlock detection on FL_FILE_PVT | 767 | * In principle, we could do a more limited deadlock detection on FL_OFDLCK |
768 | * locks that just checks for the case where two tasks are attempting to | 768 | * locks that just checks for the case where two tasks are attempting to |
769 | * upgrade from read to write locks on the same inode. | 769 | * upgrade from read to write locks on the same inode. |
770 | */ | 770 | */ |
@@ -791,9 +791,9 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, | |||
791 | 791 | ||
792 | /* | 792 | /* |
793 | * This deadlock detector can't reasonably detect deadlocks with | 793 | * This deadlock detector can't reasonably detect deadlocks with |
794 | * FL_FILE_PVT locks, since they aren't owned by a process, per-se. | 794 | * FL_OFDLCK locks, since they aren't owned by a process, per-se. |
795 | */ | 795 | */ |
796 | if (IS_FILE_PVT(caller_fl)) | 796 | if (IS_OFDLCK(caller_fl)) |
797 | return 0; | 797 | return 0; |
798 | 798 | ||
799 | while ((block_fl = what_owner_is_waiting_for(block_fl))) { | 799 | while ((block_fl = what_owner_is_waiting_for(block_fl))) { |
@@ -1391,11 +1391,10 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) | |||
1391 | 1391 | ||
1392 | restart: | 1392 | restart: |
1393 | break_time = flock->fl_break_time; | 1393 | break_time = flock->fl_break_time; |
1394 | if (break_time != 0) { | 1394 | if (break_time != 0) |
1395 | break_time -= jiffies; | 1395 | break_time -= jiffies; |
1396 | if (break_time == 0) | 1396 | if (break_time == 0) |
1397 | break_time++; | 1397 | break_time++; |
1398 | } | ||
1399 | locks_insert_block(flock, new_fl); | 1398 | locks_insert_block(flock, new_fl); |
1400 | spin_unlock(&inode->i_lock); | 1399 | spin_unlock(&inode->i_lock); |
1401 | error = wait_event_interruptible_timeout(new_fl->fl_wait, | 1400 | error = wait_event_interruptible_timeout(new_fl->fl_wait, |
@@ -1891,7 +1890,7 @@ EXPORT_SYMBOL_GPL(vfs_test_lock); | |||
1891 | 1890 | ||
1892 | static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) | 1891 | static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) |
1893 | { | 1892 | { |
1894 | flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid; | 1893 | flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; |
1895 | #if BITS_PER_LONG == 32 | 1894 | #if BITS_PER_LONG == 32 |
1896 | /* | 1895 | /* |
1897 | * Make sure we can represent the posix lock via | 1896 | * Make sure we can represent the posix lock via |
@@ -1913,7 +1912,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) | |||
1913 | #if BITS_PER_LONG == 32 | 1912 | #if BITS_PER_LONG == 32 |
1914 | static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) | 1913 | static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) |
1915 | { | 1914 | { |
1916 | flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid; | 1915 | flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; |
1917 | flock->l_start = fl->fl_start; | 1916 | flock->l_start = fl->fl_start; |
1918 | flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : | 1917 | flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : |
1919 | fl->fl_end - fl->fl_start + 1; | 1918 | fl->fl_end - fl->fl_start + 1; |
@@ -1942,13 +1941,13 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l) | |||
1942 | if (error) | 1941 | if (error) |
1943 | goto out; | 1942 | goto out; |
1944 | 1943 | ||
1945 | if (cmd == F_GETLKP) { | 1944 | if (cmd == F_OFD_GETLK) { |
1946 | error = -EINVAL; | 1945 | error = -EINVAL; |
1947 | if (flock.l_pid != 0) | 1946 | if (flock.l_pid != 0) |
1948 | goto out; | 1947 | goto out; |
1949 | 1948 | ||
1950 | cmd = F_GETLK; | 1949 | cmd = F_GETLK; |
1951 | file_lock.fl_flags |= FL_FILE_PVT; | 1950 | file_lock.fl_flags |= FL_OFDLCK; |
1952 | file_lock.fl_owner = (fl_owner_t)filp; | 1951 | file_lock.fl_owner = (fl_owner_t)filp; |
1953 | } | 1952 | } |
1954 | 1953 | ||
@@ -2074,25 +2073,25 @@ again: | |||
2074 | 2073 | ||
2075 | /* | 2074 | /* |
2076 | * If the cmd is requesting file-private locks, then set the | 2075 | * If the cmd is requesting file-private locks, then set the |
2077 | * FL_FILE_PVT flag and override the owner. | 2076 | * FL_OFDLCK flag and override the owner. |
2078 | */ | 2077 | */ |
2079 | switch (cmd) { | 2078 | switch (cmd) { |
2080 | case F_SETLKP: | 2079 | case F_OFD_SETLK: |
2081 | error = -EINVAL; | 2080 | error = -EINVAL; |
2082 | if (flock.l_pid != 0) | 2081 | if (flock.l_pid != 0) |
2083 | goto out; | 2082 | goto out; |
2084 | 2083 | ||
2085 | cmd = F_SETLK; | 2084 | cmd = F_SETLK; |
2086 | file_lock->fl_flags |= FL_FILE_PVT; | 2085 | file_lock->fl_flags |= FL_OFDLCK; |
2087 | file_lock->fl_owner = (fl_owner_t)filp; | 2086 | file_lock->fl_owner = (fl_owner_t)filp; |
2088 | break; | 2087 | break; |
2089 | case F_SETLKPW: | 2088 | case F_OFD_SETLKW: |
2090 | error = -EINVAL; | 2089 | error = -EINVAL; |
2091 | if (flock.l_pid != 0) | 2090 | if (flock.l_pid != 0) |
2092 | goto out; | 2091 | goto out; |
2093 | 2092 | ||
2094 | cmd = F_SETLKW; | 2093 | cmd = F_SETLKW; |
2095 | file_lock->fl_flags |= FL_FILE_PVT; | 2094 | file_lock->fl_flags |= FL_OFDLCK; |
2096 | file_lock->fl_owner = (fl_owner_t)filp; | 2095 | file_lock->fl_owner = (fl_owner_t)filp; |
2097 | /* Fallthrough */ | 2096 | /* Fallthrough */ |
2098 | case F_SETLKW: | 2097 | case F_SETLKW: |
@@ -2144,13 +2143,13 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l) | |||
2144 | if (error) | 2143 | if (error) |
2145 | goto out; | 2144 | goto out; |
2146 | 2145 | ||
2147 | if (cmd == F_GETLKP) { | 2146 | if (cmd == F_OFD_GETLK) { |
2148 | error = -EINVAL; | 2147 | error = -EINVAL; |
2149 | if (flock.l_pid != 0) | 2148 | if (flock.l_pid != 0) |
2150 | goto out; | 2149 | goto out; |
2151 | 2150 | ||
2152 | cmd = F_GETLK64; | 2151 | cmd = F_GETLK64; |
2153 | file_lock.fl_flags |= FL_FILE_PVT; | 2152 | file_lock.fl_flags |= FL_OFDLCK; |
2154 | file_lock.fl_owner = (fl_owner_t)filp; | 2153 | file_lock.fl_owner = (fl_owner_t)filp; |
2155 | } | 2154 | } |
2156 | 2155 | ||
@@ -2209,25 +2208,25 @@ again: | |||
2209 | 2208 | ||
2210 | /* | 2209 | /* |
2211 | * If the cmd is requesting file-private locks, then set the | 2210 | * If the cmd is requesting file-private locks, then set the |
2212 | * FL_FILE_PVT flag and override the owner. | 2211 | * FL_OFDLCK flag and override the owner. |
2213 | */ | 2212 | */ |
2214 | switch (cmd) { | 2213 | switch (cmd) { |
2215 | case F_SETLKP: | 2214 | case F_OFD_SETLK: |
2216 | error = -EINVAL; | 2215 | error = -EINVAL; |
2217 | if (flock.l_pid != 0) | 2216 | if (flock.l_pid != 0) |
2218 | goto out; | 2217 | goto out; |
2219 | 2218 | ||
2220 | cmd = F_SETLK64; | 2219 | cmd = F_SETLK64; |
2221 | file_lock->fl_flags |= FL_FILE_PVT; | 2220 | file_lock->fl_flags |= FL_OFDLCK; |
2222 | file_lock->fl_owner = (fl_owner_t)filp; | 2221 | file_lock->fl_owner = (fl_owner_t)filp; |
2223 | break; | 2222 | break; |
2224 | case F_SETLKPW: | 2223 | case F_OFD_SETLKW: |
2225 | error = -EINVAL; | 2224 | error = -EINVAL; |
2226 | if (flock.l_pid != 0) | 2225 | if (flock.l_pid != 0) |
2227 | goto out; | 2226 | goto out; |
2228 | 2227 | ||
2229 | cmd = F_SETLKW64; | 2228 | cmd = F_SETLKW64; |
2230 | file_lock->fl_flags |= FL_FILE_PVT; | 2229 | file_lock->fl_flags |= FL_OFDLCK; |
2231 | file_lock->fl_owner = (fl_owner_t)filp; | 2230 | file_lock->fl_owner = (fl_owner_t)filp; |
2232 | /* Fallthrough */ | 2231 | /* Fallthrough */ |
2233 | case F_SETLKW64: | 2232 | case F_SETLKW64: |
@@ -2413,8 +2412,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, | |||
2413 | if (IS_POSIX(fl)) { | 2412 | if (IS_POSIX(fl)) { |
2414 | if (fl->fl_flags & FL_ACCESS) | 2413 | if (fl->fl_flags & FL_ACCESS) |
2415 | seq_printf(f, "ACCESS"); | 2414 | seq_printf(f, "ACCESS"); |
2416 | else if (IS_FILE_PVT(fl)) | 2415 | else if (IS_OFDLCK(fl)) |
2417 | seq_printf(f, "FLPVT "); | 2416 | seq_printf(f, "OFDLCK"); |
2418 | else | 2417 | else |
2419 | seq_printf(f, "POSIX "); | 2418 | seq_printf(f, "POSIX "); |
2420 | 2419 | ||