diff --git a/module/zcommon/zfs_uio.c b/module/zcommon/zfs_uio.c index f78db68e4ea6..9ec3002a29e4 100644 --- a/module/zcommon/zfs_uio.c +++ b/module/zcommon/zfs_uio.c @@ -164,7 +164,7 @@ uio_prefaultpages(ssize_t n, struct uio *uio) caddr_t p; uint8_t tmp; int iovcnt; - size_t skip = uio->uio_skip; + size_t skip; /* no need to fault in kernel pages */ switch (uio->uio_segflg) { @@ -180,9 +180,13 @@ uio_prefaultpages(ssize_t n, struct uio *uio) iov = uio->uio_iov; iovcnt = uio->uio_iovcnt; + skip = uio->uio_skip; - while ((n > 0) && (iovcnt > 0)) { + for (; n > 0 && iovcnt > 0; iov++, iovcnt--, skip = 0) { cnt = MIN(iov->iov_len - skip, n); + /* empty iov */ + if (cnt == 0) + continue; n -= cnt; /* * touch each page in this segment. @@ -201,9 +205,6 @@ uio_prefaultpages(ssize_t n, struct uio *uio) p--; if (fuword8((uint8_t *) p, &tmp)) return; - iov++; - iovcnt--; - skip = 0; } } EXPORT_SYMBOL(uio_prefaultpages);