freebsd-skq/sys
Andriy Gapon 082fcc9ed2 account for ashift when gathering buffers to be written to l2arc device
The change that introduced the L2ARC compression support also introduced
a bug where the on-disk size of the selected buffers could end up larger
than the target size if the ashift is greater than 9.  This was because
the buffer selection could did not take into account the fact that
on-disk size could be larger than the in-memory buffer size due to
the alignment requirements.

At the moment b_asize is a misnomer as it does not always represent the
allocated size: if a buffer is compressed, then the compressed size is
properly rounded (on FreeBSD), but if the compression fails or it is not
applied, then the original size is kept and it could be smaller than what
ashift requires.

For the same reasons arcstat_l2_asize and the reported used space
on the cache device could be smaller than the actual allocated size
if ashift > 9.  That problem is not fixed by this change.

This change only ensures that l2ad_hand is not advanced by more
than target_sz.  Otherwise we would overwrite active (unevicted)
L2ARC buffers.  That problem is manifested as growing l2_cksum_bad
and l2_io_error counters.

This change also changes 'p' prefix to 'a' prefix in a few places
where variables represent allocated rather than physical size.

The resolved problem could also result in the reported allocated size
being greater than the cache device's capacity, because of the
overwritten buffers (more than one buffer claiming the same disk
space).

This change is already in ZFS-on-Linux:
zfsonlinux/zfs@ef56b0780c

PR:		198242
PR:		195746 (possibly related)
Reviewed by:	mahrens (https://reviews.csiden.org/r/229/)
Tested by:	gkontos@aicom.gr (most recently)
MFC after:	15 days
X-MFC note:	patch does not apply as is at the moment
Relnotes:	yes
Sponsored by:	ClusterHQ
Differential Revision:	https://reviews.freebsd.org/D2764
Reviewed by:	noone (@FreeBSD.org)
2015-08-24 08:10:52 +00:00
..
amd64 preload_search_info: make sure mod is set 2015-08-21 15:57:57 +00:00
arm Enable KDTRACE_HOOKS by default on all armv6 kernels to get more testing. 2015-08-23 21:10:20 +00:00
arm64 Handle the breakpoint instruction in userland by sending a SIGTRAP signal. 2015-08-23 13:18:56 +00:00
boot The flags -mno-aes -mno-avx only exist for clang, not gcc, so 2015-08-20 18:31:05 +00:00
bsm
cam Remove some code duplication by using biofinish(). 2015-08-22 15:58:35 +00:00
cddl account for ashift when gathering buffers to be written to l2arc device 2015-08-24 08:10:52 +00:00
compat Don't forget to invoke pre_execve() and post_execve(). 2015-08-17 13:07:12 +00:00
conf Make the UMA harvesting go away completely if not wanted. Default to "not wanted". 2015-08-22 12:59:05 +00:00
contrib Add support for the arrays in nvlist library. 2015-08-15 06:34:49 +00:00
crypto const'ify an arg that we don't update... 2015-07-29 23:37:15 +00:00
ddb Make kstack_pages a tunable on arm, x86, and powepc. On i386, the 2015-08-10 17:18:21 +00:00
dev Make the UMA harvesting go away completely if not wanted. Default to "not wanted". 2015-08-22 12:59:05 +00:00
fs After r286237 it should be fine to call vgone(9) on a busy GEOM vnode; 2015-08-23 14:53:54 +00:00
gdb CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten 2015-05-22 17:05:21 +00:00
geom Create a RouterBoard platform and use it to create a flash map 2015-08-22 05:50:18 +00:00
gnu Using consistent coding style to deal with error inside the loop. 2015-08-18 13:16:23 +00:00
i386 preload_search_info: make sure mod is set 2015-08-21 15:57:57 +00:00
isa
kern After r286237 it should be fine to call vgone(9) on a busy GEOM vnode; 2015-08-23 14:53:54 +00:00
kgssapi
libkern Remove checks for __ARM_EABI__, we only build for EABI now. 2015-07-09 21:02:40 +00:00
mips preload_search_info: make sure mod is set 2015-08-21 15:57:57 +00:00
modules fix standalone build of zfs module 2015-08-21 08:06:18 +00:00
net Add ALTQ(9) support for the CoDel algorithm. 2015-08-21 22:02:22 +00:00
net80211 Reset the channel to the first available channel if the interface 2015-08-23 01:17:52 +00:00
netgraph * Address review (and add a bit myself). 2015-07-12 18:14:38 +00:00
netinet * Split allocation and table linking for lle's. 2015-08-20 12:05:17 +00:00
netinet6 Implement the IPv6 RSS software hash function. 2015-08-24 05:36:08 +00:00
netipsec Make IPsec work with AES-GCM and AES-ICM (aka CTR) in OCF... IPsec 2015-08-04 17:47:11 +00:00
netnatm
netpfil Add ALTQ(9) support for the CoDel algorithm. 2015-08-21 22:02:22 +00:00
netsmb
nfs
nfsclient Remove some oldnfs remnants. 2015-04-18 16:08:06 +00:00
nfsserver
nlm
ofed Reinstate unify_tcp_port_space and associated code that was lost during 2015-08-12 22:09:58 +00:00
opencrypto Make IPsec work with AES-GCM and AES-ICM (aka CTR) in OCF... IPsec 2015-08-04 17:47:11 +00:00
pc98 Remove unused i386 header privatespace.h. For the native kernel, its 2015-08-07 05:59:58 +00:00
powerpc Fix static fdt support. 2015-08-24 04:39:07 +00:00
rpc Set curvnet context inside the RPC code in more places. 2015-08-18 18:12:46 +00:00
security fd: make 'rights' a manadatory argument to fget* functions 2015-07-05 19:05:16 +00:00
sparc64 Rationalize BSD license on sys/*/include/in_cksum.h 2015-08-05 19:05:12 +00:00
sys After r286237 it should be fine to call vgone(9) on a busy GEOM vnode; 2015-08-23 14:53:54 +00:00
teken Sync HPA and VPA implementations with CUP. 2015-08-24 07:49:27 +00:00
tools
ufs - Make 'struct buf *buf' private to vfs_bio.c. Having a global variable 2015-07-29 02:26:57 +00:00
vm Make the UMA harvesting go away completely if not wanted. Default to "not wanted". 2015-08-22 12:59:05 +00:00
x86 preload_search_info: make sure mod is set 2015-08-21 15:57:57 +00:00
xdr
xen xen: allow disabling PV disks and nics 2015-08-21 15:53:08 +00:00
Makefile Kill EoL whitespace. 2015-05-29 14:03:07 +00:00