Skip to content

Commit

Permalink
6950 ARC should cache compressed data
Browse files Browse the repository at this point in the history
Reviewed by: Prakash Surya <[email protected]>
Reviewed by: Dan Kimmel <[email protected]>
Reviewed by: Matt Ahrens <[email protected]>
Reviewed by: Paul Dagnelie <[email protected]>
Reviewed by: Don Brady <[email protected]>
Reviewed by: Richard Elling <[email protected]>

This change  covers the reading and writing of compressed arc headers,
sharing data between the arc_hdr_t and the arc_buf_t, and the
implementation of a new dbuf cache to keep frequently access data
uncompressed.

I've added a new member to l1 arc hdr called b_pdata. The b_pdata always
hangs off the arc_buf_hdr_t (if an L1 hdr is in use) and points to the
physical block for that DVA. The physical block may or may not be
compressed. If compressed arc is enabled and the block on-disk is
compressed, then the b_pdata will match the block on-disk and remain
compressed in memory. If the block on disk is not compressed, then
neither will the b_pdata. Lastly, if compressed arc is disabled, then
b_pdata will always be an uncompressed version of the on-disk block.

Typically the arc will cache only the arc_buf_hdr_t and will
aggressively evict any arc_buf_t's that are no longer referenced. This
means that the arc will primarily have compressed blocks as the
arc_buf_t's are considered overhead and are always uncompressed. When a
consumer reads a block we first look to see if the arc_buf_hdr_t is
cached. If the hdr is cached then we allocate a new arc_buf_t and
decompress the b_pdata contents into the arc_buf_t's b_data. If the hdr
already has a arc_buf_t, then we will allocate an additional arc_buf_t
and bcopy the uncompressed contents from the first arc_buf_t to the new
one.

Writing to the compressed arc requires that we first discard the b_pdata
since the physical block is about to be rewritten. The new data contents
will be passed in via an arc_buf_t (uncompressed) and during the I/O
pipeline stages we will copy the physical block contents to a newly
allocated b_pdata.

When an l2arc is inuse it will also take advantage of the b_pdata. Now
the l2arc will always write the contents of b_pdata to the l2arc. This
means that when compressed arc is enabled that the l2arc blocks are
identical to those stored in the main data pool. This provides a
significant advantage since we can leverage the bp's checksum when
reading from the l2arc to determine if the contents are valid. If the
compressed arc is disabled, then we must first transform the read block
to look like the physical block in the main data pool before comparing
the checksum and determining it's valid.

Closes #103
  • Loading branch information
grwilson authored and ahrens committed Jul 14, 2016
1 parent 7e1ee2f commit 7fc10f0
Show file tree
Hide file tree
Showing 58 changed files with 4,422 additions and 1,990 deletions.
20 changes: 19 additions & 1 deletion usr/src/cmd/mdb/common/mdb/mdb_ctf.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2013, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/

Expand Down Expand Up @@ -910,6 +910,24 @@ mdb_ctf_offsetof_by_name(const char *type, const char *member)
return (off);
}

ssize_t
mdb_ctf_sizeof_by_name(const char *type)
{
mdb_ctf_id_t id;
ssize_t size;

if (mdb_ctf_lookup_by_name(type, &id) == -1) {
mdb_warn("couldn't find type %s", type);
return (-1);
}

if ((size = mdb_ctf_type_size(id)) == -1) {
mdb_warn("couldn't determine type size of %s", type);
return (-1);
}

return (size);
}

/*ARGSUSED*/
static int
Expand Down
3 changes: 2 additions & 1 deletion usr/src/cmd/mdb/common/mdb/mdb_ctf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2013, 2015 by Delphix. All rights reserved.
* Copyright (c) 2015, Joyent, Inc.
*/

Expand Down Expand Up @@ -136,6 +136,7 @@ extern int mdb_ctf_member_info(mdb_ctf_id_t, const char *,
extern int mdb_ctf_offsetof(mdb_ctf_id_t, const char *, ulong_t *);
extern int mdb_ctf_num_members(mdb_ctf_id_t);
extern int mdb_ctf_offsetof_by_name(const char *, const char *);
extern ssize_t mdb_ctf_sizeof_by_name(const char *);

extern ssize_t mdb_ctf_offset_to_name(mdb_ctf_id_t, ulong_t, char *, size_t,
int, mdb_ctf_id_t *, ulong_t *);
Expand Down
3 changes: 2 additions & 1 deletion usr/src/cmd/mdb/common/modules/conf/mapfile-extern
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#
# CDDL HEADER START
#
Expand Down Expand Up @@ -67,6 +67,7 @@ SYMBOL_SCOPE {
mdb_ctf_module_lookup { FLAGS = EXTERN };
mdb_ctf_offsetof { FLAGS = EXTERN };
mdb_ctf_offsetof_by_name { FLAGS = EXTERN };
mdb_ctf_sizeof_by_name { FLAGS = EXTERN };
mdb_ctf_readsym { FLAGS = EXTERN };
mdb_ctf_type_cmp { FLAGS = EXTERN };
mdb_ctf_type_invalidate { FLAGS = EXTERN };
Expand Down
Loading

0 comments on commit 7fc10f0

Please sign in to comment.