Re: [PATCH 10/10] nfsd: use path_clone()

From: Jan Kara

Date: Mon Sep 14 2026 - 05:38:57 EST


On Sun 13-09-26 16:49:17, Mateusz Guzik wrote:
> No functional changes.
>
> Signed-off-by: Mateusz Guzik <mjguzik@xxxxxxxxx>

It would be good to CC NFSD folks on this so they are aware this is
happening (along with at least the cover letter and the patch introducing
the helpers). But the change looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> fs/nfsd/export.c | 6 ++----
> fs/nfsd/nfs4xdr.c | 8 ++++----
> 2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index e5a0f1ababe6..84ea833816b5 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -233,8 +233,7 @@ static inline void expkey_update(struct cache_head *cnew,
> struct svc_expkey *new = container_of(cnew, struct svc_expkey, h);
> struct svc_expkey *item = container_of(citem, struct svc_expkey, h);
>
> - new->ek_path = item->ek_path;
> - path_get(&item->ek_path);
> + path_clone(&item->ek_path, &new->ek_path);
> }
>
> static struct cache_head *expkey_alloc(void)
> @@ -1533,8 +1532,7 @@ static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
>
> kref_get(&item->ex_client->ref);
> new->ex_client = item->ex_client;
> - new->ex_path = item->ex_path;
> - path_get(&item->ex_path);
> + path_clone(&item->ex_path, &new->ex_path);
> new->ex_fslocs.locations = NULL;
> new->ex_fslocs.locations_count = 0;
> new->ex_fslocs.migrated = 0;
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 7d1b2d6f57f2..65a805501b75 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -2966,14 +2966,14 @@ static __be32 nfsd4_encode_pathname4(struct xdr_stream *xdr,
> const struct path *root,
> const struct path *path)
> {
> - struct path cur = *path;
> + struct path cur;
> struct dentry **components = NULL;
> unsigned int ncomponents = 0;
> __be32 err = nfserr_jukebox;
>
> dprintk("nfsd4_encode_components(");
>
> - path_get(&cur);
> + path_clone(path, &cur);
> /* First walk the path up to the nfsd root, and store the
> * dentries/path components in an array.
> */
> @@ -3216,11 +3216,11 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *bmval2, u32
>
> static int nfsd4_get_mounted_on_ino(struct svc_export *exp, u64 *pino)
> {
> - struct path path = exp->ex_path;
> + struct path path;
> struct kstat stat;
> int err;
>
> - path_get(&path);
> + path_clone(&exp->ex_path, &path);
> while (follow_up(&path)) {
> if (path.dentry != path.mnt->mnt_root)
> break;
> --
> 2.53.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR