cifs: Add witness information to debug data dump

+ Indicate if witness feature is supported
+ Indicate if witness is used when dumping tcons
+ Dumps witness registrations. Example:
  Witness registrations:
  Id: 1 Refs: 1 Network name: 'fs.fover.ad'(y) Share name: 'share1'(y) \
    Ip address: 192.168.103.200(n)

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Samuel Cabrero 2020-11-30 19:02:53 +01:00 committed by Steve French
parent fed979a7e0
commit 20fab0da2f
3 changed files with 50 additions and 0 deletions

View File

@ -23,6 +23,9 @@
#ifdef CONFIG_CIFS_SMB_DIRECT
#include "smbdirect.h"
#endif
#ifdef CONFIG_CIFS_SWN_UPCALL
#include "cifs_swn.h"
#endif
void
cifs_dump_mem(char *label, void *data, int length)
@ -115,6 +118,10 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)
seq_printf(m, " POSIX Extensions");
if (tcon->ses->server->ops->dump_share_caps)
tcon->ses->server->ops->dump_share_caps(m, tcon);
#ifdef CONFIG_CIFS_SWN_UPCALL
if (tcon->use_witness)
seq_puts(m, " Witness");
#endif
if (tcon->need_reconnect)
seq_puts(m, "\tDISCONNECTED ");
@ -262,6 +269,9 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
seq_printf(m, ",XATTR");
#endif
seq_printf(m, ",ACL");
#ifdef CONFIG_CIFS_SWN_UPCALL
seq_puts(m, ",WITNESS");
#endif
seq_putc(m, '\n');
seq_printf(m, "CIFSMaxBufSize: %d\n", CIFSMaxBufSize);
seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
@ -462,6 +472,9 @@ skip_rdma:
spin_unlock(&cifs_tcp_ses_lock);
seq_putc(m, '\n');
#ifdef CONFIG_CIFS_SWN_UPCALL
cifs_swn_dump(m);
#endif
/* BB add code to dump additional info such as TCP session info now */
return 0;
}

View File

@ -505,3 +505,38 @@ int cifs_swn_unregister(struct cifs_tcon *tcon)
return 0;
}
void cifs_swn_dump(struct seq_file *m)
{
struct cifs_swn_reg *swnreg;
struct sockaddr_in *sa;
struct sockaddr_in6 *sa6;
int id;
seq_puts(m, "Witness registrations:");
mutex_lock(&cifs_swnreg_idr_mutex);
idr_for_each_entry(&cifs_swnreg_idr, swnreg, id) {
seq_printf(m, "\nId: %u Refs: %u Network name: '%s'%s Share name: '%s'%s Ip address: ",
id, kref_read(&swnreg->ref_count),
swnreg->net_name, swnreg->net_name_notify ? "(y)" : "(n)",
swnreg->share_name, swnreg->share_name_notify ? "(y)" : "(n)");
switch (swnreg->tcon->ses->server->dstaddr.ss_family) {
case AF_INET:
sa = (struct sockaddr_in *) &swnreg->tcon->ses->server->dstaddr;
seq_printf(m, "%pI4", &sa->sin_addr.s_addr);
break;
case AF_INET6:
sa6 = (struct sockaddr_in6 *) &swnreg->tcon->ses->server->dstaddr;
seq_printf(m, "%pI6", &sa6->sin6_addr.s6_addr);
if (sa6->sin6_scope_id)
seq_printf(m, "%%%u", sa6->sin6_scope_id);
break;
default:
seq_puts(m, "(unknown)");
}
seq_printf(m, "%s", swnreg->ip_notify ? "(y)" : "(n)");
}
mutex_unlock(&cifs_swnreg_idr_mutex);
seq_puts(m, "\n");
}

View File

@ -18,4 +18,6 @@ extern int cifs_swn_unregister(struct cifs_tcon *tcon);
extern int cifs_swn_notify(struct sk_buff *skb, struct genl_info *info);
extern void cifs_swn_dump(struct seq_file *m);
#endif /* _CIFS_SWN_H */