diff options
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/fs/locks.c b/fs/locks.c index 65765cb6afed..8729347bcd1a 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -122,7 +122,6 @@ | |||
122 | #include <linux/module.h> | 122 | #include <linux/module.h> |
123 | #include <linux/security.h> | 123 | #include <linux/security.h> |
124 | #include <linux/slab.h> | 124 | #include <linux/slab.h> |
125 | #include <linux/smp_lock.h> | ||
126 | #include <linux/syscalls.h> | 125 | #include <linux/syscalls.h> |
127 | #include <linux/time.h> | 126 | #include <linux/time.h> |
128 | #include <linux/rcupdate.h> | 127 | #include <linux/rcupdate.h> |
@@ -1504,9 +1503,8 @@ static int do_fcntl_delete_lease(struct file *filp) | |||
1504 | 1503 | ||
1505 | static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) | 1504 | static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) |
1506 | { | 1505 | { |
1507 | struct file_lock *fl; | 1506 | struct file_lock *fl, *ret; |
1508 | struct fasync_struct *new; | 1507 | struct fasync_struct *new; |
1509 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
1510 | int error; | 1508 | int error; |
1511 | 1509 | ||
1512 | fl = lease_alloc(filp, arg); | 1510 | fl = lease_alloc(filp, arg); |
@@ -1518,13 +1516,16 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) | |||
1518 | locks_free_lock(fl); | 1516 | locks_free_lock(fl); |
1519 | return -ENOMEM; | 1517 | return -ENOMEM; |
1520 | } | 1518 | } |
1519 | ret = fl; | ||
1521 | lock_flocks(); | 1520 | lock_flocks(); |
1522 | error = __vfs_setlease(filp, arg, &fl); | 1521 | error = __vfs_setlease(filp, arg, &ret); |
1523 | if (error) { | 1522 | if (error) { |
1524 | unlock_flocks(); | 1523 | unlock_flocks(); |
1525 | locks_free_lock(fl); | 1524 | locks_free_lock(fl); |
1526 | goto out_free_fasync; | 1525 | goto out_free_fasync; |
1527 | } | 1526 | } |
1527 | if (ret != fl) | ||
1528 | locks_free_lock(fl); | ||
1528 | 1529 | ||
1529 | /* | 1530 | /* |
1530 | * fasync_insert_entry() returns the old entry if any. | 1531 | * fasync_insert_entry() returns the old entry if any. |
@@ -1532,17 +1533,10 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) | |||
1532 | * inserted it into the fasync list. Clear new so that | 1533 | * inserted it into the fasync list. Clear new so that |
1533 | * we don't release it here. | 1534 | * we don't release it here. |
1534 | */ | 1535 | */ |
1535 | if (!fasync_insert_entry(fd, filp, &fl->fl_fasync, new)) | 1536 | if (!fasync_insert_entry(fd, filp, &ret->fl_fasync, new)) |
1536 | new = NULL; | 1537 | new = NULL; |
1537 | 1538 | ||
1538 | if (error < 0) { | 1539 | error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); |
1539 | /* remove lease just inserted by setlease */ | ||
1540 | fl->fl_type = F_UNLCK | F_INPROGRESS; | ||
1541 | fl->fl_break_time = jiffies - 10; | ||
1542 | time_out_leases(inode); | ||
1543 | } else { | ||
1544 | error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); | ||
1545 | } | ||
1546 | unlock_flocks(); | 1540 | unlock_flocks(); |
1547 | 1541 | ||
1548 | out_free_fasync: | 1542 | out_free_fasync: |