ksmbd: send lease break notification on FILE_RENAME_INFORMATION
authorNamjae Jeon <linkinjeon@kernel.org>
Sun, 7 Jan 2024 12:26:17 +0000 (21:26 +0900)
committerSteve French <stfrench@microsoft.com>
Tue, 9 Jan 2024 18:55:07 +0000 (12:55 -0600)
Send lease break notification on FILE_RENAME_INFORMATION request.
This patch fix smb2.lease.v2_epoch2 test failure.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/oplock.c
fs/smb/server/smb2pdu.c

index 77f20d34ed9ae316a784669e4ee9737b962029b3..001926d3b348c88ff98bc1766a6a8b280415e39e 100644 (file)
@@ -541,14 +541,12 @@ static struct oplock_info *same_client_has_lease(struct ksmbd_inode *ci,
                                continue;
                        }
 
-                       if (lctx->req_state != lease->state)
-                               lease->epoch++;
-
                        /* upgrading lease */
                        if ((atomic_read(&ci->op_count) +
                             atomic_read(&ci->sop_count)) == 1) {
                                if (lease->state != SMB2_LEASE_NONE_LE &&
                                    lease->state == (lctx->req_state & lease->state)) {
+                                       lease->epoch++;
                                        lease->state |= lctx->req_state;
                                        if (lctx->req_state &
                                                SMB2_LEASE_WRITE_CACHING_LE)
@@ -559,13 +557,17 @@ static struct oplock_info *same_client_has_lease(struct ksmbd_inode *ci,
                                    atomic_read(&ci->sop_count)) > 1) {
                                if (lctx->req_state ==
                                    (SMB2_LEASE_READ_CACHING_LE |
-                                    SMB2_LEASE_HANDLE_CACHING_LE))
+                                    SMB2_LEASE_HANDLE_CACHING_LE)) {
+                                       lease->epoch++;
                                        lease->state = lctx->req_state;
+                               }
                        }
 
                        if (lctx->req_state && lease->state ==
-                           SMB2_LEASE_NONE_LE)
+                           SMB2_LEASE_NONE_LE) {
+                               lease->epoch++;
                                lease_none_upgrade(opinfo, lctx->req_state);
+                       }
                }
                read_lock(&ci->m_lock);
        }
index 2a335bfe25a458c753e8fb469542a02275ffe73f..3143819935dca1a90fbc5355f11786afd61aae1a 100644 (file)
@@ -5569,6 +5569,7 @@ static int smb2_rename(struct ksmbd_work *work,
        if (!file_info->ReplaceIfExists)
                flags = RENAME_NOREPLACE;
 
+       smb_break_all_levII_oplock(work, fp, 0);
        rc = ksmbd_vfs_rename(work, &fp->filp->f_path, new_name, flags);
 out:
        kfree(new_name);