Skip to content

fuse: optimize scatter-gather direct IO

Maxim Patlasov lkml 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest12 patches 0 repliesNew
  2. v211 patches 9 repliesSuperseded
  3. v16 patches 10 repliesSuperseded

Changes in v3 from the cover letter

- used iov_iter in fuse_get_user_pages() and __fuse_direct_io()
- zeroed req->pages[] array on allocation
- a bunch of minor cleanup changes:
- used unsigned for npages
- freed req->pages[] and req->page_descs[] together
- renamed fuse_get_ua() to fuse_get_user_addr()
- renamed fuse_get_fr_sz() to fuse_get_user_size()
- simplified loop in fuse_page_descs_length_init()
- rebased on v3.7-rc2

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12fuse: general infrastructure for pages[] of variable sizefs/fuse/dev.c fs/fuse/file.c fs/fuse/fuse_i.h +1 more+50 -200 replies
2/12fuse: categorize fuse_get_req()fs/fuse/cuse.c fs/fuse/dev.c fs/fuse/dir.c +3 more+56 -440 replies
3/12fuse: rework fuse_retrieve()fs/fuse/dev.c+15 -100 replies
4/12fuse: rework fuse_readpages()fs/fuse/file.c+14 -20 replies
5/12fuse: rework fuse_perform_write()fs/fuse/file.c+11 -20 replies
6/12fuse: rework fuse_do_ioctl()fs/fuse/file.c+1 -10 replies
7/12fuse: add per-page descriptor <offset, length> to fuse_reqfs/fuse/dev.c fs/fuse/file.c fs/fuse/fuse_i.h+37 -160 replies
8/12fuse: use req->page_descs[] for argpages casesfs/fuse/cuse.c fs/fuse/dev.c fs/fuse/dir.c +1 more+25 -40 replies
9/12mm: minor cleanup of iov_iter_single_seg_count()include/linux/fs.h mm/filemap.c+2 -20 replies
10/12fuse: pass iov[] to fuse_get_user_pages()fs/fuse/file.c+49 -540 replies
11/12fuse: optimize fuse_get_user_pages()fs/fuse/file.c+51 -280 replies
12/12fuse: optimize __fuse_direct_io()fs/fuse/file.c+21 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 00/12] fuse: optimize scatter-gather direct IO

Hi,

Existing fuse implementation processes scatter-gather direct IO in suboptimal
way: fuse_direct_IO passes iovec[] to fuse_loop_dio and the latter calls fuse_direct_read/write for each iovec from iovec[] array. Thus we have as many submitted fuse-requests as the number of elements in iovec[] array. This is pure waste of resources and affects performance negatively especially for the case of many small chunks (e.g. page-size) packed in one iovec[] array.

The patch-set amends situation in a natural way: let's simply pack as many iovec[] segments to every fuse-request as possible.

To estimate performance improvement I used slightly modified fusexmp over tmpfs (clearing O_DIRECT bit from fi->flags in xmp_open). The test opened a file with O_DIRECT, then called readv/writev in a loop. An iovec[] for readv/writev consisted of 32 segments of 4K each. The throughput on some commodity (rather feeble) server was (in MB/sec):

original / patched

writev: ~107     / ~480
readv:  ~114     / ~569

We're exploring possibility to use fuse for our own distributed storage implementation and big iovec[] arrays of many page-size chunks is typical use-case for device virtualization thread performing i/o on behalf of virtual-machine it serves.

Changed in v2:
- inline array of page pointers req->pages[] is replaced with dynamically allocated one; the number of elements is calculated a bit more intelligently than being equal to FUSE_MAX_PAGES_PER_REQ; this is done for the sake of memory economy.
- a dynamically allocated array of so-called 'page descriptors' - an offset in page plus the length of fragment - is added to fuse_req; this is done to simplify processing fuse requests covering several iov-s.

Changed in v3:
- used iov_iter in fuse_get_user_pages() and __fuse_direct_io()
- zeroed req->pages[] array on allocation
- a bunch of minor cleanup changes:
- used unsigned for npages
- freed req->pages[] and req->page_descs[] together
- renamed fuse_get_ua() to fuse_get_user_addr()
- renamed fuse_get_fr_sz() to fuse_get_user_size()
- simplified loop in fuse_page_descs_length_init()
- rebased on v3.7-rc2

Thanks,
Maxim

---

Maxim Patlasov (12):
fuse: general infrastructure for pages[] of variable size
fuse: categorize fuse_get_req()
fuse: rework fuse_retrieve()
fuse: rework fuse_readpages()
fuse: rework fuse_perform_write()
fuse: rework fuse_do_ioctl()
fuse: add per-page descriptor <offset, length> to fuse_req
fuse: use req->page_descs[] for argpages cases
mm: minor cleanup of iov_iter_single_seg_count()
fuse: pass iov[] to fuse_get_user_pages()
fuse: optimize fuse_get_user_pages()
fuse: optimize __fuse_direct_io()

 fs/fuse/cuse.c     |    3 -
 fs/fuse/dev.c      |   98 +++++++++++++++------
 fs/fuse/dir.c      |   39 ++++----
 fs/fuse/file.c     |  242 ++++++++++++++++++++++++++++++++++------------------
 fs/fuse/fuse_i.h   |   47 ++++++++--
 fs/fuse/inode.c    |    6 +
 include/linux/fs.h |    2 
 mm/filemap.c       |    2 
 8 files changed, 292 insertions(+), 147 deletions(-)
Signature · 1 line
Signature