netfs: Do copy-to-cache-on-read through VM writeback
When data is read from the server and intended to be copied to the cache,
offload the cache write to the VM writeback mechanism rather than
scheduling it immediately. This allows the downloaded data to be
superseded by local changes before it is written to the cache and means
that we no longer need to use the PG_fscache flag.
This is done by the following means:
(1) The pages just downloaded into are marked dirty in
netfs_rreq_unlock().
(2) A region of NETFS_REGION_CACHE_COPY type is added to the dirty region
list.
(3) If a region-to-be-modified overlaps the cache-copy region, the
modifications supersede the download, moving the end marker over in
netfs_merge_dirty_region().
(4) We don't really want to supersede in the middle of a region, so we may
split a pristine region so that we can supersede forwards only.
(5) We mark regions we're going to supersede with NETFS_REGION_SUPERSEDED
to prevent them getting merged whilst we're superseding them. This
flag is cleared when we're done and we may merge afterwards.
(6) Adjacent download regions are potentially mergeable.
(7) When being flushed, CACHE_COPY regions are intended only to be written
to the cache, not the server, though they may contribute data to a
cross-page chunk that has to be encrypted or compressed and sent to
the server.
Signed-off-by: David Howells <dhowells@redhat.com>
9 files changed