]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ksmbd: avoid reclaiming expired durable opens by the client
authorNamjae Jeon <linkinjeon@kernel.org>
Tue, 21 May 2024 13:57:52 +0000 (22:57 +0900)
committerSteve French <stfrench@microsoft.com>
Sun, 14 Jul 2024 23:00:35 +0000 (18:00 -0500)
The expired durable opens should not be reclaimed by client.
This patch add ->durable_scavenger_timeout to fp and check it in
ksmbd_lookup_durable_fd().

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

index 8b2e37c8716ed70e3805ea2c309eef15a941c33e..baf7f67ec21234c400db5b77034f06a3981d2d67 100644 (file)
@@ -477,7 +477,10 @@ struct ksmbd_file *ksmbd_lookup_durable_fd(unsigned long long id)
        struct ksmbd_file *fp;
 
        fp = __ksmbd_lookup_fd(&global_ft, id);
-       if (fp && fp->conn) {
+       if (fp && (fp->conn ||
+                  (fp->durable_scavenger_timeout &&
+                   (fp->durable_scavenger_timeout <
+                    jiffies_to_msecs(jiffies))))) {
                ksmbd_put_durable_fd(fp);
                fp = NULL;
        }
@@ -718,6 +721,10 @@ static bool session_fd_check(struct ksmbd_tree_connect *tcon,
        fp->tcon = NULL;
        fp->volatile_id = KSMBD_NO_FID;
 
+       if (fp->durable_timeout)
+               fp->durable_scavenger_timeout =
+                       jiffies_to_msecs(jiffies) + fp->durable_timeout;
+
        return true;
 }
 
index 5a225e7055f191b65bf9d6e63017f08fd1144ea5..f2ab1514e81a7901e25a0af7b7ebda5bc6cec4ec 100644 (file)
@@ -101,6 +101,7 @@ struct ksmbd_file {
        struct list_head                lock_list;
 
        int                             durable_timeout;
+       int                             durable_scavenger_timeout;
 
        /* if ls is happening on directory, below is valid*/
        struct ksmbd_readdir_data       readdir_data;