MCPcopy Create free account
hub / github.com/F-Stack/f-stack / l2arc_apply_transforms

Function l2arc_apply_transforms

freebsd/contrib/openzfs/module/zfs/arc.c:8911–9033  ·  view source on GitHub ↗

* Handle any abd transforms that might be required for writing to the L2ARC. * If successful, this function will always return an abd with the data * transformed as it is on disk in a new abd of asize bytes. */

Source from the content-addressed store, hash-verified

8909 * transformed as it is on disk in a new abd of asize bytes.
8910 */
8911static int
8912l2arc_apply_transforms(spa_t *spa, arc_buf_hdr_t *hdr, uint64_t asize,
8913 abd_t **abd_out)
8914{
8915 int ret;
8916 void *tmp = NULL;
8917 abd_t *cabd = NULL, *eabd = NULL, *to_write = hdr->b_l1hdr.b_pabd;
8918 enum zio_compress compress = HDR_GET_COMPRESS(hdr);
8919 uint64_t psize = HDR_GET_PSIZE(hdr);
8920 uint64_t size = arc_hdr_size(hdr);
8921 boolean_t ismd = HDR_ISTYPE_METADATA(hdr);
8922 boolean_t bswap = (hdr->b_l1hdr.b_byteswap != DMU_BSWAP_NUMFUNCS);
8923 dsl_crypto_key_t *dck = NULL;
8924 uint8_t mac[ZIO_DATA_MAC_LEN] = { 0 };
8925 boolean_t no_crypt = B_FALSE;
8926
8927 ASSERT((HDR_GET_COMPRESS(hdr) != ZIO_COMPRESS_OFF &&
8928 !HDR_COMPRESSION_ENABLED(hdr)) ||
8929 HDR_ENCRYPTED(hdr) || HDR_SHARED_DATA(hdr) || psize != asize);
8930 ASSERT3U(psize, <=, asize);
8931
8932 /*
8933 * If this data simply needs its own buffer, we simply allocate it
8934 * and copy the data. This may be done to eliminate a dependency on a
8935 * shared buffer or to reallocate the buffer to match asize.
8936 */
8937 if (HDR_HAS_RABD(hdr) && asize != psize) {
8938 ASSERT3U(asize, >=, psize);
8939 to_write = abd_alloc_for_io(asize, ismd);
8940 abd_copy(to_write, hdr->b_crypt_hdr.b_rabd, psize);
8941 if (psize != asize)
8942 abd_zero_off(to_write, psize, asize - psize);
8943 goto out;
8944 }
8945
8946 if ((compress == ZIO_COMPRESS_OFF || HDR_COMPRESSION_ENABLED(hdr)) &&
8947 !HDR_ENCRYPTED(hdr)) {
8948 ASSERT3U(size, ==, psize);
8949 to_write = abd_alloc_for_io(asize, ismd);
8950 abd_copy(to_write, hdr->b_l1hdr.b_pabd, size);
8951 if (size != asize)
8952 abd_zero_off(to_write, size, asize - size);
8953 goto out;
8954 }
8955
8956 if (compress != ZIO_COMPRESS_OFF && !HDR_COMPRESSION_ENABLED(hdr)) {
8957 cabd = abd_alloc_for_io(asize, ismd);
8958 tmp = abd_borrow_buf(cabd, asize);
8959
8960 psize = zio_compress_data(compress, to_write, tmp, size,
8961 hdr->b_complevel);
8962
8963 if (psize >= size) {
8964 abd_return_buf(cabd, tmp, asize);
8965 HDR_SET_COMPRESS(hdr, ZIO_COMPRESS_OFF);
8966 to_write = cabd;
8967 abd_copy(to_write, hdr->b_l1hdr.b_pabd, size);
8968 if (size != asize)

Callers 1

l2arc_write_buffersFunction · 0.85

Calls 13

arc_hdr_sizeFunction · 0.85
abd_copyFunction · 0.85
abd_zero_offFunction · 0.85
abd_borrow_bufFunction · 0.85
zio_compress_dataFunction · 0.85
abd_return_bufFunction · 0.85
bzeroFunction · 0.85
abd_return_buf_copyFunction · 0.85
spa_keystore_lookup_keyFunction · 0.85
abd_freeFunction · 0.85
abd_alloc_for_ioFunction · 0.50

Tested by

no test coverage detected