Skip to contentSkip to conversation

nfsd4: add filename to states output

PATCH Superseded Achilles Gaikwad 2 participants 3 messages Apr 19, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd4: add filename to states output

Add filename to states output for ease of debugging.

---
 fs/nfsd/nfs4state.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/nfsd/nfs4state.c +11 -0
index e32ecedece0f..0f4ed5e3fbe4 100644
@@ -2414,6 +2414,11 @@ static void nfs4_show_superblock(struct seq_file *s, struct nfsd_file *f)
 					 inode->i_ino);
 }
 
+static void nfs4_show_fname(struct seq_file *s, struct nfsd_file *f)
+{
+	seq_printf(s, "filename: \"%s\"", f->nf_file->f_path.dentry->d_name.name);
+}
+
 static void nfs4_show_owner(struct seq_file *s, struct nfs4_stateowner *oo)
 {
 	seq_printf(s, "owner: ");
@@ -2449,6 +2454,8 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st)
 
 	nfs4_show_superblock(s, file);
 	seq_printf(s, ", ");
+	nfs4_show_fname(s, file);
+	seq_printf(s, ", ");
 	nfs4_show_owner(s, oo);
 	seq_printf(s, " }\n");
 	nfsd_file_put(file);
@@ -2480,6 +2487,8 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st)
 	nfs4_show_superblock(s, file);
 	/* XXX: open stateid? */
 	seq_printf(s, ", ");
+	nfs4_show_fname(s, file);
+	seq_printf(s, ", ");
 	nfs4_show_owner(s, oo);
 	seq_printf(s, " }\n");
 	nfsd_file_put(file);
@@ -2506,6 +2515,7 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)
 	/* XXX: lease time, whether it's being recalled. */
 
 	nfs4_show_superblock(s, file);
+	nfs4_show_fname(s, file);
 	seq_printf(s, " }\n");
 
 	return 0;
@@ -2524,6 +2534,7 @@ static int nfs4_show_layout(struct seq_file *s, struct nfs4_stid *st)
 	/* XXX: What else would be useful? */
 
 	nfs4_show_superblock(s, file);
+	nfs4_show_fname(s, file);
 	seq_printf(s, " }\n");
 
 	return 0;
Signature · 1 line
2.25.3
#1 lore raw
Quoted 13 lines · Achilles Gaikwad

Add filename to states output for ease of debugging.

---
 fs/nfsd/nfs4state.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/nfsd/nfs4state.c +0 -0
index e32ecedece0f..0f4ed5e3fbe4 100644

fs/nfsd/nfs4state.c static void nfs4_show_superblock(struct · line 2421

Quoted 8 lines
fs/nfsd/nfs4state.c +3 -0
@@ -2414,6 +2414,11 @@ static void nfs4_show_superblock(struct
 seq_file *s, struct nfsd_file *f)
 					 inode->i_ino);
 }
 
