]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: show lease state as R/H/W (or NONE) in open_files
authorBharath SM <bharathsm@microsoft.com>
Tue, 2 Sep 2025 11:16:03 +0000 (16:46 +0530)
committerSteve French <stfrench@microsoft.com>
Wed, 1 Oct 2025 17:41:46 +0000 (12:41 -0500)
Print the lease/oplock caching state for each open file as a
compact string of letters: R (read), H (handle), W (write).

Signed-off-by: Bharath SM <bharathsm@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifs_debug.c

index 35c4d27d2cc0ec558eb98ba29be58b12cbdbd8c7..75f5f60f0bb8768314f287fdd548efc931b5117e 100644 (file)
@@ -240,14 +240,18 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
        struct cifs_ses *ses;
        struct cifs_tcon *tcon;
        struct cifsFileInfo *cfile;
+       struct inode *inode;
+       struct cifsInodeInfo *cinode;
+       char lease[4];
+       int n;
 
        seq_puts(m, "# Version:1\n");
        seq_puts(m, "# Format:\n");
        seq_puts(m, "# <tree id> <ses id> <persistent fid> <flags> <count> <pid> <uid>");
 #ifdef CONFIG_CIFS_DEBUG2
-       seq_printf(m, " <filename> <mid>\n");
+       seq_puts(m, " <filename> <lease> <mid>\n");
 #else
-       seq_printf(m, " <filename>\n");
+       seq_puts(m, " <filename> <lease>\n");
 #endif /* CIFS_DEBUG2 */
        spin_lock(&cifs_tcp_ses_lock);
        list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
@@ -267,11 +271,30 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
                                                cfile->pid,
                                                from_kuid(&init_user_ns, cfile->uid),
                                                cfile->dentry);
+
+                                       /* Append lease/oplock caching state as RHW letters */
+                                       inode = d_inode(cfile->dentry);
+                                       n = 0;
+                                       if (inode) {
+                                               cinode = CIFS_I(inode);
+                                               if (CIFS_CACHE_READ(cinode))
+                                                       lease[n++] = 'R';
+                                               if (CIFS_CACHE_HANDLE(cinode))
+                                                       lease[n++] = 'H';
+                                               if (CIFS_CACHE_WRITE(cinode))
+                                                       lease[n++] = 'W';
+                                       }
+                                       lease[n] = '\0';
+                                       seq_puts(m, " ");
+                                       if (n)
+                                               seq_printf(m, "%s", lease);
+                                       else
+                                               seq_puts(m, "NONE");
+
 #ifdef CONFIG_CIFS_DEBUG2
-                                       seq_printf(m, " %llu\n", cfile->fid.mid);
-#else
+                                       seq_printf(m, " %llu", cfile->fid.mid);
+#endif /* CONFIG_CIFS_DEBUG2 */
                                        seq_printf(m, "\n");
-#endif /* CIFS_DEBUG2 */
                                }
                                spin_unlock(&tcon->open_file_lock);
                        }