Commit ac3ad984 authored by Bharath SM's avatar Bharath SM Committed by Steve French
Browse files

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: default avatarBharath SM <bharathsm@microsoft.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 998a67b9
Loading
Loading
Loading
Loading
+28 −5
Original line number Diff line number Diff line
@@ -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);
			}