Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion module/os/freebsd/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -4225,8 +4225,20 @@ zfs_getpages(struct vnode *vp, vm_page_t *ma, int count, int *rbehind,

zfs_vmobject_wlock(object);
(void) vm_page_grab_pages(object, OFF_TO_IDX(start),
VM_ALLOC_NORMAL | VM_ALLOC_WAITOK | VM_ALLOC_ZERO,
VM_ALLOC_NORMAL | VM_ALLOC_WAITOK,
ma, count);
if (!vm_page_all_valid(ma[count - 1])) {
/*
* Later in this function, we copy DMU data to
* invalid pages only. The last page may not be
* entirely filled though, if the file does not
* end on a page boundary. Therefore, we zero
* that last page here to make sure it does not
* contain garbage after the end of file.
*/
vm_page_invalid(ma[count - 1]);
vm_page_zero_invalid(ma[count - 1], FALSE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below we assert that if vm_page_any_valid(m) then vm_page_all_valid(m) must be true. It follows that if !vm_page_all_valid(m) then vm_page_none_valid(m) must be true, so the vm_page_invalid() call here is redundant. Am I missing something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this call because I was wondering if the allocated page could be partially invalid. To be sure the entire page is zero'd, I preferred to call vm_page_invalid() before calling vm_page_zero_invalid().

Perhaps it is unnecessary and I can remove this vm_page_invalid() call.

}
zfs_vmobject_wunlock(object);
}
if (blksz == zp->z_blksz)
Expand Down
Loading