Commit 7390022d697bcc62a7556d6fdc61ec56ce3a381a

Authored by NeilBrown
Committed by Linus Torvalds
1 parent 15b7a1b86d

[PATCH] knfsd: Restore functionality to read from file in /proc/fs/nfsd/

Most files in the nfsd filesystems are transaction files.  You write a
request, and read a response.

For some (e.g.  'threads') it makes sense to just be able to read and get the
current value.

This functionality did exist but was broken recently when someone modified
nfsctl.c without going through the maintainer.  This patch fixes the
regression.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 15 additions and 1 deletions Side-by-side Diff

... ... @@ -104,9 +104,23 @@
104 104 return rv;
105 105 }
106 106  
  107 +static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
  108 +{
  109 + if (! file->private_data) {
  110 + /* An attempt to read a transaction file without writing
  111 + * causes a 0-byte write so that the file can return
  112 + * state information
  113 + */
  114 + ssize_t rv = nfsctl_transaction_write(file, buf, 0, pos);
  115 + if (rv < 0)
  116 + return rv;
  117 + }
  118 + return simple_transaction_read(file, buf, size, pos);
  119 +}
  120 +
107 121 static struct file_operations transaction_ops = {
108 122 .write = nfsctl_transaction_write,
109   - .read = simple_transaction_read,
  123 + .read = nfsctl_transaction_read,
110 124 .release = simple_transaction_release,
111 125 };
112 126