/*
- * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <vm/vm_map.h>
#include <vm/vm_kern.h>
#include <kern/zalloc.h>
-#include <kern/kalloc.h>
#include <libkern/libkern.h>
#include <vm/vnode_pager.h>
#include <vfs/vfs_disk_conditioner.h>
void
-vnode_pager_throttle()
+vnode_pager_throttle(void)
{
struct uthread *ut;
set_tier.extents = &extent;
set_tier.extentsCount = 1;
- set_tier.tier = priority;
+ set_tier.tier = (uint8_t)priority;
error = VNOP_IOCTL(devvp, DKIOCSETTIER, (caddr_t)&set_tier, 0, vfs_context_kernel());
return;
isize = (int)size;
+ /*
+ * This call is non-blocking and does not ever fail but it can
+ * only be made when there is other explicit synchronization
+ * with reclaiming of the vnode which, in this path, is provided
+ * by the paging in progress counter.
+ *
+ * In addition, this may also be entered via explicit ubc_msync
+ * calls or vm_swapfile_io where the existing iocount provides
+ * the necessary synchronization. Ideally we would not take an
+ * additional iocount here in the cases where an explcit iocount
+ * has already been taken but this call doesn't cause a deadlock
+ * as other forms of vnode_get* might if this thread has already
+ * taken an iocount.
+ */
+ error = vnode_getalways_from_pager(vp);
+ if (error != 0) {
+ /* This can't happen */
+ panic("vnode_getalways returned %d for vp %p", error, vp);
+ }
+
if (isize <= 0) {
result = PAGER_ERROR;
error_ret = EINVAL;
pg_index += num_of_pages;
}
out:
+ vnode_put_from_pager(vp);
+
if (errorp) {
*errorp = error_ret;
}
ignore_valid_page_check = 1;
}
+ /*
+ * This call is non-blocking and does not ever fail but it can
+ * only be made when there is other explicit synchronization
+ * with reclaiming of the vnode which, in this path, is provided
+ * by the paging in progress counter.
+ *
+ * In addition, this may also be entered via vm_swapfile_io
+ * where the existing iocount provides the necessary synchronization.
+ * Ideally we would not take an additional iocount here in the cases
+ * where an explcit iocount has already been taken but this call
+ * doesn't cause a deadlock as other forms of vnode_get* might if
+ * this thread has already taken an iocount.
+ */
+ error = vnode_getalways_from_pager(vp);
+ if (error != 0) {
+ /* This can't happen */
+ panic("vnode_getalways returned %d for vp %p", error, vp);
+ }
+
if (UBCINFOEXISTS(vp) == 0) {
result = PAGER_ERROR;
error = PAGER_ERROR;
}
}
out:
+ vnode_put_from_pager(vp);
+
if (errorp) {
*errorp = result;
}