diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-12-23 02:41:14 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-12-23 02:41:14 -0500 |
commit | cfb13c5db08c90311a5defdde9a0328ee788cca5 (patch) | |
tree | 842cb60d1d19b99e550fdbc653723e4b13e51ee5 /fs/locks.c | |
parent | 4b6ba8aacbb3185703b797286547d0f8f3859b02 (diff) | |
parent | 90a8a73c06cc32b609a880d48449d7083327e11a (diff) |
Merge commit 'v2.6.37-rc7' into devicetree/next
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/fs/locks.c b/fs/locks.c index 5b526a977882..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> |
@@ -235,11 +234,8 @@ static void locks_copy_private(struct file_lock *new, struct file_lock *fl) | |||
235 | fl->fl_ops->fl_copy_lock(new, fl); | 234 | fl->fl_ops->fl_copy_lock(new, fl); |
236 | new->fl_ops = fl->fl_ops; | 235 | new->fl_ops = fl->fl_ops; |
237 | } | 236 | } |
238 | if (fl->fl_lmops) { | 237 | if (fl->fl_lmops) |
239 | if (fl->fl_lmops->fl_copy_lock) | ||
240 | fl->fl_lmops->fl_copy_lock(new, fl); | ||
241 | new->fl_lmops = fl->fl_lmops; | 238 | new->fl_lmops = fl->fl_lmops; |
242 | } | ||
243 | } | 239 | } |
244 | 240 | ||
245 | /* | 241 | /* |
@@ -1428,8 +1424,9 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp) | |||
1428 | goto out; | 1424 | goto out; |
1429 | 1425 | ||
1430 | if (my_before != NULL) { | 1426 | if (my_before != NULL) { |
1431 | *flp = *my_before; | ||
1432 | error = lease->fl_lmops->fl_change(my_before, arg); | 1427 | error = lease->fl_lmops->fl_change(my_before, arg); |
1428 | if (!error) | ||
1429 | *flp = *my_before; | ||
1433 | goto out; | 1430 | goto out; |
1434 | } | 1431 | } |
1435 | 1432 | ||
@@ -1444,8 +1441,6 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp) | |||
1444 | return 0; | 1441 | return 0; |
1445 | 1442 | ||
1446 | out: | 1443 | out: |
1447 | if (arg != F_UNLCK) | ||
1448 | locks_free_lock(lease); | ||
1449 | return error; | 1444 | return error; |
1450 | } | 1445 | } |
1451 | EXPORT_SYMBOL(generic_setlease); | 1446 | EXPORT_SYMBOL(generic_setlease); |
@@ -1508,9 +1503,8 @@ static int do_fcntl_delete_lease(struct file *filp) | |||
1508 | 1503 | ||
1509 | 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) |
1510 | { | 1505 | { |
1511 | struct file_lock *fl; | 1506 | struct file_lock *fl, *ret; |
1512 | struct fasync_struct *new; | 1507 | struct fasync_struct *new; |
1513 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
1514 | int error; | 1508 | int error; |
1515 | 1509 | ||
1516 | fl = lease_alloc(filp, arg); | 1510 | fl = lease_alloc(filp, arg); |
@@ -1522,10 +1516,16 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) | |||
1522 | locks_free_lock(fl); | 1516 | locks_free_lock(fl); |
1523 | return -ENOMEM; | 1517 | return -ENOMEM; |
1524 | } | 1518 | } |
1519 | ret = fl; | ||
1525 | lock_flocks(); | 1520 | lock_flocks(); |
1526 | error = __vfs_setlease(filp, arg, &fl); | 1521 | error = __vfs_setlease(filp, arg, &ret); |
1527 | if (error) | 1522 | if (error) { |
1528 | goto out_unlock; | 1523 | unlock_flocks(); |
1524 | locks_free_lock(fl); | ||
1525 | goto out_free_fasync; | ||
1526 | } | ||
1527 | if (ret != fl) | ||
1528 | locks_free_lock(fl); | ||
1529 | 1529 | ||
1530 | /* | 1530 | /* |
1531 | * fasync_insert_entry() returns the old entry if any. | 1531 | * fasync_insert_entry() returns the old entry if any. |
@@ -1533,20 +1533,13 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) | |||
1533 | * inserted it into the fasync list. Clear new so that | 1533 | * inserted it into the fasync list. Clear new so that |
1534 | * we don't release it here. | 1534 | * we don't release it here. |
1535 | */ | 1535 | */ |
1536 | if (!fasync_insert_entry(fd, filp, &fl->fl_fasync, new)) | 1536 | if (!fasync_insert_entry(fd, filp, &ret->fl_fasync, new)) |
1537 | new = NULL; | 1537 | new = NULL; |
1538 | 1538 | ||
1539 | if (error < 0) { | ||
1540 | /* remove lease just inserted by setlease */ | ||
1541 | fl->fl_type = F_UNLCK | F_INPROGRESS; | ||
1542 | fl->fl_break_time = jiffies - 10; | ||
1543 | time_out_leases(inode); | ||
1544 | goto out_unlock; | ||
1545 | } | ||
1546 | |||
1547 | error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); | 1539 | error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); |
1548 | out_unlock: | ||
1549 | unlock_flocks(); | 1540 | unlock_flocks(); |
1541 | |||
1542 | out_free_fasync: | ||
1550 | if (new) | 1543 | if (new) |
1551 | fasync_free(new); | 1544 | fasync_free(new); |
1552 | return error; | 1545 | return error; |