OpenCloudOS-Kernel/include
Al Viro 10f525a8cd ITER_PIPE: cache the type of last buffer
We often need to find whether the last buffer is anon or not, and
currently it's rather clumsy:
	check if ->iov_offset is non-zero (i.e. that pipe is not empty)
	if so, get the corresponding pipe_buffer and check its ->ops
	if it's &default_pipe_buf_ops, we have an anon buffer.

Let's replace the use of ->iov_offset (which is nowhere near similar to
its role for other flavours) with signed field (->last_offset), with
the following rules:
	empty, no buffers occupied:		0
	anon, with bytes up to N-1 filled:	N
	zero-copy, with bytes up to N-1 filled:	-N

That way abs(i->last_offset) is equal to what used to be in i->iov_offset
and empty vs. anon vs. zero-copy can be distinguished by the sign of
i->last_offset.

	Checks for "should we extend the last buffer or should we start
a new one?" become easier to follow that way.

	Note that most of the operations can only be done in a sane
state - i.e. when the pipe has nothing past the current position of
iterator.  About the only thing that could be done outside of that
state is iov_iter_advance(), which transitions to the sane state by
truncating the pipe.  There are only two cases where we leave the
sane state:
	1) iov_iter_get_pages()/iov_iter_get_pages_alloc().  Will be
dealt with later, when we make get_pages advancing - the callers are
actually happier that way.
	2) iov_iter copied, then something is put into the copy.  Since
they share the underlying pipe, the original gets behind.  When we
decide that we are done with the copy (original is not usable until then)
we advance the original.  direct_io used to be done that way; nowadays
it operates on the original and we do iov_iter_revert() to discard
the excessive data.  At the moment there's nothing in the kernel that
could do that to ITER_PIPE iterators, so this reason for insane state
is theoretical right now.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2022-08-08 22:37:18 -04:00
..
acpi Merge branches 'acpi-processor', 'acpi-apei' and 'acpi-ec' 2022-07-29 20:08:25 +02:00
asm-generic pci-v5.20-changes 2022-08-04 19:30:35 -07:00
clocksource - Add the missing DT bindings for the MTU nomadik timer (Linus 2022-07-28 12:33:34 +02:00
crypto for-5.20/block-2022-08-04 2022-08-04 20:00:14 -07:00
drm Driver uAPI changes: 2022-07-22 15:51:31 +10:00
dt-bindings The clk core gains a new set of APIs that allow drivers to both acquire clks 2022-08-04 18:40:08 -07:00
keys
kunit kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites 2022-07-11 17:13:15 -06:00
kvm KVM: arm64: vgic: Consolidate userspace access for base address setting 2022-07-17 11:55:33 +01:00
linux ITER_PIPE: cache the type of last buffer 2022-08-08 22:37:18 -04:00
math-emu
media SPDX changes for 6.0-rc1 2022-08-04 12:12:54 -07:00
memory
misc
net Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
pcmcia
ras
rdma RDMA: Fix comment typo 2022-07-22 12:07:16 -03:00
scsi SCSI misc on 20220804 2022-08-04 19:47:37 -07:00
soc Char / Misc driver changes for 6.0-rc1 2022-08-04 11:05:48 -07:00
sound ASoC: Remove unused hw_write_t type 2022-06-24 16:21:41 +01:00
target scsi: target: Add callout to configure UNMAP settings 2022-07-07 16:53:52 -04:00
trace SCSI misc on 20220804 2022-08-04 19:47:37 -07:00
uapi for-5.20/block-2022-08-04 2022-08-04 20:00:14 -07:00
ufs scsi: ufs: ufshcd: Constify pointed data 2022-06-27 22:26:45 -04:00
vdso
video video: of_display_timing.h: include errno.h 2022-07-06 17:16:20 +02:00
xen xen: don't require virtio with grants for non-PV guests 2022-08-01 07:43:03 +02:00