buffer pager: allow get_blksize method to return error

(cherry picked from commit 197a4f29f3)
This commit is contained in:
Konstantin Belousov 2021-09-17 02:53:58 +03:00
parent ed03973908
commit fc58a6f8e6
7 changed files with 26 additions and 17 deletions

View File

@ -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

View File

@ -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);
}
/*

View File

@ -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

View File

@ -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

View File

@ -5177,8 +5177,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;
@ -5195,7 +5195,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.
@ -5251,9 +5254,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) {

View File

@ -595,7 +595,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);

View File

@ -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