mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
config: remove HAVE_SPLIT_SHRINKER_CALLBACK and HAVE_SINGLE_SHRINKER_CALLBACK
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #16479
This commit is contained in:
committed by
Brian Behlendorf
parent
d60d4ad809
commit
b545b07b2f
@@ -1178,64 +1178,6 @@ zfs_root(zfsvfs_t *zfsvfs, struct inode **ipp)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Linux kernels older than 3.1 do not support a per-filesystem shrinker.
|
||||
* To accommodate this we must improvise and manually walk the list of znodes
|
||||
* attempting to prune dentries in order to be able to drop the inodes.
|
||||
*
|
||||
* To avoid scanning the same znodes multiple times they are always rotated
|
||||
* to the end of the z_all_znodes list. New znodes are inserted at the
|
||||
* end of the list so we're always scanning the oldest znodes first.
|
||||
*/
|
||||
static int
|
||||
zfs_prune_aliases(zfsvfs_t *zfsvfs, unsigned long nr_to_scan)
|
||||
{
|
||||
znode_t **zp_array, *zp;
|
||||
int max_array = MIN(nr_to_scan, PAGE_SIZE * 8 / sizeof (znode_t *));
|
||||
int objects = 0;
|
||||
int i = 0, j = 0;
|
||||
|
||||
zp_array = vmem_zalloc(max_array * sizeof (znode_t *), KM_SLEEP);
|
||||
|
||||
mutex_enter(&zfsvfs->z_znodes_lock);
|
||||
while ((zp = list_head(&zfsvfs->z_all_znodes)) != NULL) {
|
||||
|
||||
if ((i++ > nr_to_scan) || (j >= max_array))
|
||||
break;
|
||||
|
||||
ASSERT(list_link_active(&zp->z_link_node));
|
||||
list_remove(&zfsvfs->z_all_znodes, zp);
|
||||
list_insert_tail(&zfsvfs->z_all_znodes, zp);
|
||||
|
||||
/* Skip active znodes and .zfs entries */
|
||||
if (MUTEX_HELD(&zp->z_lock) || zp->z_is_ctldir)
|
||||
continue;
|
||||
|
||||
if (igrab(ZTOI(zp)) == NULL)
|
||||
continue;
|
||||
|
||||
zp_array[j] = zp;
|
||||
j++;
|
||||
}
|
||||
mutex_exit(&zfsvfs->z_znodes_lock);
|
||||
|
||||
for (i = 0; i < j; i++) {
|
||||
zp = zp_array[i];
|
||||
|
||||
ASSERT3P(zp, !=, NULL);
|
||||
d_prune_aliases(ZTOI(zp));
|
||||
|
||||
if (atomic_read(&ZTOI(zp)->i_count) == 1)
|
||||
objects++;
|
||||
|
||||
zrele(zp);
|
||||
}
|
||||
|
||||
vmem_free(zp_array, max_array * sizeof (znode_t *));
|
||||
|
||||
return (objects);
|
||||
}
|
||||
|
||||
/*
|
||||
* The ARC has requested that the filesystem drop entries from the dentry
|
||||
* and inode caches. This can occur when the ARC needs to free meta data
|
||||
@@ -1261,8 +1203,7 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects)
|
||||
if ((error = zfs_enter(zfsvfs, FTAG)) != 0)
|
||||
return (error);
|
||||
|
||||
#if defined(HAVE_SPLIT_SHRINKER_CALLBACK) && \
|
||||
defined(SHRINK_CONTROL_HAS_NID) && \
|
||||
#if defined(SHRINK_CONTROL_HAS_NID) && \
|
||||
defined(SHRINKER_NUMA_AWARE)
|
||||
if (shrinker->flags & SHRINKER_NUMA_AWARE) {
|
||||
long tc = 1;
|
||||
@@ -1285,24 +1226,8 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects)
|
||||
} else {
|
||||
*objects = (*shrinker->scan_objects)(shrinker, &sc);
|
||||
}
|
||||
|
||||
#elif defined(HAVE_SPLIT_SHRINKER_CALLBACK)
|
||||
#else
|
||||
*objects = (*shrinker->scan_objects)(shrinker, &sc);
|
||||
#elif defined(HAVE_SINGLE_SHRINKER_CALLBACK)
|
||||
*objects = (*shrinker->shrink)(shrinker, &sc);
|
||||
#define D_PRUNE_ALIASES_IS_DEFAULT
|
||||
*objects = zfs_prune_aliases(zfsvfs, nr_to_scan);
|
||||
#endif
|
||||
|
||||
#ifndef D_PRUNE_ALIASES_IS_DEFAULT
|
||||
#undef D_PRUNE_ALIASES_IS_DEFAULT
|
||||
/*
|
||||
* Fall back to zfs_prune_aliases if the kernel's per-superblock
|
||||
* shrinker couldn't free anything, possibly due to the inodes being
|
||||
* allocated in a different memcg.
|
||||
*/
|
||||
if (*objects == 0)
|
||||
*objects = zfs_prune_aliases(zfsvfs, nr_to_scan);
|
||||
#endif
|
||||
|
||||
zfs_exit(zfsvfs, FTAG);
|
||||
|
||||
Reference in New Issue
Block a user