diff options
author | Al Viro | 2021-05-02 11:13:09 -0400 |
---|---|---|
committer | Al Viro | 2021-06-10 11:45:19 -0400 |
commit | 622838f3fde2c3671a718dc6196c19087ebe9b11 (patch) | |
tree | 01144487443e697d06bbad0bde78a63752c2f4f9 /fs/btrfs/raid56.h | |
parent | 21b56c84775351ac66354c9b09fb429e5cdeceac (diff) |
iov_iter: make the amount already copied available to iterator callbacks
Making iterator macros keep track of the amount of data copied is pretty
easy and it has several benefits:
1) we no longer need the mess like (from += v.iov_len) - v.iov_len
in the callbacks - initial value + total amount copied so far would do
just fine.
2) less obviously, we no longer need to remember the initial amount
of data we wanted to copy; the loops in iterator macros are along the lines
of
wanted = bytes;
while (bytes) {
copy some
bytes -= copied
if short copy
break
}
bytes = wanted - bytes;
Replacement is
offs = 0;
while (bytes) {
copy some
offs += copied
bytes -= copied
if short copy
break
}
bytes = offs;
That wouldn't be a win per se, but unlike the initial value of bytes, the amount
copied so far *is* useful in callbacks.
3) in some cases (csum_and_copy_..._iter()) we already had offs manually
maintained by the callbacks. With that change we can drop that.
Less boilerplate and more readable code...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/btrfs/raid56.h')
0 files changed, 0 insertions, 0 deletions