net/9p: distinguish zero-copy requests
authorChristian Schoenebeck <linux_oss@crudebyte.com>
Tue, 22 Nov 2022 19:20:22 +0000 (20:20 +0100)
committerDominique Martinet <asmadeus@codewreck.org>
Mon, 5 Dec 2022 22:30:55 +0000 (07:30 +0900)
Add boolean `zc` member to struct p9_fcall to distinguish zero-copy
messages (not using the linear `sdata` buffer for message payload) from
regular messages (which do copy message payload to `sdata` before being
further processed).

This new member is appended to end of structure to avoid inserting huge
padding in generated layout.

Link: https://lkml.kernel.org/r/8f2a5c12a446c3b544da64e0b1550e1fb2d6f972.1669144861.git.linux_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <linux_oss@crudebyte.com>
Tested-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
include/net/9p/9p.h
net/9p/client.c

index 13abe013af21cd331464c23acb5a561224d4244a..429adf6be29cd00a46ca8541dd1ee28b81043da1 100644 (file)
@@ -531,6 +531,7 @@ struct p9_rstatfs {
  * @offset: used by marshalling routines to track current position in buffer
  * @capacity: used by marshalling routines to track total malloc'd capacity
  * @sdata: payload
+ * @zc: whether zero-copy is used
  *
  * &p9_fcall represents the structure for all 9P RPC
  * transactions.  Requests are packaged into fcalls, and reponses
@@ -549,6 +550,7 @@ struct p9_fcall {
 
        struct kmem_cache *cache;
        u8 *sdata;
+       bool zc;
 };
 
 int p9_errstr2errno(char *errstr, int len);
index b554f8357f96730356dd24cb88f982638abb4207..a2b4a965a5a99e82ac881299bbd917feed0ca459 100644 (file)
@@ -685,6 +685,9 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
        if (IS_ERR(req))
                return req;
 
+       req->tc.zc = false;
+       req->rc.zc = false;
+
        if (signal_pending(current)) {
                sigpending = 1;
                clear_thread_flag(TIF_SIGPENDING);
@@ -783,6 +786,9 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type,
        if (IS_ERR(req))
                return req;
 
+       req->tc.zc = true;
+       req->rc.zc = true;
+
        if (signal_pending(current)) {
                sigpending = 1;
                clear_thread_flag(TIF_SIGPENDING);