linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about sg_count_fuse_req() in linux/fs/fuse/virtio_fs.c
@ 2021-03-17 18:12 Connor Kuehl
  2021-03-18 13:56 ` Vivek Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Connor Kuehl @ 2021-03-17 18:12 UTC (permalink / raw)
  To: virtio-fs
  Cc: vgoyal, stefanha, miklos, virtualization, linux-fsdevel, linux-kernel

Hi,

I've been familiarizing myself with the virtiofs guest kernel module and 
I'm trying to better understand how virtiofs maps a FUSE request into 
scattergather lists.

sg_count_fuse_req() starts knowing that there will be at least one in 
header, as shown here (which makes sense):

         unsigned int size, total_sgs = 1 /* fuse_in_header */;

However, I'm confused about this snippet right beneath it:

         if (args->in_numargs - args->in_pages)
                 total_sgs += 1;

What is the significance of the sg that is needed in the cases where 
this branch is taken? I'm not sure what its relationship is with 
args->in_numargs since it will increment total_sgs regardless 
args->in_numargs is 3, 2, or even 1 if args->in_pages is false.

Especially since the block right below it counts pages if args->in_pages 
is true:

         if (args->in_pages) {
                 size = args->in_args[args->in_numargs - 1].size;
                 total_sgs += sg_count_fuse_pages(ap->descs, ap->num_pages,
                                                  size);
         }

The rest of the routine goes on similarly but for the 'out' components.

I doubt incrementing 'total_sgs' in the first if-statement I showed 
above is vestigial, I just think my mental model of what is happening 
here is incomplete.

Any clarification is much appreciated!

Connor


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-18 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 18:12 Question about sg_count_fuse_req() in linux/fs/fuse/virtio_fs.c Connor Kuehl
2021-03-18 13:56 ` Vivek Goyal
2021-03-18 13:58   ` Connor Kuehl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).