2022-01-31 11:32:02

by Dai Ngo

[permalink] [raw]
Subject: [PATCH RFC 2/3] fs/lock: only call lm_breaker_owns_lease if there is conflict.

Modify leases_conflict to call lm_breaker_owns_lease only if
there is real conflict. This is to allow the lock manager to
resolve the conflict if possible.

Signed-off-by: Dai Ngo <[email protected]>
---
fs/locks.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 052b42cc7f25..456717873cff 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1357,9 +1357,6 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
{
bool rc;

- if (lease->fl_lmops->lm_breaker_owns_lease
- && lease->fl_lmops->lm_breaker_owns_lease(lease))
- return false;
if ((breaker->fl_flags & FL_LAYOUT) != (lease->fl_flags & FL_LAYOUT)) {
rc = false;
goto trace;
@@ -1370,6 +1367,9 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
}

rc = locks_conflict(breaker, lease);
+ if (rc && lease->fl_lmops->lm_breaker_owns_lease &&
+ lease->fl_lmops->lm_breaker_owns_lease(lease))
+ rc = false;
trace:
trace_leases_conflict(rc, lease, breaker);
return rc;
--
2.9.5


2022-02-04 14:48:37

by Chuck Lever

[permalink] [raw]
Subject: Re: [PATCH RFC 2/3] fs/lock: only call lm_breaker_owns_lease if there is conflict.

Hi Jeff-

> On Jan 28, 2022, at 2:39 PM, Dai Ngo <[email protected]> wrote:
>
> Modify leases_conflict to call lm_breaker_owns_lease only if
> there is real conflict. This is to allow the lock manager to
> resolve the conflict if possible.
>
> Signed-off-by: Dai Ngo <[email protected]>

If we are to take 1/3 and 2/3 through the nfsd tree,
can you send an Acked-by: ?


> ---
> fs/locks.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 052b42cc7f25..456717873cff 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1357,9 +1357,6 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
> {
> bool rc;
>
> - if (lease->fl_lmops->lm_breaker_owns_lease
> - && lease->fl_lmops->lm_breaker_owns_lease(lease))
> - return false;
> if ((breaker->fl_flags & FL_LAYOUT) != (lease->fl_flags & FL_LAYOUT)) {
> rc = false;
> goto trace;
> @@ -1370,6 +1367,9 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
> }
>
> rc = locks_conflict(breaker, lease);
> + if (rc && lease->fl_lmops->lm_breaker_owns_lease &&
> + lease->fl_lmops->lm_breaker_owns_lease(lease))
> + rc = false;
> trace:
> trace_leases_conflict(rc, lease, breaker);
> return rc;
> --
> 2.9.5
>

--
Chuck Lever



2022-02-07 09:13:41

by Jeff Layton

[permalink] [raw]
Subject: Re: [PATCH RFC 2/3] fs/lock: only call lm_breaker_owns_lease if there is conflict.

On Fri, 2022-01-28 at 11:39 -0800, Dai Ngo wrote:
> Modify leases_conflict to call lm_breaker_owns_lease only if
> there is real conflict. This is to allow the lock manager to
> resolve the conflict if possible.
>
> Signed-off-by: Dai Ngo <[email protected]>
> ---
> fs/locks.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 052b42cc7f25..456717873cff 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1357,9 +1357,6 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
> {
> bool rc;
>
> - if (lease->fl_lmops->lm_breaker_owns_lease
> - && lease->fl_lmops->lm_breaker_owns_lease(lease))
> - return false;
> if ((breaker->fl_flags & FL_LAYOUT) != (lease->fl_flags & FL_LAYOUT)) {
> rc = false;
> goto trace;
> @@ -1370,6 +1367,9 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
> }
>
> rc = locks_conflict(breaker, lease);
> + if (rc && lease->fl_lmops->lm_breaker_owns_lease &&
> + lease->fl_lmops->lm_breaker_owns_lease(lease))
> + rc = false;
> trace:
> trace_leases_conflict(rc, lease, breaker);
> return rc;

Acked-by: Jeff Layton <[email protected]>