Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

NFS: Add implid to sysfs

The Linux NFS server added support for returning this information during
an EXCHANGE_ID in Linux v6.13. This is something and admin might want to
query, so let's add it to sysfs.

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
Link: https://lore.kernel.org/r/20250207204225.594002-2-anna@kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

authored by

Anna Schumaker and committed by
Trond Myklebust
e171b965 cfe1f877

+60
+60
fs/nfs/sysfs.c
··· 272 272 273 273 static struct kobj_attribute nfs_sysfs_attr_shutdown = __ATTR_RW(shutdown); 274 274 275 + #if IS_ENABLED(CONFIG_NFS_V4_1) 276 + static ssize_t 277 + implid_domain_show(struct kobject *kobj, struct kobj_attribute *attr, 278 + char *buf) 279 + { 280 + struct nfs_server *server = container_of(kobj, struct nfs_server, kobj); 281 + struct nfs41_impl_id *impl_id = server->nfs_client->cl_implid; 282 + 283 + if (!impl_id || strlen(impl_id->domain) == 0) 284 + return 0; //sysfs_emit(buf, ""); 285 + return sysfs_emit(buf, "%s\n", impl_id->domain); 286 + } 287 + 288 + static struct kobj_attribute nfs_sysfs_attr_implid_domain = __ATTR_RO(implid_domain); 289 + 290 + 291 + static ssize_t 292 + implid_name_show(struct kobject *kobj, struct kobj_attribute *attr, 293 + char *buf) 294 + { 295 + struct nfs_server *server = container_of(kobj, struct nfs_server, kobj); 296 + struct nfs41_impl_id *impl_id = server->nfs_client->cl_implid; 297 + 298 + if (!impl_id || strlen(impl_id->name) == 0) 299 + return 0; //sysfs_emit(buf, ""); 300 + return sysfs_emit(buf, "%s\n", impl_id->name); 301 + } 302 + 303 + static struct kobj_attribute nfs_sysfs_attr_implid_name = __ATTR_RO(implid_name); 304 + 305 + #endif /* IS_ENABLED(CONFIG_NFS_V4_1) */ 306 + 275 307 #define RPC_CLIENT_NAME_SIZE 64 276 308 277 309 void nfs_sysfs_link_rpc_client(struct nfs_server *server, ··· 341 309 .child_ns_type = nfs_netns_object_child_ns_type, 342 310 }; 343 311 312 + #if IS_ENABLED(CONFIG_NFS_V4_1) 313 + static void nfs_sysfs_add_nfsv41_server(struct nfs_server *server) 314 + { 315 + int ret; 316 + 317 + if (!server->nfs_client->cl_implid) 318 + return; 319 + 320 + ret = sysfs_create_file_ns(&server->kobj, &nfs_sysfs_attr_implid_domain.attr, 321 + nfs_netns_server_namespace(&server->kobj)); 322 + if (ret < 0) 323 + pr_warn("NFS: sysfs_create_file_ns for server-%d failed (%d)\n", 324 + server->s_sysfs_id, ret); 325 + 326 + ret = sysfs_create_file_ns(&server->kobj, &nfs_sysfs_attr_implid_name.attr, 327 + nfs_netns_server_namespace(&server->kobj)); 328 + if (ret < 0) 329 + pr_warn("NFS: sysfs_create_file_ns for server-%d failed (%d)\n", 330 + server->s_sysfs_id, ret); 331 + } 332 + #else /* CONFIG_NFS_V4_1 */ 333 + static inline void nfs_sysfs_add_nfsv41_server(struct nfs_server *server) 334 + { 335 + } 336 + #endif /* CONFIG_NFS_V4_1 */ 337 + 344 338 void nfs_sysfs_add_server(struct nfs_server *server) 345 339 { 346 340 int ret; ··· 383 325 if (ret < 0) 384 326 pr_warn("NFS: sysfs_create_file_ns for server-%d failed (%d)\n", 385 327 server->s_sysfs_id, ret); 328 + 329 + nfs_sysfs_add_nfsv41_server(server); 386 330 } 387 331 EXPORT_SYMBOL_GPL(nfs_sysfs_add_server); 388 332