aboutsummaryrefslogtreecommitdiffstats
path: root/fs/locks.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-06-23 05:05:10 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:43:02 -0400
commit39005d022ad221b76dc2de0ac62ef475a796433b (patch)
treee0a36fec7076d48764f0588b9ce09ce8e9f067ff /fs/locks.c
parent0d9a490abe1f69fda220f7866f6f23af41daa128 (diff)
[PATCH] locks: don't do unnecessary allocations
posix_lock_file() always allocates new locks in advance, even if it's easy to determine that no allocations will be needed. Optimize these cases: - FL_ACCESS flag is set - Unlocking the whole range Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/locks.c')
-rw-r--r--fs/locks.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/locks.c b/fs/locks.c
index c5ac6b40e766..2344f241c687 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -794,7 +794,8 @@ out:
794static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request, struct file_lock *conflock) 794static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
795{ 795{
796 struct file_lock *fl; 796 struct file_lock *fl;
797 struct file_lock *new_fl, *new_fl2; 797 struct file_lock *new_fl = NULL;
798 struct file_lock *new_fl2 = NULL;
798 struct file_lock *left = NULL; 799 struct file_lock *left = NULL;
799 struct file_lock *right = NULL; 800 struct file_lock *right = NULL;
800 struct file_lock **before; 801 struct file_lock **before;
@@ -803,9 +804,15 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request
803 /* 804 /*
804 * We may need two file_lock structures for this operation, 805 * We may need two file_lock structures for this operation,
805 * so we get them in advance to avoid races. 806 * so we get them in advance to avoid races.
807 *
808 * In some cases we can be sure, that no new locks will be needed
806 */ 809 */
807 new_fl = locks_alloc_lock(); 810 if (!(request->fl_flags & FL_ACCESS) &&
808 new_fl2 = locks_alloc_lock(); 811 (request->fl_type != F_UNLCK ||
812 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
813 new_fl = locks_alloc_lock();
814 new_fl2 = locks_alloc_lock();
815 }
809 816
810 lock_kernel(); 817 lock_kernel();
811 if (request->fl_type != F_UNLCK) { 818 if (request->fl_type != F_UNLCK) {