linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "David M. Richter" <richterd@citi.umich.edu>
To: Bruce Fields <bfields@citi.umich.edu>
Cc: linux-fsdevel@vger.kernel.org,
	"David M. Richter" <richterd@citi.umich.edu>
Subject: [PATCH 2/4] leases: when unlocking, skip locking-related steps
Date: Wed, 23 Apr 2008 16:29:00 -0400	[thread overview]
Message-ID: <1208982542-18277-2-git-send-email-richterd@citi.umich.edu> (raw)
In-Reply-To: <1208982542-18277-1-git-send-email-richterd@citi.umich.edu>

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 <richterd@citi.umich.edu>
---
 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


  reply	other threads:[~2008-04-23 20:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-23 20:28 [PATCH 1/4] leases: fix a return-value mixup David M. Richter
2008-04-23 20:29 ` David M. Richter [this message]
2008-04-23 20:29   ` [PATCH 3/4] leases: move lock allocation earlier in generic_setlease() David M. Richter
2008-04-23 20:29     ` [PATCH 4/4] leases: remove unneeded variable from fcntl_setlease() David M. Richter
2008-04-23 22:52       ` J. Bruce Fields
2008-04-24 14:32   ` [PATCH 2/4] leases: when unlocking, skip locking-related steps Chuck Lever
2008-04-24 20:41     ` J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1208982542-18277-2-git-send-email-richterd@citi.umich.edu \
    --to=richterd@citi.umich.edu \
    --cc=bfields@citi.umich.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).