Thread (15 messages) 15 messages, 2 authors, 2023-06-26

Re: [PATCH v4 05/11] NFS: add superblock sysfs entries

From: Nathan Chancellor <nathan@kernel.org>
Date: 2023-06-26 22:25:17

On Mon, Jun 26, 2023 at 05:47:21PM -0400, Benjamin Coddington wrote:
quoted hunk ↗ jump to hunk
On 26 Jun 2023, at 17:12, Nathan Chancellor wrote:
quoted
Hi Benjamin,

On Thu, Jun 15, 2023 at 02:07:26PM -0400, Benjamin Coddington wrote:
quoted
Create a sysfs directory for each mount that corresponds to the mount's
nfs_server struct.  As the mount is being constructed, use the name
"server-n", but rename it to the "MAJOR:MINOR" of the mount after assigning
a device_id. The rename approach allows us to populate the mount's directory
with links to the various rpc_client objects during the mount's
construction.  The naming convention (MAJOR:MINOR) can be used to reference
a particular NFS mount's sysfs tree.

Signed-off-by: Benjamin Coddington <redacted>
I am not sure if this has been reported or fixed already, so I apologize
if this is a duplicate. After this change landed in -next as commit
1c7251187dc0 ("NFS: add superblock sysfs entries"), I see the following
splat when accessing a NFS server:
Hi Nathan, oh yes - I see there are a few paths through nfs4_init_server()
where we can exit early due to an error or duplicate client, in which case
nfs_free_server() tries to clean up the server kobject before it has been
initialized.

I think we can simply do:
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 4967ac800b14..4046072663f2 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1013,8 +1013,10 @@ void nfs_free_server(struct nfs_server *server)

        nfs_put_client(server->nfs_client);

-       nfs_sysfs_remove_server(server);
-       kobject_put(&server->kobj);
+       if (server->kobj.state_initialized) {
+               nfs_sysfs_remove_server(server);
+               kobject_put(&server->kobj);
+       }
        ida_free(&s_sysfs_ids, server->s_sysfs_id);

        ida_destroy(&server->lockowner_id);
Are you able to test that?  If not, totally fine - I think I should be able
to reproduce the problem and send a patch.
Yes, that appears to work for me! Feel free to add

Tested-by: Nathan Chancellor <nathan@kernel.org>

to that diff if you send it along formally.

Cheers,
Nathan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help