FILE_LOCK_DEFERRED can be returned when creating or removing a lock, but
not when testing for a lock. This support was explicitly removed in
Commit
09802fd2a8ca ("lockd: rip out deferred lock handling from testlock codepath")
However the test in nlmsvc_testlock() suggests that it *can* be returned,
only nlm cannot handle it.
To aid clarity, remove the test and instead put a similar test and
warning in vfs_test_lock(). If the impossible happens, convert
FILE_LOCK_DEFERRED to -EIO.
Signed-off-by: NeilBrown <neil@brown.name>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
conflock->fl.c.flc_owner = lock->fl.c.flc_owner;
error = vfs_test_lock(file->f_file[mode], &conflock->fl);
if (error) {
- /* We can't currently deal with deferred test requests */
- if (error == FILE_LOCK_DEFERRED)
- WARN_ON_ONCE(1);
-
ret = nlm_lck_denied_nolocks;
goto out;
}
*/
int vfs_test_lock(struct file *filp, struct file_lock *fl)
{
+ int error = 0;
+
WARN_ON_ONCE(fl->fl_ops || fl->fl_lmops);
WARN_ON_ONCE(filp != fl->c.flc_file);
if (filp->f_op->lock)
- return filp->f_op->lock(filp, F_GETLK, fl);
- posix_test_lock(filp, fl);
- return 0;
+ error = filp->f_op->lock(filp, F_GETLK, fl);
+ else
+ posix_test_lock(filp, fl);
+
+ /*
+ * We don't expect FILE_LOCK_DEFERRED and callers cannot
+ * handle it.
+ */
+ if (WARN_ON_ONCE(error == FILE_LOCK_DEFERRED))
+ error = -EIO;
+
+ return error;
}
EXPORT_SYMBOL_GPL(vfs_test_lock);