Tweaks for the buffer pager.

Pass current thread credentials instead of NOCRED.
Only allow unmapped buffers for filesystem which proclaimed the support.

For all filesystems which currently use buffer pager (UFS, msdosfs and
cd9660), the changes are effectively nop.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
kib 2016-11-08 10:10:55 +00:00
parent bf9328d796
commit 3a3ee801ba

View File

@ -4686,13 +4686,15 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
vm_page_t m;
vm_object_t object;
struct buf *bp;
struct mount *mp;
daddr_t lbn, lbnp;
vm_ooffset_t la, lb, poff, poffe;
long bsize;
int bo_bs, error, i;
int bo_bs, br_flags, error, i;
bool redo, lpart;
object = vp->v_object;
mp = vp->v_mount;
la = IDX_TO_OFF(ma[count - 1]->pindex);
if (la >= object->un_pager.vnp.vnp_size)
return (VM_PAGER_BAD);
@ -4709,6 +4711,8 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
vnp.vnp_size, PAGE_SIZE) - la);
}
}
br_flags = (mp != NULL && (mp->mnt_kern_flag & MNTK_UNMAPPED_BUFS)
!= 0) ? GB_UNMAPPED : 0;
VM_OBJECT_WLOCK(object);
again:
for (i = 0; i < count; i++)
@ -4741,8 +4745,8 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
lbnp = lbn;
bsize = get_blksize(vp, lbn);
error = bread_gb(vp, lbn, bsize, NOCRED, GB_UNMAPPED,
&bp);
error = bread_gb(vp, lbn, bsize, curthread->td_ucred,
br_flags, &bp);
if (error != 0)
goto end_pages;
if (LIST_EMPTY(&bp->b_dep)) {