From mboxrd@z Thu Jan 1 00:00:00 1970 From: "David M. Richter" Subject: [PATCH 2/4] leases: when unlocking, skip locking-related steps Date: Wed, 23 Apr 2008 16:29:00 -0400 Message-ID: <1208982542-18277-2-git-send-email-richterd@citi.umich.edu> References: <1208982542-18277-1-git-send-email-richterd@citi.umich.edu> Cc: linux-fsdevel@vger.kernel.org, "David M. Richter" To: Bruce Fields Return-path: Received: from citi.umich.edu ([141.211.133.111]:46112 "EHLO citi.umich.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753058AbYDWU3F (ORCPT ); Wed, 23 Apr 2008 16:29:05 -0400 In-Reply-To: <1208982542-18277-1-git-send-email-richterd@citi.umich.edu> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: In generic_setlease(), we don't need to allocate a new struct file_lock or check for readers or writers when called with F_UNLCK. Signed-off-by: David M. Richter --- fs/locks.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index b9f3a0b..da1d0dd 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1367,18 +1367,20 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp) lease = *flp; - error = -EAGAIN; - if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0)) - goto out; - if ((arg == F_WRLCK) - && ((atomic_read(&dentry->d_count) > 1) - || (atomic_read(&inode->i_count) > 1))) - goto out; + if (arg != F_UNLCK) { + error = -EAGAIN; + if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0)) + goto out; + if ((arg == F_WRLCK) + && ((atomic_read(&dentry->d_count) > 1) + || (atomic_read(&inode->i_count) > 1))) + goto out; - error = -ENOMEM; - new_fl = locks_alloc_lock(); - if (new_fl == NULL) - goto out; + error = -ENOMEM; + new_fl = locks_alloc_lock(); + if (new_fl == NULL) + goto out; + } /* * At this point, we know that if there is an exclusive -- 1.5.4