Re: [PATCH 13/20] filelock: convert __locks_insert_block, conflict and deadlock checks to use file_lock_core

From: Jeff Layton
Date: Wed Jan 17 2024 - 07:42:42 EST


On Wed, 2024-01-17 at 09:32 +1100, NeilBrown wrote:
> On Wed, 17 Jan 2024, Jeff Layton wrote:
> > Have both __locks_insert_block and the deadlock and conflict checking
> > functions take a struct file_lock_core pointer instead of a struct
> > file_lock one. Also, change posix_locks_deadlock to return bool.
> >
> > Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> > ---
> > fs/locks.c | 132 ++++++++++++++++++++++++++++++++-----------------------------
> > 1 file changed, 70 insertions(+), 62 deletions(-)
> >
>
>
> >
> > /* Must be called with the blocked_lock_lock held! */
> > -static int posix_locks_deadlock(struct file_lock *caller_fl,
> > - struct file_lock *block_fl)
> > +static bool posix_locks_deadlock(struct file_lock *caller_fl,
> > + struct file_lock *block_fl)
> > {
> > + struct file_lock_core *caller = &caller_fl->fl_core;
> > + struct file_lock_core *blocker = &block_fl->fl_core;
> > int i = 0;
> > - struct file_lock_core *flc = &caller_fl->fl_core;
> >
> > lockdep_assert_held(&blocked_lock_lock);
> >
> > @@ -1034,16 +1040,16 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
> > * This deadlock detector can't reasonably detect deadlocks with
> > * FL_OFDLCK locks, since they aren't owned by a process, per-se.
> > */
> > - if (IS_OFDLCK(flc))
> > + if (IS_OFDLCK(caller))
> > return 0;
>
> return false;
>

Good catch. Fixed in my local branch.

--
Jeff Layton <jlayton@xxxxxxxxxx>