Re: [PATCH 2/2] 9p: client_create: init fcall_cache earlier

From: Leon Romanovsky
Date: Thu Sep 29 2022 - 01:57:45 EST


On Thu, Sep 29, 2022 at 06:44:17AM +0900, Dominique Martinet wrote:
> fcall cache was init'd last for some reason, but we actually allocate
> some requests for the version check before that.
> Moving the cache creation towards the start also makes p9_client_destroy's
> order match the allocation order, which might be easier to think about
>
> Signed-off-by: Dominique Martinet <asmadeus@xxxxxxxxxxxxx>
> ---
> net/9p/client.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)

Please submit it properly. It is unclear to which series you are
referring.

>
> diff --git a/net/9p/client.c b/net/9p/client.c
> index 40b59431a566..1ea326e6e271 100644
> --- a/net/9p/client.c
> +++ b/net/9p/client.c
> @@ -977,6 +977,17 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
> if (err < 0)
> goto out;
>
> + /* P9_HDRSZ + 4 is the smallest packet header we can have that is
> + * followed by data accessed from userspace by read
> + * Note we do not check for failure here because the cache is
> + * optional; warning will be issued on dmesg for failure.
> + */
> + clnt->fcall_cache =
> + kmem_cache_create_usercopy("9p-fcall-cache", clnt->msize,
> + 0, 0, P9_HDRSZ + 4,
> + clnt->msize - (P9_HDRSZ + 4),
> + NULL);
> +

clnt->msize can be changed after call to ->create() if it is larger than clnt->trans_mod->maxsize).

> if (!clnt->trans_mod)
> clnt->trans_mod = v9fs_get_default_trans();
>
> @@ -1016,15 +1027,6 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
> if (err)
> goto out;
>
> - /* P9_HDRSZ + 4 is the smallest packet header we can have that is
> - * followed by data accessed from userspace by read
> - */
> - clnt->fcall_cache =
> - kmem_cache_create_usercopy("9p-fcall-cache", clnt->msize,
> - 0, 0, P9_HDRSZ + 4,
> - clnt->msize - (P9_HDRSZ + 4),
> - NULL);
> -
> return clnt;
>
> out:
> --
> 2.35.1
>