+static void nfs4_show_fname(struct seq_file *s, struct nfsd_file *f)
+{
+	seq_printf(s, "filename: \"%s\"", f->nf_file->f_path.dentry-
 >d_name.name);

Please consider using the '%pD' format specifier, as described in Documentation/core-api/printk-formats.rst, which is designed to avoid races with rename in cases like the above.

Note that most debugging printks use something like %pD2 in order to display the name of the parent directory as well, in which case you want

	seq_printf (s, "filename: \"%pD2\"", f->nf_file);
Quoted 44 lines
fs/nfsd/nfs4state.c +2 -0
+}
+
 static void nfs4_show_owner(struct seq_file *s, struct

nfs4_stateowner *oo)
{

fs/nfsd/nfs4state.c +2 -0
 	seq_printf(s, "owner: ");
@@ -2449,6 +2454,8 @@ static int nfs4_show_open(struct seq_file *s,
 struct nfs4_stid *st)
 
 	nfs4_show_superblock(s, file);
 	seq_printf(s, ", ");
+	nfs4_show_fname(s, file);
+	seq_printf(s, ", ");
 	nfs4_show_owner(s, oo);
 	seq_printf(s, " }\n");
fs/nfsd/nfs4state.c +2 -0
 	nfsd_file_put(file);
@@ -2480,6 +2487,8 @@ static int nfs4_show_lock(struct seq_file *s,
 struct nfs4_stid *st)
 	nfs4_show_superblock(s, file);
 	/* XXX: open stateid? */
 	seq_printf(s, ", ");
+	nfs4_show_fname(s, file);
+	seq_printf(s, ", ");
 	nfs4_show_owner(s, oo);
 	seq_printf(s, " }\n");
fs/nfsd/nfs4state.c +1 -0
 	nfsd_file_put(file);
@@ -2506,6 +2515,7 @@ static int nfs4_show_deleg(struct seq_file *s,
 struct nfs4_stid *st)
 	/* XXX: lease time, whether it's being recalled. */
 
 	nfs4_show_superblock(s, file);
+	nfs4_show_fname(s, file);
 	seq_printf(s, " }\n");
 
fs/nfsd/nfs4state.c +1 -0
 	return 0;
@@ -2524,6 +2534,7 @@ static int nfs4_show_layout(struct seq_file *s,
 struct nfs4_stid *st)
 	/* XXX: What else would be useful? */
 
 	nfs4_show_superblock(s, file);
+	nfs4_show_fname(s, file);
 	seq_printf(s, " }\n");
 

return 0;

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
#2 lore raw

Thanks for the help Trond!
I'll fix the code and send another patch.

Best,
- Achilles
---

Quoted 85 lines · Trond Myklebust
Quoted 13 lines · Achilles Gaikwad

Add filename to states output for ease of debugging.

---
 fs/nfsd/nfs4state.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/nfsd/nfs4state.c +0 -0
index e32ecedece0f..0f4ed5e3fbe4 100644

fs/nfsd/nfs4state.c static void nfs4_show_superblock(struct · line 2421

Quoted 8 lines
fs/nfsd/nfs4state.c +3 -0
@@ -2414,6 +2414,11 @@ static void nfs4_show_superblock(struct
 seq_file *s, struct nfsd_file *f)
                                       inode->i_ino);
 }
 
+static void nfs4_show_fname(struct seq_file *s, struct nfsd_file *f)
+{
+     seq_printf(s, "filename: \"%s\"", f->nf_file->f_path.dentry-
 >d_name.name);

Please consider using the '%pD' format specifier, as described in Documentation/core-api/printk-formats.rst, which is designed to avoid races with rename in cases like the above.

Note that most debugging printks use something like %pD2 in order to display the name of the parent directory as well, in which case you want

        seq_printf (s, "filename: \"%pD2\"", f->nf_file);
Quoted 43 lines
fs/nfsd/nfs4state.c +2 -0
+}
+
 static void nfs4_show_owner(struct seq_file *s, struct

nfs4_stateowner *oo)

 {
      seq_printf(s, "owner: ");
fs/nfsd/nfs4state.c +2 -0
@@ -2449,6 +2454,8 @@ static int nfs4_show_open(struct seq_file *s,
 struct nfs4_stid *st)
 
      nfs4_show_superblock(s, file);
      seq_printf(s, ", ");
+     nfs4_show_fname(s, file);
+     seq_printf(s, ", ");
      nfs4_show_owner(s, oo);
      seq_printf(s, " }\n");
      nfsd_file_put(file);
fs/nfsd/nfs4state.c +2 -0
@@ -2480,6 +2487,8 @@ static int nfs4_show_lock(struct seq_file *s,
 struct nfs4_stid *st)
      nfs4_show_superblock(s, file);
      /* XXX: open stateid? */
      seq_printf(s, ", ");
+     nfs4_show_fname(s, file);
+     seq_printf(s, ", ");
      nfs4_show_owner(s, oo);
      seq_printf(s, " }\n");
      nfsd_file_put(file);
fs/nfsd/nfs4state.c +1 -0
@@ -2506,6 +2515,7 @@ static int nfs4_show_deleg(struct seq_file *s,
 struct nfs4_stid *st)
      /* XXX: lease time, whether it's being recalled. */
 
      nfs4_show_superblock(s, file);
+     nfs4_show_fname(s, file);
      seq_printf(s, " }\n");
 
      return 0;
fs/nfsd/nfs4state.c +1 -0
@@ -2524,6 +2534,7 @@ static int nfs4_show_layout(struct seq_file *s,
 struct nfs4_stid *st)
      /* XXX: What else would be useful? */
 
      nfs4_show_superblock(s, file);
+     nfs4_show_fname(s, file);
      seq_printf(s, " }\n");
 
Quoted 1 line
      return 0;

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]