mbox series

[0/3] filelock: remove redundant filp arguments from API

Message ID 20221114150240.198648-1-jlayton@kernel.org (mailing list archive)
Headers show
Series filelock: remove redundant filp arguments from API | expand

Message

Jeff Layton Nov. 14, 2022, 3:02 p.m. UTC
Some of the exported functions in fs/locks.c take both a struct file
argument and a struct file_lock. struct file_lock has a dedicated field
to record which file it was set on (fl_file). This is redundant, and
there have been some cases where the two didn't match [1], leading to
bugs.

This patchset is intended to remove this ambiguity by eliminating the
separate struct file argument from vfs_lock_file, vfs_test_lock and
vfs_cancel_lock.

Most callers are easy to vet to ensure that they set this correctly, but
lockd had a few places where it wasn't doing the right thing. This
series depends on the lockd patches I sent late last week [2].

I'm targeting this series for v6.3. I'll plan to get it into linux-next
soon unless there are objections.

[1]: https://bugzilla.kernel.org/show_bug.cgi?id=216582
[2]: https://lore.kernel.org/linux-nfs/20221111215538.356543-1-jlayton@kernel.org/T/#t

Jeff Layton (3):
  filelock: remove redundant filp argument from vfs_lock_file
  filelock: remove redundant filp argument from vfs_test_lock
  filelock: remove redundant filp arg from vfs_cancel_lock

 fs/ksmbd/smb2pdu.c  |  4 ++--
 fs/lockd/svclock.c  | 21 +++++++--------------
 fs/lockd/svcsubs.c  |  4 ++--
 fs/locks.c          | 29 ++++++++++++++---------------
 fs/nfsd/nfs4state.c |  6 +++---
 include/linux/fs.h  | 14 +++++++-------
 6 files changed, 35 insertions(+), 43 deletions(-)

Comments

Chuck Lever Nov. 14, 2022, 3:08 p.m. UTC | #1
> On Nov 14, 2022, at 10:02 AM, Jeff Layton <jlayton@kernel.org> wrote:
> 
> Some of the exported functions in fs/locks.c take both a struct file
> argument and a struct file_lock. struct file_lock has a dedicated field
> to record which file it was set on (fl_file). This is redundant, and
> there have been some cases where the two didn't match [1], leading to
> bugs.

Hi Jeff, doesn't the same argument apply to f_ops->lock ? Do you
have a plan for updating that API as well?


> This patchset is intended to remove this ambiguity by eliminating the
> separate struct file argument from vfs_lock_file, vfs_test_lock and
> vfs_cancel_lock.
> 
> Most callers are easy to vet to ensure that they set this correctly, but
> lockd had a few places where it wasn't doing the right thing. This
> series depends on the lockd patches I sent late last week [2].
> 
> I'm targeting this series for v6.3. I'll plan to get it into linux-next
> soon unless there are objections.
> 
> [1]: https://bugzilla.kernel.org/show_bug.cgi?id=216582
> [2]: https://lore.kernel.org/linux-nfs/20221111215538.356543-1-jlayton@kernel.org/T/#t
> 
> Jeff Layton (3):
>  filelock: remove redundant filp argument from vfs_lock_file
>  filelock: remove redundant filp argument from vfs_test_lock
>  filelock: remove redundant filp arg from vfs_cancel_lock
> 
> fs/ksmbd/smb2pdu.c  |  4 ++--
> fs/lockd/svclock.c  | 21 +++++++--------------
> fs/lockd/svcsubs.c  |  4 ++--
> fs/locks.c          | 29 ++++++++++++++---------------
> fs/nfsd/nfs4state.c |  6 +++---
> include/linux/fs.h  | 14 +++++++-------
> 6 files changed, 35 insertions(+), 43 deletions(-)
> 
> -- 
> 2.38.1
> 

--
Chuck Lever
Jeff Layton Nov. 14, 2022, 3:31 p.m. UTC | #2
On Mon, 2022-11-14 at 15:08 +0000, Chuck Lever III wrote:
> 
> > On Nov 14, 2022, at 10:02 AM, Jeff Layton <jlayton@kernel.org> wrote:
> > 
> > Some of the exported functions in fs/locks.c take both a struct file
> > argument and a struct file_lock. struct file_lock has a dedicated field
> > to record which file it was set on (fl_file). This is redundant, and
> > there have been some cases where the two didn't match [1], leading to
> > bugs.
> 
> Hi Jeff, doesn't the same argument apply to f_ops->lock ? Do you
> have a plan for updating that API as well?
> 
> 

It does apply to fops->lock. I don't have a real plan as of yet. I
figure we'll get this set in first and then we can look at changing that
API as well.

> > This patchset is intended to remove this ambiguity by eliminating the
> > separate struct file argument from vfs_lock_file, vfs_test_lock and
> > vfs_cancel_lock.
> > 
> > Most callers are easy to vet to ensure that they set this correctly, but
> > lockd had a few places where it wasn't doing the right thing. This
> > series depends on the lockd patches I sent late last week [2].
> > 
> > I'm targeting this series for v6.3. I'll plan to get it into linux-next
> > soon unless there are objections.
> > 
> > [1]: https://bugzilla.kernel.org/show_bug.cgi?id=216582
> > [2]: https://lore.kernel.org/linux-nfs/20221111215538.356543-1-jlayton@kernel.org/T/#t
> > 
> > Jeff Layton (3):
> >  filelock: remove redundant filp argument from vfs_lock_file
> >  filelock: remove redundant filp argument from vfs_test_lock
> >  filelock: remove redundant filp arg from vfs_cancel_lock
> > 
> > fs/ksmbd/smb2pdu.c  |  4 ++--
> > fs/lockd/svclock.c  | 21 +++++++--------------
> > fs/lockd/svcsubs.c  |  4 ++--
> > fs/locks.c          | 29 ++++++++++++++---------------
> > fs/nfsd/nfs4state.c |  6 +++---
> > include/linux/fs.h  | 14 +++++++-------
> > 6 files changed, 35 insertions(+), 43 deletions(-)
> > 
> > -- 
> > 2.38.1
> > 
> 
> --
> Chuck Lever
> 
> 
>