linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Bryan Schumaker <bjschuma@netapp.com>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] locks: let the caller free file_lock on ->setlease failure
Date: Wed, 3 Nov 2010 21:41:28 -0400	[thread overview]
Message-ID: <20101104014128.GB22498@fieldses.org> (raw)
In-Reply-To: <20101104014024.GA22498@fieldses.org>

On Wed, Nov 03, 2010 at 09:40:24PM -0400, J. Bruce Fields wrote:
> On Wed, Nov 03, 2010 at 04:41:48PM -0400, J. Bruce Fields wrote:
> > On Sun, Oct 31, 2010 at 08:35:10AM -0400, Christoph Hellwig wrote:
> > > Index: linux-2.6/fs/locks.c
> > > ===================================================================
> > > --- linux-2.6.orig/fs/locks.c	2010-10-31 07:10:07.649004084 -0400
> > > +++ linux-2.6/fs/locks.c	2010-10-31 07:34:10.102255587 -0400
> > > @@ -1428,8 +1425,9 @@ int generic_setlease(struct file *filp,
> > >  		goto out;
> > >  
> > >  	if (my_before != NULL) {
> > > -		*flp = *my_before;
> > >  		error = lease->fl_lmops->fl_change(my_before, arg);
> > > +		if (!error)
> > > +			*flp = *my_before;
> > 
> > Argh, missed this: we're leaking the passed-in lease in this case.
> 
> We could do something like this.

And while I was here I noticed:

--b.

>From 072be1f975c6f839661cfc4f6c45ccb944417eea Mon Sep 17 00:00:00 2001
From: J. Bruce Fields <bfields@redhat.com>
Date: Wed, 3 Nov 2010 18:09:18 -0400
Subject: [PATCH 2/2] locks: remove dead lease error-handling code

A minor oversight from f7347ce4ee7c65415f84be915c018473e7076f31,
"fasync: re-organize fasync entry insertion to allow it under a
spinlock": this cleanup-on-error was only needed to handle -ENOMEM.  Now
that we're preallocating it's unneeded.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/locks.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 61c22f7..0e62dd3 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1506,7 +1506,6 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
 {
 	struct file_lock *fl, *ret;
 	struct fasync_struct *new;
-	struct inode *inode = filp->f_path.dentry->d_inode;
 	int error;
 
 	fl = lease_alloc(filp, arg);
@@ -1520,7 +1519,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
 	}
 	ret = fl;
 	lock_flocks();
-	error = __vfs_setlease(filp, arg, &fl);
+	error = __vfs_setlease(filp, arg, &ret);
 	if (error) {
 		unlock_flocks();
 		locks_free_lock(fl);
@@ -1538,14 +1537,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
 	if (!fasync_insert_entry(fd, filp, &ret->fl_fasync, new))
 		new = NULL;
 
-	if (error < 0) {
-		/* remove lease just inserted by setlease */
-		fl->fl_type = F_UNLCK | F_INPROGRESS;
-		fl->fl_break_time = jiffies - 10;
-		time_out_leases(inode);
-	} else {
-		error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
-	}
+	error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
 	unlock_flocks();
 
 out_free_fasync:
-- 
1.7.1


  reply	other threads:[~2010-11-04  1:41 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-26 16:45 nfsd changes for 2.6.37 J. Bruce Fields
2010-10-26 17:22 ` J. Bruce Fields
2010-10-26 17:39   ` Linus Torvalds
     [not found]     ` <AANLkTi=emsmLNFSV=j48d37JQxecQmNGZwY9OYdoKjeS-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-26 17:46       ` J. Bruce Fields
2010-10-26 20:18 ` Arnd Bergmann
2010-10-26 20:35   ` Bryan Schumaker
2010-10-26 20:55     ` Arnd Bergmann
2010-10-26 21:02       ` Linus Torvalds
2010-10-26 21:24         ` J. Bruce Fields
2010-10-26 21:37           ` Linus Torvalds
2010-10-26 21:44             ` J. Bruce Fields
2010-10-26 22:11               ` J. Bruce Fields
2010-10-26 22:41                 ` J. Bruce Fields
2010-10-27  7:21                 ` Arnd Bergmann
2010-10-27  8:39                   ` Christoph Hellwig
2010-10-27 13:39                     ` J. Bruce Fields
2010-10-27 13:46                       ` Arnd Bergmann
2010-10-27 14:55                         ` J. Bruce Fields
2010-10-27 14:59                           ` Christoph Hellwig
2010-10-27 15:16                             ` J. Bruce Fields
2010-10-27 15:19                               ` Christoph Hellwig
2010-10-27 15:23                             ` Arnd Bergmann
2010-10-27 15:28                               ` J. Bruce Fields
2010-10-27 15:31                               ` Christoph Hellwig
2010-10-27 16:12                               ` Linus Torvalds
     [not found]                                 ` <AANLkTinTm-LwjfBfoFUyp5Dj8S2hexnHGQGpZiOWqyMY-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-27 16:46                                   ` J. Bruce Fields
2010-10-27 17:32                                     ` Linus Torvalds
2010-10-27 17:40                                       ` J. Bruce Fields
2010-10-27 18:20                                         ` Arnd Bergmann
2010-10-27 18:42                                           ` Linus Torvalds
2010-10-27 18:43                                             ` Linus Torvalds
2010-10-27 19:48                                               ` Arnd Bergmann
2010-10-27 20:01                                                 ` J. Bruce Fields
2010-10-27 20:20                                                   ` Arnd Bergmann
2010-10-27 20:24                                                     ` J. Bruce Fields
2010-10-30 21:25                             ` J. Bruce Fields
2010-10-30 21:31                               ` [PATCH 1/4] locks: prevent ENOMEM on lease unlock J. Bruce Fields
2010-10-30 21:31                               ` [PATCH 2/4] locks: fix leaks on setlease errors J. Bruce Fields
2010-10-31 11:10                                 ` Christoph Hellwig
2010-11-01 17:24                                   ` J. Bruce Fields
2010-11-01 17:41                                     ` Christoph Hellwig
2010-11-01 18:34                                       ` J. Bruce Fields
2010-10-30 21:31                               ` [PATCH 3/4] locks: fix setlease methods to free passed-in lock J. Bruce Fields
2010-10-30 21:31                               ` [PATCH 4/4] nfsd4: initialize delegation pointer to lease J. Bruce Fields
2010-10-31  2:04                                 ` Christoph Hellwig
2010-10-31  3:04                                   ` J. Bruce Fields
2010-10-30 21:40                               ` nfsd changes for 2.6.37 Arnd Bergmann
2010-10-31  2:07                               ` Christoph Hellwig
2010-10-31  3:05                                 ` J. Bruce Fields
2010-10-31 12:34                               ` Christoph Hellwig
2010-10-31 12:35                                 ` [PATCH 1/2] locks: let the caller free file_lock on ->setlease failure Christoph Hellwig
2010-11-03 20:41                                   ` J. Bruce Fields
2010-11-04  1:40                                     ` J. Bruce Fields
2010-11-04  1:41                                       ` J. Bruce Fields [this message]
2010-11-06 19:03                                         ` Christoph Hellwig
2010-11-06 19:03                                       ` Christoph Hellwig
2010-11-08 16:10                                         ` J. Bruce Fields
2010-10-31 12:35                                 ` [PATCH 2/2] locks: remove fl_copy_lock lock_manager operation Christoph Hellwig
2010-11-01 15:02                                 ` nfsd changes for 2.6.37 J. Bruce Fields
2010-11-06 19:04                                   ` Christoph Hellwig

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=20101104014128.GB22498@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=arnd@arndb.de \
    --cc=bjschuma@netapp.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=torvalds@linux-foundation.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).