Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c =================================================================== --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -4140,7 +4140,7 @@ (void) arc_flush_state(arc_mfu_ghost, guid, ARC_BUFC_METADATA, retry); } -void +uint64_t arc_shrink(int64_t to_free) { if (arc_c > arc_c_min) { @@ -4167,8 +4167,9 @@ if (arc_size > arc_c) { DTRACE_PROBE2(arc__shrink_adjust, uint64_t, arc_size, uint64_t, arc_c); - (void) arc_adjust(); + return (arc_adjust()); } + return (0); } static long needfree = 0; @@ -4485,7 +4486,14 @@ #ifdef _KERNEL to_free = MAX(to_free, ptob(needfree)); #endif - arc_shrink(to_free); + evicted = arc_shrink(to_free); + if (needfree) { + /* + * Decrement needfree to ensure that we + * won't free more memory than necessary. + */ + needfree -= MIN(needfree, btoc(evicted)); + } } } else if (free_memory < arc_c >> arc_no_grow_shift) { arc_no_grow = B_TRUE;