linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Layton <jlayton@primarydata.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [RFC PATCH 03/12] locks: have locks_release_file use flock_lock_file to release generic flock locks
Date: Wed, 10 Sep 2014 13:38:43 -0400	[thread overview]
Message-ID: <20140910173843.GA4210@fieldses.org> (raw)
In-Reply-To: <1410359330-27564-4-git-send-email-jlayton@primarydata.com>

On Wed, Sep 10, 2014 at 10:28:41AM -0400, Jeff Layton wrote:
> Signed-off-by: Jeff Layton <jlayton@primarydata.com>

ACK to going ahead and applying this now if you want.

Took me a moment to understand why the i_flock test got moved--OK, so
the locks_remove_*'s are doing that themselves instead, got it.

--b.

> ---
>  fs/locks.c | 49 +++++++++++++++++++++++++++++++------------------
>  1 file changed, 31 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/locks.c b/fs/locks.c
> index af55bd35be5f..5e8b865814a2 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -2393,6 +2393,30 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
>  
>  EXPORT_SYMBOL(locks_remove_posix);
>  
> +static void
> +locks_remove_flock(struct file *filp)
> +{
> +	struct file_lock fl = {
> +		.fl_owner = filp,
> +		.fl_pid = current->tgid,
> +		.fl_file = filp,
> +		.fl_flags = FL_FLOCK,
> +		.fl_type = F_UNLCK,
> +		.fl_end = OFFSET_MAX,
> +	};
> +
> +	if (!file_inode(filp)->i_flock)
> +		return;
> +
> +	if (filp->f_op->flock)
> +		filp->f_op->flock(filp, F_SETLKW, &fl);
> +	else
> +		flock_lock_file(filp, &fl);
> +
> +	if (fl.fl_ops && fl.fl_ops->fl_release_private)
> +		fl.fl_ops->fl_release_private(&fl);
> +}
> +
>  /*
>   * This function is called on the last close of an open file.
>   */
> @@ -2403,24 +2427,14 @@ void locks_remove_file(struct file *filp)
>  	struct file_lock **before;
>  	LIST_HEAD(dispose);
>  
> -	if (!inode->i_flock)
> -		return;
> -
> +	/* remove any OFD locks */
>  	locks_remove_posix(filp, filp);
>  
> -	if (filp->f_op->flock) {
> -		struct file_lock fl = {
> -			.fl_owner = filp,
> -			.fl_pid = current->tgid,
> -			.fl_file = filp,
> -			.fl_flags = FL_FLOCK,
> -			.fl_type = F_UNLCK,
> -			.fl_end = OFFSET_MAX,
> -		};
> -		filp->f_op->flock(filp, F_SETLKW, &fl);
> -		if (fl.fl_ops && fl.fl_ops->fl_release_private)
> -			fl.fl_ops->fl_release_private(&fl);
> -	}
> +	/* remove flock locks */
> +	locks_remove_flock(filp);
> +
> +	if (!inode->i_flock)
> +		return;



>  
>  	spin_lock(&inode->i_lock);
>  	before = &inode->i_flock;
> @@ -2440,8 +2454,7 @@ void locks_remove_file(struct file *filp)
>  			 * some info about it and then just remove it from
>  			 * the list.
>  			 */
> -			WARN(!IS_FLOCK(fl),
> -				"leftover lock: dev=%u:%u ino=%lu type=%hhd flags=0x%x start=%lld end=%lld\n",
> +			WARN(1, "leftover lock: dev=%u:%u ino=%lu type=%hhd flags=0x%x start=%lld end=%lld\n",
>  				MAJOR(inode->i_sb->s_dev),
>  				MINOR(inode->i_sb->s_dev), inode->i_ino,
>  				fl->fl_type, fl->fl_flags,
> -- 
> 1.9.3
> 

  reply	other threads:[~2014-09-10 17:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 14:28 [RFC PATCH 00/12] locks: saner method for managing file locks Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 01/12] locks: add a new struct file_locking_context pointer to struct inode Jeff Layton
2014-09-10 18:38   ` J. Bruce Fields
2014-09-10 18:51     ` Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 02/12] locks: add new struct list_head to struct file_lock Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 03/12] locks: have locks_release_file use flock_lock_file to release generic flock locks Jeff Layton
2014-09-10 17:38   ` J. Bruce Fields [this message]
2014-09-10 17:49     ` Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 04/12] locks: move flock locks to file_lock_context Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 05/12] locks: convert posix " Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 06/12] locks: convert lease handling " Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 07/12] ceph: convert to looking for locks in struct file_lock_context Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 08/12] nfs: convert lock handling to use file_lock_context Jeff Layton
2014-09-10 19:17   ` J. Bruce Fields
2014-09-10 19:20     ` Al Viro
2014-09-10 19:28     ` Jeff Layton
2014-09-10 19:34       ` J. Bruce Fields
2014-09-10 14:28 ` [RFC PATCH 09/12] cifs: convert it " Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 10/12] lockd: " Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 11/12] nfsd: convert to file_lock_context Jeff Layton
2014-09-10 14:28 ` [RFC PATCH 12/12] locks: remove i_flock field from struct inode Jeff Layton

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=20140910173843.GA4210@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=hch@infradead.org \
    --cc=jlayton@primarydata.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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).