diff mbox series

SMB3: Close all deferred handles of inode in case of handle lease break

Message ID 20230508190103.601678-1-bharathsm.hsk@gmail.com (mailing list archive)
State New, archived
Headers show
Series SMB3: Close all deferred handles of inode in case of handle lease break | expand

Commit Message

Bharath SM May 8, 2023, 7:01 p.m. UTC
Oplock break may occur for different file handle than the deferred handle.
Check for inode deferred closes list, if it's not empty then close all the
deferred handles of inode.

Fixes: 9e31678fb403 ("SMB3: fix lease break timeout when multiple deferred close handles for the same file.")
Signed-off-by: Bharath SM <bharathsm@microsoft.com>
---
 fs/cifs/file.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Comments

Bharath SM May 15, 2023, 8:49 p.m. UTC | #1
Attached updated patch with expanded commit message.

On Tue, May 9, 2023 at 12:32 AM Bharath SM <bharathsm.hsk@gmail.com> wrote:
>
> Oplock break may occur for different file handle than the deferred handle.
> Check for inode deferred closes list, if it's not empty then close all the
> deferred handles of inode.
>
> Fixes: 9e31678fb403 ("SMB3: fix lease break timeout when multiple deferred close handles for the same file.")
> Signed-off-by: Bharath SM <bharathsm@microsoft.com>
> ---
>  fs/cifs/file.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index 791a12575109..260d5ec878e8 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -4886,8 +4886,6 @@ void cifs_oplock_break(struct work_struct *work)
>         struct TCP_Server_Info *server = tcon->ses->server;
>         int rc = 0;
>         bool purge_cache = false;
> -       struct cifs_deferred_close *dclose;
> -       bool is_deferred = false;
>
>         wait_on_bit(&cinode->flags, CIFS_INODE_PENDING_WRITERS,
>                         TASK_UNINTERRUPTIBLE);
> @@ -4928,14 +4926,9 @@ void cifs_oplock_break(struct work_struct *work)
>          * file handles but cached, then schedule deferred close immediately.
>          * So, new open will not use cached handle.
>          */
> -       spin_lock(&CIFS_I(inode)->deferred_lock);
> -       is_deferred = cifs_is_deferred_close(cfile, &dclose);
> -       spin_unlock(&CIFS_I(inode)->deferred_lock);
>
> -       if (!CIFS_CACHE_HANDLE(cinode) && is_deferred &&
> -                       cfile->deferred_close_scheduled && delayed_work_pending(&cfile->deferred)) {
> +       if (!CIFS_CACHE_HANDLE(cinode) && !list_empty(&cinode->deferred_closes))
>                 cifs_close_deferred_file(cinode);
> -       }
>
>         /*
>          * releasing stale oplock after recent reconnect of smb session using
> --
> 2.34.1
>
Shyam Prasad N May 18, 2023, 2:01 p.m. UTC | #2
On Tue, May 16, 2023 at 2:19 AM Bharath SM <bharathsm.hsk@gmail.com> wrote:
>
> Attached updated patch with expanded commit message.
>
> On Tue, May 9, 2023 at 12:32 AM Bharath SM <bharathsm.hsk@gmail.com> wrote:
> >
> > Oplock break may occur for different file handle than the deferred handle.
> > Check for inode deferred closes list, if it's not empty then close all the
> > deferred handles of inode.
> >
> > Fixes: 9e31678fb403 ("SMB3: fix lease break timeout when multiple deferred close handles for the same file.")
> > Signed-off-by: Bharath SM <bharathsm@microsoft.com>
> > ---
> >  fs/cifs/file.c | 9 +--------
> >  1 file changed, 1 insertion(+), 8 deletions(-)
> >
> > diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> > index 791a12575109..260d5ec878e8 100644
> > --- a/fs/cifs/file.c
> > +++ b/fs/cifs/file.c
> > @@ -4886,8 +4886,6 @@ void cifs_oplock_break(struct work_struct *work)
> >         struct TCP_Server_Info *server = tcon->ses->server;
> >         int rc = 0;
> >         bool purge_cache = false;
> > -       struct cifs_deferred_close *dclose;
> > -       bool is_deferred = false;
> >
> >         wait_on_bit(&cinode->flags, CIFS_INODE_PENDING_WRITERS,
> >                         TASK_UNINTERRUPTIBLE);
> > @@ -4928,14 +4926,9 @@ void cifs_oplock_break(struct work_struct *work)
> >          * file handles but cached, then schedule deferred close immediately.
> >          * So, new open will not use cached handle.
> >          */
> > -       spin_lock(&CIFS_I(inode)->deferred_lock);
> > -       is_deferred = cifs_is_deferred_close(cfile, &dclose);
> > -       spin_unlock(&CIFS_I(inode)->deferred_lock);
> >
> > -       if (!CIFS_CACHE_HANDLE(cinode) && is_deferred &&
> > -                       cfile->deferred_close_scheduled && delayed_work_pending(&cfile->deferred)) {
> > +       if (!CIFS_CACHE_HANDLE(cinode) && !list_empty(&cinode->deferred_closes))
> >                 cifs_close_deferred_file(cinode);
> > -       }
> >
> >         /*
> >          * releasing stale oplock after recent reconnect of smb session using
> > --
> > 2.34.1
> >

Changes look good to me.
diff mbox series

Patch

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 791a12575109..260d5ec878e8 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -4886,8 +4886,6 @@  void cifs_oplock_break(struct work_struct *work)
 	struct TCP_Server_Info *server = tcon->ses->server;
 	int rc = 0;
 	bool purge_cache = false;
-	struct cifs_deferred_close *dclose;
-	bool is_deferred = false;
 
 	wait_on_bit(&cinode->flags, CIFS_INODE_PENDING_WRITERS,
 			TASK_UNINTERRUPTIBLE);
@@ -4928,14 +4926,9 @@  void cifs_oplock_break(struct work_struct *work)
 	 * file handles but cached, then schedule deferred close immediately.
 	 * So, new open will not use cached handle.
 	 */
-	spin_lock(&CIFS_I(inode)->deferred_lock);
-	is_deferred = cifs_is_deferred_close(cfile, &dclose);
-	spin_unlock(&CIFS_I(inode)->deferred_lock);
 
-	if (!CIFS_CACHE_HANDLE(cinode) && is_deferred &&
-			cfile->deferred_close_scheduled && delayed_work_pending(&cfile->deferred)) {
+	if (!CIFS_CACHE_HANDLE(cinode) && !list_empty(&cinode->deferred_closes))
 		cifs_close_deferred_file(cinode);
-	}
 
 	/*
 	 * releasing stale oplock after recent reconnect of smb session using