Declare the seq_operations and let procfs open and free the seq_file.
->proc_open() and ->proc_release() only set up ->private and take and
drop the reference to the network namespace now. Reading the file then
no longer holds up its removal.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/nfsd/nfsctl.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index f8ce3c0fb077..5b2782f9dbbd 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -1407,16 +1407,23 @@ MODULE_ALIAS_FS("nfsd");
#ifdef CONFIG_PROC_FS
+/* procfs opens the seq_file */
static int exports_proc_open(struct inode *inode, struct file *file)
{
- return exports_net_open(current->nsproxy->net_ns, file);
+ exports_net_init(current->nsproxy->net_ns, file->private_data);
+ return 0;
+}
+
+static int exports_proc_release(struct inode *inode, struct file *file)
+{
+ exports_net_put(file->private_data);
+ return 0;
}
static const struct proc_ops exports_proc_ops = {
+ .proc_seq_ops = &nfs_exports_op,
.proc_open = exports_proc_open,
- .proc_read = seq_read,
- .proc_lseek = seq_lseek,
- .proc_release = exports_release,
+ .proc_release = exports_proc_release,
};
static int create_proc_exports_entry(void)
--
2.53.0