Skip to content

Commit

Permalink
Base dbuf cache size limit on arc_c_max
Browse files Browse the repository at this point in the history
Fixes openzfs#10563

Signed-off-by: Ryan Moeller <[email protected]>
  • Loading branch information
Ryan Moeller authored and Ryan Moeller committed Jul 22, 2020
1 parent 317dbea commit 2b7f125
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions include/sys/arc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <sys/zio_crypt.h>
#include <sys/zthr.h>
#include <sys/aggsum.h>
#include <sys/multilist.h>

#ifdef __cplusplus
extern "C" {
Expand Down
23 changes: 9 additions & 14 deletions module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <sys/zfs_context.h>
#include <sys/arc.h>
#include <sys/arc_impl.h>
#include <sys/dmu.h>
#include <sys/dmu_send.h>
#include <sys/dmu_impl.h>
Expand Down Expand Up @@ -207,7 +208,7 @@ typedef struct dbuf_cache {
dbuf_cache_t dbuf_caches[DB_CACHE_MAX];

/* Size limits for the caches */
unsigned long dbuf_cache_max_bytes = 0;
unsigned long dbuf_cache_max_bytes = ULONG_MAX;
unsigned long dbuf_metadata_cache_max_bytes = 0;
/* Set the default sizes of the caches to log2 fraction of arc size */
int dbuf_cache_shift = 5;
Expand Down Expand Up @@ -613,8 +614,8 @@ dbuf_cache_multilist_index_func(multilist_t *ml, void *obj)
static inline unsigned long
dbuf_cache_target_bytes(void)
{
return MIN(dbuf_cache_max_bytes,
arc_target_bytes() >> dbuf_cache_shift);
return (MIN(dbuf_cache_max_bytes,
arc_target_bytes() >> dbuf_cache_shift));
}

static inline uint64_t
Expand Down Expand Up @@ -807,20 +808,14 @@ dbuf_init(void)

/*
* Setup the parameters for the dbuf caches. We set the sizes of the
* dbuf cache and the metadata cache to 1/32nd and 1/16th (default)
* of the target size of the ARC. If the values has been specified as
* a module option and they're not greater than the target size of the
* ARC, then we honor that value.
* dbuf metadata cache to 1/16th (default) of the max size of the ARC.
* If the value has been specified as a module option and it's not
* greater than the max size of the ARC, then we honor that value.
*/
if (dbuf_cache_max_bytes == 0 ||
dbuf_cache_max_bytes >= arc_target_bytes()) {
dbuf_cache_max_bytes = arc_target_bytes() >> dbuf_cache_shift;
}
if (dbuf_metadata_cache_max_bytes == 0 ||
dbuf_metadata_cache_max_bytes >= arc_target_bytes()) {
dbuf_metadata_cache_max_bytes >= arc_c_max)
dbuf_metadata_cache_max_bytes =
arc_target_bytes() >> dbuf_metadata_cache_shift;
}
arc_c_max >> dbuf_metadata_cache_shift;

/*
* All entries are queued via taskq_dispatch_ent(), so min/maxalloc
Expand Down

0 comments on commit 2b7f125

Please sign in to comment.