diff options
author | Chirantan Ekbote <chirantan@chromium.org> | 2020-05-08 20:50:58 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-14 17:09:56 +0000 |
commit | c569a579fe674773807b888f2eb65b23405c53b9 (patch) | |
tree | f3b43fd53da06d850b57d06385c288dae39fa8f4 /devices/src/virtio/fs | |
parent | 6db9f9f58a095ee9a70c8edb6563aaf7027cb278 (diff) | |
download | crosvm-c569a579fe674773807b888f2eb65b23405c53b9.tar crosvm-c569a579fe674773807b888f2eb65b23405c53b9.tar.gz crosvm-c569a579fe674773807b888f2eb65b23405c53b9.tar.bz2 crosvm-c569a579fe674773807b888f2eb65b23405c53b9.tar.lz crosvm-c569a579fe674773807b888f2eb65b23405c53b9.tar.xz crosvm-c569a579fe674773807b888f2eb65b23405c53b9.tar.zst crosvm-c569a579fe674773807b888f2eb65b23405c53b9.zip |
descriptor_utils: Remove need for temporary vectors
Refactor the DescriptorChainConsumer, Reader, and Writer structs so that we don't have to allocate a Vec on the heap every time we read or write from a DescriptorChain. This should hopefully give us some small performance improvements as well as simplify the code in some places. Also switch from VolatileSlices to iovecs so that it's easier to use these structs with io_uring. Otherwise we would end up allocating temporary vectors to convert from VolatlieSlice to iovec. BUG=none TEST=unit tests Change-Id: I1657bc76cfff084df825dbbdc8ff414740b71a8f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2190106 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'devices/src/virtio/fs')
-rw-r--r-- | devices/src/virtio/fs/server.rs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/devices/src/virtio/fs/server.rs b/devices/src/virtio/fs/server.rs index 33b7c98..c1af80c 100644 --- a/devices/src/virtio/fs/server.rs +++ b/devices/src/virtio/fs/server.rs @@ -496,10 +496,7 @@ impl<F: FileSystem + Sync> Server<F> { }; // Split the writer into 2 pieces: one for the `OutHeader` and the rest for the data. - let data_writer = ZCWriter( - w.split_at(size_of::<OutHeader>()) - .map_err(Error::InvalidDescriptorChain)?, - ); + let data_writer = ZCWriter(w.split_at(size_of::<OutHeader>())); match self.fs.read( Context::from(in_header), @@ -910,9 +907,7 @@ impl<F: FileSystem + Sync> Server<F> { } // Skip over enough bytes for the header. - let mut cursor = w - .split_at(size_of::<OutHeader>()) - .map_err(Error::InvalidDescriptorChain)?; + let mut cursor = w.split_at(size_of::<OutHeader>()); let res = if plus { self.fs.readdirplus( |