Re: fctnl(F_SETSIG) no longer works in 2.6.17, does in 2.6.16.

From: Trond Myklebust
Date: Tue Aug 08 2006 - 09:24:35 EST


On Tue, 2006-08-08 at 07:38 +0200, Beschorner Daniel wrote:
> >>> static void lease_release_private_callback(struct file_lock *fl)
> >>> {
> >>> if (!fl->fl_file)
> >>> return;
> >>> f_delown(fl->fl_file);
> >>> => fl->fl_file->f_owner.signum = 0;
> >>> }
>
> >> Why should the lease cleanup code be resetting f_owner.signum? That
> >> looks wrong.
> >> Stephen, I think this line of code predates the CITI changes. Do you
> >> know who added it and why?
>
> >Because when the original code was written, it was only called when we
> got
> >a fcntl(F_SETLEASE, F_UNLCK) call. The code got moved incorrectly and
> >noone noticed.
>
> Does somebody have a patch for this issue? It breaks one important
> application (Samba) in its default configuration.
>
> Daniel

I believe this ought to fix it.

Cheers,
Trond

--- Begin Message --- fcntl(F_SETSIG) no longer works on leases because
lease_release_private_callback() gets called as the lease is copied in
order to initialise it.
The problem is that lease_alloc() performs an unnecessary initialisation,
which sets the lease_manager_ops. Avoid the problem by allocating the
target lease structure using locks_alloc_lock().

Signed-off-by: Trond Myklebust <Trond.Myklebust@xxxxxxxxxx>
---

fs/locks.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index b0b41a6..d7c5339 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1421,8 +1421,9 @@ static int __setlease(struct file *filp,
if (!leases_enable)
goto out;

- error = lease_alloc(filp, arg, &fl);
- if (error)
+ error = -ENOMEM;
+ fl = locks_alloc_lock();
+ if (fl == NULL)
goto out;

locks_copy_lock(fl, lease);
@@ -1430,6 +1431,7 @@ static int __setlease(struct file *filp,
locks_insert_lock(before, fl);

*flp = fl;
+ error = 0;
out:
return error;
}

--- End Message ---