Skip to content

Commit ac3ad98

Browse files
bharathsm-mssmfrench
authored andcommitted
smb: client: show lease state as R/H/W (or NONE) in open_files
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>
1 parent 998a67b commit ac3ad98

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

fs/smb/client/cifs_debug.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,18 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
240240
struct cifs_ses *ses;
241241
struct cifs_tcon *tcon;
242242
struct cifsFileInfo *cfile;
243+
struct inode *inode;
244+
struct cifsInodeInfo *cinode;
245+
char lease[4];
246+
int n;
243247

244248
seq_puts(m, "# Version:1\n");
245249
seq_puts(m, "# Format:\n");
246250
seq_puts(m, "# <tree id> <ses id> <persistent fid> <flags> <count> <pid> <uid>");
247251
#ifdef CONFIG_CIFS_DEBUG2
248-
seq_printf(m, " <filename> <mid>\n");
252+
seq_puts(m, " <filename> <lease> <mid>\n");
249253
#else
250-
seq_printf(m, " <filename>\n");
254+
seq_puts(m, " <filename> <lease>\n");
251255
#endif /* CIFS_DEBUG2 */
252256
spin_lock(&cifs_tcp_ses_lock);
253257
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)
267271
cfile->pid,
268272
from_kuid(&init_user_ns, cfile->uid),
269273
cfile->dentry);
274+
275+
/* Append lease/oplock caching state as RHW letters */
276+
inode = d_inode(cfile->dentry);
277+
n = 0;
278+
if (inode) {
279+
cinode = CIFS_I(inode);
280+
if (CIFS_CACHE_READ(cinode))
281+
lease[n++] = 'R';
282+
if (CIFS_CACHE_HANDLE(cinode))
283+
lease[n++] = 'H';
284+
if (CIFS_CACHE_WRITE(cinode))
285+
lease[n++] = 'W';
286+
}
287+
lease[n] = '\0';
288+
seq_puts(m, " ");
289+
if (n)
290+
seq_printf(m, "%s", lease);
291+
else
292+
seq_puts(m, "NONE");
293+
270294
#ifdef CONFIG_CIFS_DEBUG2
271-
seq_printf(m, " %llu\n", cfile->fid.mid);
272-
#else
295+
seq_printf(m, " %llu", cfile->fid.mid);
296+
#endif /* CONFIG_CIFS_DEBUG2 */
273297
seq_printf(m, "\n");
274-
#endif /* CIFS_DEBUG2 */
275298
}
276299
spin_unlock(&tcon->open_file_lock);
277300
}

0 commit comments

Comments
 (0)