From: Christian Schoenebeck <linux_oss@crudebyte.com>
To: v9fs-developer@lists.sourceforge.net,
Eric Van Hensbergen <ericvh@gmail.com>,
Dominique Martinet <asmadeus@codewreck.org>
Cc: Latchesar Ionkov <lucho@ionkov.net>,
linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Pengfei Xu <pengfei.xu@intel.com>,
Dominique Martinet <asmadeus@codewreck.org>
Subject: Re: [PATCH 1/5] 9p/net: move code in preparation of async rpc
Date: Mon, 13 Feb 2023 18:46:13 +0100 [thread overview]
Message-ID: <1847623.mNM4OxGzmo@silver> (raw)
In-Reply-To: <20230211075023.137253-2-asmadeus@codewreck.org>
On Saturday, February 11, 2023 8:50:19 AM CET Dominique Martinet wrote:
> This commit containers no code change:
> - move p9_fid_* higher in code as p9_fid_destroy will be used
> in async callback
I would have just added p9_fid_destroy()'s prototype earlier in code instead
of moving stuff around:
static void p9_fid_destroy(struct p9_fid *fid);
Because that would not mess with 'git blame' history. But anyway, it's just
restructuring, no behaviour change, so:
Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
> - move p9_client_flush as it will no longer call p9_client_rpc
> and can simplify forward declaration a bit later
>
> This just simplifies the next commits to make diffs cleaner.
>
> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
> ---
> net/9p/client.c | 198 ++++++++++++++++++++++++------------------------
> 1 file changed, 99 insertions(+), 99 deletions(-)
>
> diff --git a/net/9p/client.c b/net/9p/client.c
> index 622ec6a586ee..53ebd07c36ee 100644
> --- a/net/9p/client.c
> +++ b/net/9p/client.c
> @@ -428,6 +428,66 @@ static void p9_tag_cleanup(struct p9_client *c)
> rcu_read_unlock();
> }
>
> +static struct p9_fid *p9_fid_create(struct p9_client *clnt)
> +{
> + int ret;
> + struct p9_fid *fid;
> +
> + p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt);
> + fid = kzalloc(sizeof(*fid), GFP_KERNEL);
> + if (!fid)
> + return NULL;
> +
> + fid->mode = -1;
> + fid->uid = current_fsuid();
> + fid->clnt = clnt;
> + refcount_set(&fid->count, 1);
> +
> + idr_preload(GFP_KERNEL);
> + spin_lock_irq(&clnt->lock);
> + ret = idr_alloc_u32(&clnt->fids, fid, &fid->fid, P9_NOFID - 1,
> + GFP_NOWAIT);
> + spin_unlock_irq(&clnt->lock);
> + idr_preload_end();
> + if (!ret) {
> + trace_9p_fid_ref(fid, P9_FID_REF_CREATE);
> + return fid;
> + }
> +
> + kfree(fid);
> + return NULL;
> +}
> +
> +static void p9_fid_destroy(struct p9_fid *fid)
> +{
> + struct p9_client *clnt;
> + unsigned long flags;
> +
> + p9_debug(P9_DEBUG_FID, "fid %d\n", fid->fid);
> + trace_9p_fid_ref(fid, P9_FID_REF_DESTROY);
> + clnt = fid->clnt;
> + spin_lock_irqsave(&clnt->lock, flags);
> + idr_remove(&clnt->fids, fid->fid);
> + spin_unlock_irqrestore(&clnt->lock, flags);
> + kfree(fid->rdir);
> + kfree(fid);
> +}
> +
> +/* We also need to export tracepoint symbols for tracepoint_enabled() */
> +EXPORT_TRACEPOINT_SYMBOL(9p_fid_ref);
> +
> +void do_trace_9p_fid_get(struct p9_fid *fid)
> +{
> + trace_9p_fid_ref(fid, P9_FID_REF_GET);
> +}
> +EXPORT_SYMBOL(do_trace_9p_fid_get);
> +
> +void do_trace_9p_fid_put(struct p9_fid *fid)
> +{
> + trace_9p_fid_ref(fid, P9_FID_REF_PUT);
> +}
> +EXPORT_SYMBOL(do_trace_9p_fid_put);
> +
> /**
> * p9_client_cb - call back from transport to client
> * @c: client state
> @@ -570,6 +630,45 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
> return err;
> }
>
> +static struct p9_req_t *p9_client_prepare_req(struct p9_client *c,
> + int8_t type, uint t_size, uint r_size,
> + const char *fmt, va_list ap)
> +{
> + int err;
> + struct p9_req_t *req;
> + va_list apc;
> +
> + p9_debug(P9_DEBUG_MUX, "client %p op %d\n", c, type);
> +
> + /* we allow for any status other than disconnected */
> + if (c->status == Disconnected)
> + return ERR_PTR(-EIO);
> +
> + /* if status is begin_disconnected we allow only clunk request */
> + if (c->status == BeginDisconnect && type != P9_TCLUNK)
> + return ERR_PTR(-EIO);
> +
> + va_copy(apc, ap);
> + req = p9_tag_alloc(c, type, t_size, r_size, fmt, apc);
> + va_end(apc);
> + if (IS_ERR(req))
> + return req;
> +
> + /* marshall the data */
> + p9pdu_prepare(&req->tc, req->tc.tag, type);
> + err = p9pdu_vwritef(&req->tc, c->proto_version, fmt, ap);
> + if (err)
> + goto reterr;
> + p9pdu_finalize(c, &req->tc);
> + trace_9p_client_req(c, type, req->tc.tag);
> + return req;
> +reterr:
> + p9_req_put(c, req);
> + /* We have to put also the 2nd reference as it won't be used */
> + p9_req_put(c, req);
> + return ERR_PTR(err);
> +}
> +
> static struct p9_req_t *
> p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...);
>
> @@ -613,45 +712,6 @@ static int p9_client_flush(struct p9_client *c, struct p9_req_t *oldreq)
> return 0;
> }
>
> -static struct p9_req_t *p9_client_prepare_req(struct p9_client *c,
> - int8_t type, uint t_size, uint r_size,
> - const char *fmt, va_list ap)
> -{
> - int err;
> - struct p9_req_t *req;
> - va_list apc;
> -
> - p9_debug(P9_DEBUG_MUX, "client %p op %d\n", c, type);
> -
> - /* we allow for any status other than disconnected */
> - if (c->status == Disconnected)
> - return ERR_PTR(-EIO);
> -
> - /* if status is begin_disconnected we allow only clunk request */
> - if (c->status == BeginDisconnect && type != P9_TCLUNK)
> - return ERR_PTR(-EIO);
> -
> - va_copy(apc, ap);
> - req = p9_tag_alloc(c, type, t_size, r_size, fmt, apc);
> - va_end(apc);
> - if (IS_ERR(req))
> - return req;
> -
> - /* marshall the data */
> - p9pdu_prepare(&req->tc, req->tc.tag, type);
> - err = p9pdu_vwritef(&req->tc, c->proto_version, fmt, ap);
> - if (err)
> - goto reterr;
> - p9pdu_finalize(c, &req->tc);
> - trace_9p_client_req(c, type, req->tc.tag);
> - return req;
> -reterr:
> - p9_req_put(c, req);
> - /* We have to put also the 2nd reference as it won't be used */
> - p9_req_put(c, req);
> - return ERR_PTR(err);
> -}
> -
> /**
> * p9_client_rpc - issue a request and wait for a response
> * @c: client session
> @@ -838,66 +898,6 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type,
> return ERR_PTR(safe_errno(err));
> }
>
> -static struct p9_fid *p9_fid_create(struct p9_client *clnt)
> -{
> - int ret;
> - struct p9_fid *fid;
> -
> - p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt);
> - fid = kzalloc(sizeof(*fid), GFP_KERNEL);
> - if (!fid)
> - return NULL;
> -
> - fid->mode = -1;
> - fid->uid = current_fsuid();
> - fid->clnt = clnt;
> - refcount_set(&fid->count, 1);
> -
> - idr_preload(GFP_KERNEL);
> - spin_lock_irq(&clnt->lock);
> - ret = idr_alloc_u32(&clnt->fids, fid, &fid->fid, P9_NOFID - 1,
> - GFP_NOWAIT);
> - spin_unlock_irq(&clnt->lock);
> - idr_preload_end();
> - if (!ret) {
> - trace_9p_fid_ref(fid, P9_FID_REF_CREATE);
> - return fid;
> - }
> -
> - kfree(fid);
> - return NULL;
> -}
> -
> -static void p9_fid_destroy(struct p9_fid *fid)
> -{
> - struct p9_client *clnt;
> - unsigned long flags;
> -
> - p9_debug(P9_DEBUG_FID, "fid %d\n", fid->fid);
> - trace_9p_fid_ref(fid, P9_FID_REF_DESTROY);
> - clnt = fid->clnt;
> - spin_lock_irqsave(&clnt->lock, flags);
> - idr_remove(&clnt->fids, fid->fid);
> - spin_unlock_irqrestore(&clnt->lock, flags);
> - kfree(fid->rdir);
> - kfree(fid);
> -}
> -
> -/* We also need to export tracepoint symbols for tracepoint_enabled() */
> -EXPORT_TRACEPOINT_SYMBOL(9p_fid_ref);
> -
> -void do_trace_9p_fid_get(struct p9_fid *fid)
> -{
> - trace_9p_fid_ref(fid, P9_FID_REF_GET);
> -}
> -EXPORT_SYMBOL(do_trace_9p_fid_get);
> -
> -void do_trace_9p_fid_put(struct p9_fid *fid)
> -{
> - trace_9p_fid_ref(fid, P9_FID_REF_PUT);
> -}
> -EXPORT_SYMBOL(do_trace_9p_fid_put);
> -
> static int p9_client_version(struct p9_client *c)
> {
> int err = 0;
>
next prev parent reply other threads:[~2023-02-13 17:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-11 7:50 [PATCH 0/5] Take 3 at async RPCs and no longer looping forever on signals Dominique Martinet
2023-02-11 7:50 ` [PATCH 1/5] 9p/net: move code in preparation of async rpc Dominique Martinet
2023-02-13 17:46 ` Christian Schoenebeck [this message]
2023-02-11 7:50 ` [PATCH 2/5] 9p/net: share pooled receive buffers size exception in p9_tag_alloc Dominique Martinet
2023-02-13 18:06 ` Christian Schoenebeck
2023-02-11 7:50 ` [PATCH 3/5] 9p/net: implement asynchronous rpc skeleton Dominique Martinet
2023-02-11 7:50 ` [PATCH 4/5] 9p/net: add async clunk for retries Dominique Martinet
2023-02-11 7:50 ` [PATCH 5/5] 9p/net: make flush asynchronous Dominique Martinet
2023-02-11 8:05 ` [PATCH 0/5] Take 3 at async RPCs and no longer looping forever on signals Dominique Martinet
2023-02-13 18:26 ` Christian Schoenebeck
2023-02-13 18:45 ` Christian Schoenebeck
2023-02-13 22:37 ` Dominique Martinet
2023-02-14 9:34 ` Christian Schoenebeck
2023-02-14 11:16 ` Dominique Martinet
2023-03-19 11:53 ` [V9fs-developer] " Dominique Martinet
2023-03-23 15:58 ` Christian Schoenebeck
2023-03-25 12:45 ` Christian Schoenebeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1847623.mNM4OxGzmo@silver \
--to=linux_oss@crudebyte.com \
--cc=asmadeus@codewreck.org \
--cc=axboe@kernel.dk \
--cc=ericvh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucho@ionkov.net \
--cc=pengfei.xu@intel.com \
--cc=v9fs-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox