summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2022-04-21 14:57:24 -0500
committerToomas Soome <tsoome@me.com>2022-04-23 21:15:08 +0300
commit77570342d4bf7e1e439bf1b8008312de7f031a0a (patch)
tree401cb9f4843da937df07db96a0d76bdc53d760f7
parent1aa1f41fe10c6220a7fbef328fac1b72a8355a01 (diff)
downloadillumos-joyent-77570342d4bf7e1e439bf1b8008312de7f031a0a.tar.gz
14653 loader: zfs: handle holes at the tail end correctly
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Jason King <jason.brian.king+illumos@gmail.com> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/libsa/zfs/zfsimpl.c13
2 files changed, 14 insertions, 1 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index 6e0fa00d86..f0ea00a876 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -34,4 +34,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2022.01.25.1
+BOOT_VERSION = $(LOADER_VERSION)-2022.04.21.1
diff --git a/usr/src/boot/libsa/zfs/zfsimpl.c b/usr/src/boot/libsa/zfs/zfsimpl.c
index e83a8a3983..f2c5ca82d6 100644
--- a/usr/src/boot/libsa/zfs/zfsimpl.c
+++ b/usr/src/boot/libsa/zfs/zfsimpl.c
@@ -2348,6 +2348,19 @@ dnode_read(const spa_t *spa, const dnode_phys_t *dnode, off_t offset,
}
/*
+ * Handle odd block sizes, mirrors dmu_read_impl(). Data can't exist
+ * past the first block, so we'll clip the read to the portion of the
+ * buffer within bsize and zero out the remainder.
+ */
+ if (dnode->dn_maxblkid == 0) {
+ size_t newbuflen;
+
+ newbuflen = offset > bsize ? 0 : MIN(buflen, bsize - offset);
+ bzero((char *)buf + newbuflen, buflen - newbuflen);
+ buflen = newbuflen;
+ }
+
+ /*
* Note: bsize may not be a power of two here so we need to do an
* actual divide rather than a bitshift.
*/