From: Doug Chapman <doug.chapman@hp.com>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org, hch@infradead.org,
Marc Eshel <eshel@almaden.ibm.com>,
Trond Myklebust <trond@netapp.com>
Subject: Re: [PATCH] locks: fix F_GETLK regression (failure to find conflicts)
Date: Thu, 10 May 2007 19:30:56 -0400 [thread overview]
Message-ID: <1178839856.21710.0.camel@phobos> (raw)
In-Reply-To: <20070510223843.GB13719@fieldses.org>
On Thu, 2007-05-10 at 18:38 -0400, J. Bruce Fields wrote:
> In 9d6a8c5c213e34c475e72b245a8eb709258e968c we changed posix_test_lock
> to modify its single file_lock argument instead of taking separate input
> and output arguments. This makes it no longer safe to set the output
> lock's fl_type to F_UNLCK before looking for a conflict, since that
> means searching for a conflict against a lock with type F_UNLCK.
>
> This fixes a regression which causes F_GETLK to incorrectly report no
> conflict on most filesystems (including any filesystem that doesn't do
> its own locking).
>
> Also fix posix_lock_to_flock() to copy the lock type. This isn't
> strictly necessary, since the caller already does this; but it seems
> less likely to cause confusion in the future.
>
> Thanks to Doug Chapman for the bug report.
>
> Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
> ---
> fs/locks.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 671a034..8ec16ab 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -669,7 +669,6 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
> {
> struct file_lock *cfl;
>
> - fl->fl_type = F_UNLCK;
> lock_kernel();
> for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) {
> if (!IS_POSIX(cfl))
> @@ -681,7 +680,8 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
> __locks_copy_lock(fl, cfl);
> unlock_kernel();
> return 1;
> - }
> + } else
> + fl->fl_type = F_UNLCK;
> unlock_kernel();
> return 0;
> }
> @@ -1632,6 +1632,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl)
> flock->l_len = fl->fl_end == OFFSET_MAX ? 0 :
> fl->fl_end - fl->fl_start + 1;
> flock->l_whence = 0;
> + flock->l_type = fl->fl_type;
> return 0;
> }
>
I tested this both with my little hacked up test program as well as with
the LTP tests. Looks good. Nice job on the quick turnaround on this
Bruce.
- Doug
prev parent reply other threads:[~2007-05-10 23:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-10 18:56 post 2.6.21 regression in F_GETLK Doug Chapman
2007-05-10 19:14 ` Doug Chapman
2007-05-10 19:30 ` J. Bruce Fields
2007-05-10 19:38 ` J. Bruce Fields
2007-05-10 20:23 ` J. Bruce Fields
2007-05-10 21:01 ` Doug Chapman
2007-05-10 21:04 ` J. Bruce Fields
2007-05-10 21:35 ` J. Bruce Fields
2007-05-10 20:24 ` Doug Chapman
2007-05-10 22:38 ` [PATCH] locks: fix F_GETLK regression (failure to find conflicts) J. Bruce Fields
2007-05-10 23:30 ` Doug Chapman [this message]
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=1178839856.21710.0.camel@phobos \
--to=doug.chapman@hp.com \
--cc=bfields@fieldses.org \
--cc=eshel@almaden.ibm.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=trond@netapp.com \
/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