Re: [RFC PATCH 18/35] libceph, rbd: Convert some page arrays to ceph_databuf

From: David Howells
Date: Tue Mar 18 2025 - 18:26:02 EST


Viacheslav Dubeyko <Slava.Dubeyko@xxxxxxx> wrote:

> > /*
> > * The response data for a STAT call consists of:
> > @@ -2118,14 +2118,12 @@ static int rbd_osd_setup_stat(struct ceph_osd_request *osd_req, int which)
> > * le32 tv_nsec;
> > * } mtime;
> > */
> > - pages = ceph_alloc_page_vector(1, GFP_NOIO);
> > - if (IS_ERR(pages))
> > - return PTR_ERR(pages);
> > + dbuf = ceph_databuf_reply_alloc(1, 8 + sizeof(struct ceph_timespec), GFP_NOIO);
>
> What this 8 + sizeof(struct ceph_timespec) means? Why do we use 8 here? :)

See the comment that's partially obscured by the patch hunk line:

/*
* The response data for a STAT call consists of:
* le64 length;
* struct {
* le32 tv_sec;
* le32 tv_nsec;
* } mtime;
*/

If you want to clean up and formalise all of these sorts of things, you might
need to invest in an rpcgen-like tool. I've occasionally toyed with the idea
for afs in the kernel (I've hand-written all the marshalling/unmarshalling
code in fs/afs/fsclient.c, fs/afs/yfsclient.c and fs/afs/vlclient.c, but there
are some not-so-simple RPC calls to handle - FetchData and StoreData for
example).

David