The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=197a4f29f39e6ae6215a6dbd28ef449d305e6d49

commit 197a4f29f39e6ae6215a6dbd28ef449d305e6d49
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2021-09-16 23:53:58 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2021-09-17 17:29:55 +0000

    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
---
 sys/fs/cd9660/cd9660_vnops.c   |  5 +++--
 sys/fs/fuse/fuse_vnops.c       |  5 +++--
 sys/fs/msdosfs/msdosfs_vnops.c |  5 +++--
 sys/fs/nfsclient/nfs_clbio.c   |  5 +++--
 sys/kern/vfs_bio.c             | 16 ++++++++++------
 sys/sys/buf.h                  |  2 +-
 sys/ufs/ffs/ffs_vnops.c        |  5 +++--
 7 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c
index 500ff79716be..0ddf73548e3f 100644
--- a/sys/fs/cd9660/cd9660_vnops.c
+++ b/sys/fs/cd9660/cd9660_vnops.c
@@ -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
diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
index adb297b6aacb..1216c1252f2b 100644
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -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);
 }
 
 /*
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index 6197340e8943..5f778724786d 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -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
diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index ff9f446ff1ef..10a76f0a4b83 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -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
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 174892b374d1..e234bf2d6563 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -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 @@ again:
                                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) {
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index d6c4c7f44795..b831003cf63d 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -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);
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index a10afd86f8e6..a1657db9ece2 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -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
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to