buffer pager: allow get_blksize method to return error
Reported and reviewed by: asomers Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31998
This commit is contained in:
parent
c6efcb1281
commit
197a4f29f3
@ -858,12 +858,13 @@ cd9660_gbp_getblkno(struct vnode *vp, vm_ooffset_t off)
|
||||
}
|
||||
|
||||
static int
|
||||
cd9660_gbp_getblksz(struct vnode *vp, daddr_t lbn)
|
||||
cd9660_gbp_getblksz(struct vnode *vp, daddr_t lbn, long *sz)
|
||||
{
|
||||
struct iso_node *ip;
|
||||
|
||||
ip = VTOI(vp);
|
||||
return (blksize(ip->i_mnt, ip, lbn));
|
||||
*sz = blksize(ip->i_mnt, ip, lbn);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2199,7 +2199,7 @@ fuse_gbp_getblkno(struct vnode *vp, vm_ooffset_t off)
|
||||
}
|
||||
|
||||
static int
|
||||
fuse_gbp_getblksz(struct vnode *vp, daddr_t lbn)
|
||||
fuse_gbp_getblksz(struct vnode *vp, daddr_t lbn, long *sz)
|
||||
{
|
||||
off_t filesize;
|
||||
int blksz, err;
|
||||
@ -2217,7 +2217,8 @@ fuse_gbp_getblksz(struct vnode *vp, daddr_t lbn)
|
||||
} else {
|
||||
blksz = biosize;
|
||||
}
|
||||
return (blksz);
|
||||
*sz = blksz;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1861,10 +1861,11 @@ msdosfs_gbp_getblkno(struct vnode *vp, vm_ooffset_t off)
|
||||
}
|
||||
|
||||
static int
|
||||
msdosfs_gbp_getblksz(struct vnode *vp, daddr_t lbn)
|
||||
msdosfs_gbp_getblksz(struct vnode *vp, daddr_t lbn, long *sz)
|
||||
{
|
||||
|
||||
return (VTODE(vp)->de_pmp->pm_bpcluster);
|
||||
*sz = VTODE(vp)->de_pmp->pm_bpcluster;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -94,7 +94,7 @@ ncl_gbp_getblkno(struct vnode *vp, vm_ooffset_t off)
|
||||
}
|
||||
|
||||
static int
|
||||
ncl_gbp_getblksz(struct vnode *vp, daddr_t lbn)
|
||||
ncl_gbp_getblksz(struct vnode *vp, daddr_t lbn, long *sz)
|
||||
{
|
||||
struct nfsnode *np;
|
||||
u_quad_t nsize;
|
||||
@ -111,7 +111,8 @@ ncl_gbp_getblksz(struct vnode *vp, daddr_t lbn)
|
||||
bcount = 0;
|
||||
else if ((off_t)(lbn + 1) * biosize > nsize)
|
||||
bcount = nsize - (off_t)lbn * biosize;
|
||||
return (bcount);
|
||||
*sz = bcount;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -5203,8 +5203,8 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
|
||||
struct mount *mp;
|
||||
daddr_t lbn, lbnp;
|
||||
vm_ooffset_t la, lb, poff, poffe;
|
||||
long bsize;
|
||||
int bo_bs, br_flags, error, i, pgsin, pgsin_a, pgsin_b;
|
||||
long bo_bs, bsize;
|
||||
int br_flags, error, i, pgsin, pgsin_a, pgsin_b;
|
||||
bool redo, lpart;
|
||||
|
||||
object = vp->v_object;
|
||||
@ -5221,7 +5221,10 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
|
||||
*/
|
||||
la += PAGE_SIZE;
|
||||
lpart = la > object->un_pager.vnp.vnp_size;
|
||||
bo_bs = get_blksize(vp, get_lblkno(vp, IDX_TO_OFF(ma[0]->pindex)));
|
||||
error = get_blksize(vp, get_lblkno(vp, IDX_TO_OFF(ma[0]->pindex)),
|
||||
&bo_bs);
|
||||
if (error != 0)
|
||||
return (VM_PAGER_ERROR);
|
||||
|
||||
/*
|
||||
* Calculate read-ahead, behind and total pages.
|
||||
@ -5277,9 +5280,10 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
|
||||
goto next_page;
|
||||
lbnp = lbn;
|
||||
|
||||
bsize = get_blksize(vp, lbn);
|
||||
error = bread_gb(vp, lbn, bsize, curthread->td_ucred,
|
||||
br_flags, &bp);
|
||||
error = get_blksize(vp, lbn, &bsize);
|
||||
if (error == 0)
|
||||
error = bread_gb(vp, lbn, bsize,
|
||||
curthread->td_ucred, br_flags, &bp);
|
||||
if (error != 0)
|
||||
goto end_pages;
|
||||
if (bp->b_rcred == curthread->td_ucred) {
|
||||
|
@ -610,7 +610,7 @@ void bwait(struct buf *, u_char, const char *);
|
||||
void bdone(struct buf *);
|
||||
|
||||
typedef daddr_t (vbg_get_lblkno_t)(struct vnode *, vm_ooffset_t);
|
||||
typedef int (vbg_get_blksize_t)(struct vnode *, daddr_t);
|
||||
typedef int (vbg_get_blksize_t)(struct vnode *, daddr_t, long *);
|
||||
int vfs_bio_getpages(struct vnode *vp, struct vm_page **ma, int count,
|
||||
int *rbehind, int *rahead, vbg_get_lblkno_t get_lblkno,
|
||||
vbg_get_blksize_t get_blksize);
|
||||
|
@ -1935,10 +1935,11 @@ ffs_gbp_getblkno(struct vnode *vp, vm_ooffset_t off)
|
||||
}
|
||||
|
||||
static int
|
||||
ffs_gbp_getblksz(struct vnode *vp, daddr_t lbn)
|
||||
ffs_gbp_getblksz(struct vnode *vp, daddr_t lbn, long *sz)
|
||||
{
|
||||
|
||||
return (blksize(VFSTOUFS(vp->v_mount)->um_fs, VTOI(vp), lbn));
|
||||
*sz = blksize(VFSTOUFS(vp->v_mount)->um_fs, VTOI(vp), lbn);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user