From: David Howells <dhowells@redhat.com>
To: Viacheslav Dubeyko <slava@dubeyko.com>,
Alex Markuze <amarkuze@redhat.com>
Cc: David Howells <dhowells@redhat.com>,
Ilya Dryomov <idryomov@gmail.com>,
Jeff Layton <jlayton@kernel.org>,
Dongsheng Yang <dongsheng.yang@easystack.cn>,
ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 23/35] rbd: Use ceph_databuf_enc_start/stop()
Date: Thu, 13 Mar 2025 23:33:15 +0000 [thread overview]
Message-ID: <20250313233341.1675324-24-dhowells@redhat.com> (raw)
In-Reply-To: <20250313233341.1675324-1-dhowells@redhat.com>
Make rbd use ceph_databuf_enc_start() and ceph_databuf_enc_stop() when
filling out the request data. Also use ceph_encode_*() rather than
ceph_databuf_encode_*() as the latter will do an iterator copy to deal with
page crossing and misalignment (the latter being something that the CPU
will handle on some arches).
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Viacheslav Dubeyko <slava@dubeyko.com>
cc: Alex Markuze <amarkuze@redhat.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: ceph-devel@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
drivers/block/rbd.c | 64 ++++++++++++++++++++++-----------------------
1 file changed, 31 insertions(+), 33 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index a2674077edea..956fc4a8f1da 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1970,19 +1970,19 @@ static int rbd_cls_object_map_update(struct ceph_osd_request *req,
int which, u64 objno, u8 new_state,
const u8 *current_state)
{
- struct ceph_databuf *dbuf;
- void *p, *start;
+ struct ceph_databuf *request;
+ void *p;
int ret;
ret = osd_req_op_cls_init(req, which, "rbd", "object_map_update");
if (ret)
return ret;
- dbuf = ceph_databuf_req_alloc(1, PAGE_SIZE, GFP_NOIO);
- if (!dbuf)
+ request = ceph_databuf_req_alloc(1, 8 * 2 + 3 * 1, GFP_NOIO);
+ if (!request)
return -ENOMEM;
- p = start = kmap_ceph_databuf_page(dbuf, 0);
+ p = ceph_databuf_enc_start(request);
ceph_encode_64(&p, objno);
ceph_encode_64(&p, objno + 1);
ceph_encode_8(&p, new_state);
@@ -1992,10 +1992,9 @@ static int rbd_cls_object_map_update(struct ceph_osd_request *req,
} else {
ceph_encode_8(&p, 0);
}
- kunmap_local(p);
- ceph_databuf_added_data(dbuf, p - start);
+ ceph_databuf_enc_stop(request, p);
- osd_req_op_cls_request_databuf(req, which, dbuf);
+ osd_req_op_cls_request_databuf(req, which, request);
return 0;
}
@@ -2108,7 +2107,7 @@ static int rbd_obj_calc_img_extents(struct rbd_obj_request *obj_req,
static int rbd_osd_setup_stat(struct ceph_osd_request *osd_req, int which)
{
- struct ceph_databuf *dbuf;
+ struct ceph_databuf *request;
/*
* The response data for a STAT call consists of:
@@ -2118,12 +2117,12 @@ static int rbd_osd_setup_stat(struct ceph_osd_request *osd_req, int which)
* le32 tv_nsec;
* } mtime;
*/
- dbuf = ceph_databuf_reply_alloc(1, 8 + sizeof(struct ceph_timespec), GFP_NOIO);
- if (!dbuf)
+ request = ceph_databuf_reply_alloc(1, 8 + sizeof(struct ceph_timespec), GFP_NOIO);
+ if (!request)
return -ENOMEM;
osd_req_op_init(osd_req, which, CEPH_OSD_OP_STAT, 0);
- osd_req_op_raw_data_in_databuf(osd_req, which, dbuf);
+ osd_req_op_raw_data_in_databuf(osd_req, which, request);
return 0;
}
@@ -2964,16 +2963,16 @@ static int rbd_obj_copyup_current_snapc(struct rbd_obj_request *obj_req,
static int setup_copyup_buf(struct rbd_obj_request *obj_req, u64 obj_overlap)
{
- struct ceph_databuf *dbuf;
+ struct ceph_databuf *request;
rbd_assert(!obj_req->copyup_buf);
- dbuf = ceph_databuf_req_alloc(calc_pages_for(0, obj_overlap),
+ request = ceph_databuf_req_alloc(calc_pages_for(0, obj_overlap),
obj_overlap, GFP_NOIO);
- if (!dbuf)
+ if (!request)
return -ENOMEM;
- obj_req->copyup_buf = dbuf;
+ obj_req->copyup_buf = request;
return 0;
}
@@ -4580,10 +4579,9 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
if (!request)
return -ENOMEM;
- p = kmap_ceph_databuf_page(request, 0);
- memcpy(p, outbound, outbound_size);
- kunmap_local(p);
- ceph_databuf_added_data(request, outbound_size);
+ p = ceph_databuf_enc_start(request);
+ ceph_encode_copy(&p, outbound, outbound_size);
+ ceph_databuf_enc_stop(request, p);
}
reply = ceph_databuf_reply_alloc(1, inbound_size, GFP_KERNEL);
@@ -4712,7 +4710,7 @@ static void rbd_free_disk(struct rbd_device *rbd_dev)
static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
struct ceph_object_id *oid,
struct ceph_object_locator *oloc,
- struct ceph_databuf *dbuf, int len)
+ struct ceph_databuf *request, int len)
{
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
struct ceph_osd_request *req;
@@ -4727,7 +4725,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
req->r_flags = CEPH_OSD_FLAG_READ;
osd_req_op_extent_init(req, 0, CEPH_OSD_OP_READ, 0, len, 0, 0);
- osd_req_op_extent_osd_databuf(req, 0, dbuf);
+ osd_req_op_extent_osd_databuf(req, 0, request);
ret = ceph_osdc_alloc_messages(req, GFP_KERNEL);
if (ret)
@@ -4750,16 +4748,16 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev,
bool first_time)
{
struct rbd_image_header_ondisk *ondisk;
- struct ceph_databuf *dbuf = NULL;
+ struct ceph_databuf *request = NULL;
u32 snap_count = 0;
u64 names_size = 0;
u32 want_count;
int ret;
- dbuf = ceph_databuf_req_alloc(1, sizeof(*ondisk), GFP_KERNEL);
- if (!dbuf)
+ request = ceph_databuf_req_alloc(1, sizeof(*ondisk), GFP_KERNEL);
+ if (!request)
return -ENOMEM;
- ondisk = kmap_ceph_databuf_page(dbuf, 0);
+ ondisk = kmap_ceph_databuf_page(request, 0);
/*
* The complete header will include an array of its 64-bit
@@ -4776,13 +4774,13 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev,
size += names_size;
ret = -ENOMEM;
- if (size > dbuf->limit &&
- ceph_databuf_reserve(dbuf, size - dbuf->limit,
+ if (size > request->limit &&
+ ceph_databuf_reserve(request, size - request->limit,
GFP_KERNEL) < 0)
goto out;
ret = rbd_obj_read_sync(rbd_dev, &rbd_dev->header_oid,
- &rbd_dev->header_oloc, dbuf, size);
+ &rbd_dev->header_oloc, request, size);
if (ret < 0)
goto out;
if ((size_t)ret < size) {
@@ -4806,7 +4804,7 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev,
ret = rbd_header_from_disk(header, ondisk, first_time);
out:
kunmap_local(ondisk);
- ceph_databuf_release(dbuf);
+ ceph_databuf_release(request);
return ret;
}
@@ -5625,10 +5623,10 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev,
if (!reply)
goto out_free;
- p = kmap_ceph_databuf_page(request, 0);
+ p = ceph_databuf_enc_start(request);
ceph_encode_64(&p, rbd_dev->spec->snap_id);
- kunmap_local(p);
- ceph_databuf_added_data(request, sizeof(__le64));
+ ceph_databuf_enc_stop(request, p);
+
ret = __get_parent_info(rbd_dev, request, reply, pii);
if (ret > 0)
ret = __get_parent_info_legacy(rbd_dev, request, reply, pii);
next prev parent reply other threads:[~2025-03-13 23:35 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 23:32 [RFC PATCH 00/35] ceph, rbd, netfs: Make ceph fully use netfslib David Howells
2025-03-13 23:32 ` [RFC PATCH 01/35] ceph: Fix incorrect flush end position calculation David Howells
2025-03-13 23:32 ` [RFC PATCH 02/35] libceph: Rename alignment to offset David Howells
2025-03-14 19:04 ` Viacheslav Dubeyko
2025-03-14 20:01 ` David Howells
2025-03-13 23:32 ` [RFC PATCH 03/35] libceph: Add a new data container type, ceph_databuf David Howells
2025-03-14 20:06 ` Viacheslav Dubeyko
2025-03-17 11:27 ` David Howells
2025-03-13 23:32 ` [RFC PATCH 04/35] ceph: Convert ceph_mds_request::r_pagelist to a databuf David Howells
2025-03-14 22:27 ` slava
2025-03-17 11:52 ` David Howells
2025-03-20 20:34 ` Viacheslav Dubeyko
2025-03-20 22:01 ` David Howells
2025-03-13 23:32 ` [RFC PATCH 05/35] libceph: Add functions to add ceph_databufs to requests David Howells
2025-03-13 23:32 ` [RFC PATCH 06/35] rbd: Use ceph_databuf for rbd_obj_read_sync() David Howells
2025-03-17 19:08 ` Viacheslav Dubeyko
2025-04-11 13:48 ` David Howells
2025-03-13 23:32 ` [RFC PATCH 07/35] libceph: Change ceph_osdc_call()'s reply to a ceph_databuf David Howells
2025-03-17 19:41 ` Viacheslav Dubeyko
2025-03-17 22:12 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 08/35] libceph: Unexport osd_req_op_cls_request_data_pages() David Howells
2025-03-13 23:33 ` [RFC PATCH 09/35] libceph: Remove osd_req_op_cls_response_data_pages() David Howells
2025-03-13 23:33 ` [RFC PATCH 10/35] libceph: Convert notify_id_pages to a ceph_databuf David Howells
2025-03-13 23:33 ` [RFC PATCH 11/35] ceph: Use ceph_databuf in DIO David Howells
2025-03-17 20:03 ` Viacheslav Dubeyko
2025-03-17 22:26 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 12/35] libceph: Bypass the messenger-v1 Tx loop for databuf/iter data blobs David Howells
2025-03-13 23:33 ` [RFC PATCH 13/35] rbd: Switch from using bvec_iter to iov_iter David Howells
2025-03-18 19:38 ` Viacheslav Dubeyko
2025-03-18 22:13 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 14/35] libceph: Remove bvec and bio data container types David Howells
2025-03-13 23:33 ` [RFC PATCH 15/35] libceph: Make osd_req_op_cls_init() use a ceph_databuf and map it David Howells
2025-03-13 23:33 ` [RFC PATCH 16/35] libceph: Convert req_page of ceph_osdc_call() to ceph_databuf David Howells
2025-03-13 23:33 ` [RFC PATCH 17/35] libceph, rbd: Use ceph_databuf encoding start/stop David Howells
2025-03-18 19:59 ` Viacheslav Dubeyko
2025-03-18 22:19 ` David Howells
2025-03-20 21:45 ` Viacheslav Dubeyko
2025-03-13 23:33 ` [RFC PATCH 18/35] libceph, rbd: Convert some page arrays to ceph_databuf David Howells
2025-03-18 20:02 ` Viacheslav Dubeyko
2025-03-18 22:25 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 19/35] libceph, ceph: Convert users of ceph_pagelist " David Howells
2025-03-18 20:09 ` Viacheslav Dubeyko
2025-03-18 22:27 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 20/35] libceph: Remove ceph_pagelist David Howells
2025-03-13 23:33 ` [RFC PATCH 21/35] libceph: Make notify code use ceph_databuf_enc_start/stop David Howells
2025-03-18 20:12 ` Viacheslav Dubeyko
2025-03-18 22:36 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 22/35] libceph, rbd: Convert ceph_osdc_notify() reply to ceph_databuf David Howells
2025-03-19 0:08 ` Viacheslav Dubeyko
2025-03-20 14:44 ` David Howells
2025-03-13 23:33 ` David Howells [this message]
2025-03-19 0:32 ` [RFC PATCH 23/35] rbd: Use ceph_databuf_enc_start/stop() Viacheslav Dubeyko
2025-03-20 14:59 ` Why use plain numbers and totals rather than predef'd constants for RPC sizes? David Howells
2025-03-20 21:48 ` Viacheslav Dubeyko
2025-03-13 23:33 ` [RFC PATCH 24/35] ceph: Make ceph_calc_file_object_mapping() return size as size_t David Howells
2025-03-13 23:33 ` [RFC PATCH 25/35] ceph: Wrap POSIX_FADV_WILLNEED to get caps David Howells
2025-03-13 23:33 ` [RFC PATCH 26/35] ceph: Kill ceph_rw_context David Howells
2025-03-13 23:33 ` [RFC PATCH 27/35] netfs: Pass extra write context to write functions David Howells
2025-03-13 23:33 ` [RFC PATCH 28/35] netfs: Adjust group handling David Howells
2025-03-19 18:57 ` Viacheslav Dubeyko
2025-03-20 15:22 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 29/35] netfs: Allow fs-private data to be handed through to request alloc David Howells
2025-03-13 23:33 ` [RFC PATCH 30/35] netfs: Make netfs_page_mkwrite() use folio_mkwrite_check_truncate() David Howells
2025-03-13 23:33 ` [RFC PATCH 31/35] netfs: Fix netfs_unbuffered_read() to return ssize_t rather than int David Howells
2025-03-13 23:33 ` [RFC PATCH 32/35] netfs: Add some more RMW support for ceph David Howells
2025-03-19 19:14 ` Viacheslav Dubeyko
2025-03-20 15:25 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 33/35] ceph: Use netfslib [INCOMPLETE] David Howells
2025-03-19 19:54 ` Viacheslav Dubeyko
2025-03-20 15:38 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 34/35] ceph: Enable multipage folios for ceph files David Howells
2025-03-13 23:33 ` [RFC PATCH 35/35] ceph: Remove old I/O API bits David Howells
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=20250313233341.1675324-24-dhowells@redhat.com \
--to=dhowells@redhat.com \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=dongsheng.yang@easystack.cn \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=slava@dubeyko.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.