From 5ffa01badf7ef7bce95f1d82f2c5b023573764ed Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 23 Jun 2006 02:05:10 -0700 Subject: [PATCH] --- yaml --- r: 29029 b: refs/heads/master c: 39005d022ad221b76dc2de0ac62ef475a796433b h: refs/heads/master i: 29027: b223fcf992d17d7ad9f9e8ce364d6e21c16b09d6 v: v3 --- [refs] | 2 +- trunk/fs/locks.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index face490af5c2..f2243106ab2b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0d9a490abe1f69fda220f7866f6f23af41daa128 +refs/heads/master: 39005d022ad221b76dc2de0ac62ef475a796433b diff --git a/trunk/fs/locks.c b/trunk/fs/locks.c index c5ac6b40e766..2344f241c687 100644 --- a/trunk/fs/locks.c +++ b/trunk/fs/locks.c @@ -794,7 +794,8 @@ static int flock_lock_file(struct file *filp, struct file_lock *request) static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request, struct file_lock *conflock) { struct file_lock *fl; - struct file_lock *new_fl, *new_fl2; + struct file_lock *new_fl = NULL; + struct file_lock *new_fl2 = NULL; struct file_lock *left = NULL; struct file_lock *right = NULL; struct file_lock **before; @@ -803,9 +804,15 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request /* * We may need two file_lock structures for this operation, * so we get them in advance to avoid races. + * + * In some cases we can be sure, that no new locks will be needed */ - new_fl = locks_alloc_lock(); - new_fl2 = locks_alloc_lock(); + if (!(request->fl_flags & FL_ACCESS) && + (request->fl_type != F_UNLCK || + request->fl_start != 0 || request->fl_end != OFFSET_MAX)) { + new_fl = locks_alloc_lock(); + new_fl2 = locks_alloc_lock(); + } lock_kernel(); if (request->fl_type != F_UNLCK) {