locks: fix F_GETLK regression (failure to find conflicts)
authorJ. Bruce Fields <bfields@fieldses.org>
Thu, 10 May 2007 22:38:43 +0000 (18:38 -0400)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 11 May 2007 03:25:59 +0000 (20:25 -0700)
commit129a84de2347002f09721cda3155ccfd19fade40
tree11dabc5695dbcd0eb814935b2c02ddeb01442932
parenta9deecba19b8f384d97f82c75379da48bccb2588
locks: fix F_GETLK regression (failure to find conflicts)

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>
Acked-by: Doug Chapman <doug.chapman@hp.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/locks.c