Skip to content

Commit 62d2cde

Browse files
Mike SnitzerAnna Schumaker
authored andcommitted
NFS: add localio to sysfs
The Linux NFS client and server added support for LOCALIO in Linux v6.12. It is useful to know if a client and server negotiated LOCALIO be used, so expose it through the 'localio' attribute. Suggested-by: Anna Schumaker <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent f72a675 commit 62d2cde

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

fs/nfs/sysfs.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,33 @@ static inline void nfs_sysfs_add_nfsv41_server(struct nfs_server *server)
387387
}
388388
#endif /* CONFIG_NFS_V4_1 */
389389

390+
#if IS_ENABLED(CONFIG_NFS_LOCALIO)
391+
392+
static ssize_t
393+
localio_show(struct kobject *kobj, struct kobj_attribute *attr,
394+
char *buf)
395+
{
396+
struct nfs_server *server = container_of(kobj, struct nfs_server, kobj);
397+
bool localio = nfs_server_is_local(server->nfs_client);
398+
return sysfs_emit(buf, "%d\n", localio);
399+
}
400+
401+
static struct kobj_attribute nfs_sysfs_attr_localio = __ATTR_RO(localio);
402+
403+
static void nfs_sysfs_add_nfs_localio_server(struct nfs_server *server)
404+
{
405+
int ret = sysfs_create_file_ns(&server->kobj, &nfs_sysfs_attr_localio.attr,
406+
nfs_netns_server_namespace(&server->kobj));
407+
if (ret < 0)
408+
pr_warn("NFS: sysfs_create_file_ns for server-%d failed (%d)\n",
409+
server->s_sysfs_id, ret);
410+
}
411+
#else
412+
static inline void nfs_sysfs_add_nfs_localio_server(struct nfs_server *server)
413+
{
414+
}
415+
#endif /* IS_ENABLED(CONFIG_NFS_LOCALIO) */
416+
390417
void nfs_sysfs_add_server(struct nfs_server *server)
391418
{
392419
int ret;
@@ -405,6 +432,7 @@ void nfs_sysfs_add_server(struct nfs_server *server)
405432
server->s_sysfs_id, ret);
406433

407434
nfs_sysfs_add_nfsv41_server(server);
435+
nfs_sysfs_add_nfs_localio_server(server);
408436
}
409437
EXPORT_SYMBOL_GPL(nfs_sysfs_add_server);
410438

0 commit comments

Comments
 (0)