diff options
author | Toomas Soome <tsoome@me.com> | 2017-03-15 15:24:03 +0200 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2017-04-27 01:01:12 +0000 |
commit | 3dab25019f363b9dfef49cb3eeb29b0b2023b85b (patch) | |
tree | 9b2b5628b2b771cbbbc4fd285dac111760eecb94 /usr/src | |
parent | 9c0752ac0dc05794d2f8a8b4521d55e2b3f63247 (diff) | |
download | illumos-joyent-3dab25019f363b9dfef49cb3eeb29b0b2023b85b.tar.gz |
8010 loader: want mechanism to avoid RA with bcache
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/boot/Makefile.version | 2 | ||||
-rw-r--r-- | usr/src/boot/lib/libstand/stand.h | 3 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/common/bcache.c | 12 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/common/disk.c | 7 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/common/md.c | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/efi/libefi/efipart.c | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/i386/libi386/bioscd.c | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/i386/libi386/biosdisk.c | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/uboot/lib/disk.c | 1 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/usb/storage/umass_loader.c | 1 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c | 1 |
11 files changed, 26 insertions, 9 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index 2fb500a314..c8dbaf6b00 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -33,4 +33,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)-2017.4.22.2 +BOOT_VERSION = $(LOADER_VERSION)-2017.4.23.1 diff --git a/usr/src/boot/lib/libstand/stand.h b/usr/src/boot/lib/libstand/stand.h index 7653242656..cd10db19c4 100644 --- a/usr/src/boot/lib/libstand/stand.h +++ b/usr/src/boot/lib/libstand/stand.h @@ -195,6 +195,9 @@ extern struct open_file files[]; #define F_NODEV 0x0008 /* network open - no device */ #define F_GZIP 0x0010 /* file is compressed by gzip */ #define F_BZIP 0x0020 /* file is compressed by bzip */ +#define F_MASK 0xFFFF +/* Mode modifier for strategy() */ +#define F_NORA (0x01 << 16) /* Disable Read-Ahead */ #define isascii(c) (((c) & ~0x7F) == 0) diff --git a/usr/src/boot/sys/boot/common/bcache.c b/usr/src/boot/sys/boot/common/bcache.c index 87cda7a92f..dcbf6cbc88 100644 --- a/usr/src/boot/sys/boot/common/bcache.c +++ b/usr/src/boot/sys/boot/common/bcache.c @@ -293,7 +293,11 @@ read_strategy(void *devdata, int rw, daddr_t blk, size_t size, * Our choice of 16 read ahead blocks will always fit inside the bcache. */ - ra = bc->bcache_nblks - BHASH(bc, p_blk + p_size); + if ((rw & F_NORA) == F_NORA) + ra = 0; + else + ra = bc->bcache_nblks - BHASH(bc, p_blk + p_size); + if (ra != 0 && ra != bc->bcache_nblks) { /* do we have RA space? */ ra = MIN(bc->ra, ra - 1); ra = rounddown(ra, 16); /* multiple of 16 blocks */ @@ -314,6 +318,7 @@ read_strategy(void *devdata, int rw, daddr_t blk, size_t size, * in either case we should return the data in bcache and only * return error if there is no data. */ + rw &= F_MASK; result = dd->dv_strategy(dd->dv_devdata, rw, p_blk, p_size * bcache_blksize, p_buf, &r_size); @@ -379,10 +384,11 @@ bcache_strategy(void *devdata, int rw, daddr_t blk, size_t size, ((size * 2 / bcache_blksize) > bcache_nblks)) { DEBUG("bypass %zu from %qu", size / bcache_blksize, blk); bcache_bypasses++; + rw &= F_MASK; return (dd->dv_strategy(dd->dv_devdata, rw, blk, size, buf, rsize)); } - switch (rw) { + switch (rw & F_MASK) { case F_READ: nblk = size / bcache_blksize; if (size != 0 && nblk == 0) @@ -421,7 +427,7 @@ bcache_strategy(void *devdata, int rw, daddr_t blk, size_t size, return (ret); case F_WRITE: - return write_strategy(devdata, rw, blk, size, buf, rsize); + return write_strategy(devdata, F_WRITE, blk, size, buf, rsize); } return -1; } diff --git a/usr/src/boot/sys/boot/common/disk.c b/usr/src/boot/sys/boot/common/disk.c index c70b6e16aa..ba727e2671 100644 --- a/usr/src/boot/sys/boot/common/disk.c +++ b/usr/src/boot/sys/boot/common/disk.c @@ -85,7 +85,12 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t offset) dev = (struct disk_devdesc *)d; od = (struct open_disk *)dev->d_opendata; - return (dev->d_dev->dv_strategy(dev, F_READ, offset, + + /* + * As the GPT backup partition is located at the end of the disk, + * to avoid reading past disk end, flag bcache not to use RA. + */ + return (dev->d_dev->dv_strategy(dev, F_READ | F_NORA , offset, blocks * od->sectorsize, (char *)buf, NULL)); } diff --git a/usr/src/boot/sys/boot/common/md.c b/usr/src/boot/sys/boot/common/md.c index c9bc52b1d2..175833d748 100644 --- a/usr/src/boot/sys/boot/common/md.c +++ b/usr/src/boot/sys/boot/common/md.c @@ -106,7 +106,7 @@ md_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf, if (rsize != 0) *rsize = size; - switch (rw) { + switch (rw & F_MASK) { case F_READ: bcopy(md_image.start + ofs, buf, size); return (0); diff --git a/usr/src/boot/sys/boot/efi/libefi/efipart.c b/usr/src/boot/sys/boot/efi/libefi/efipart.c index e4f3e1151b..fb65fe82cc 100644 --- a/usr/src/boot/sys/boot/efi/libefi/efipart.c +++ b/usr/src/boot/sys/boot/efi/libefi/efipart.c @@ -288,7 +288,7 @@ efipart_readwrite(EFI_BLOCK_IO *blkio, int rw, daddr_t blk, daddr_t nblks, if ((blk + nblks - 1) > blkio->Media->LastBlock) return (EIO); - switch (rw) { + switch (rw & F_MASK) { case F_READ: status = blkio->ReadBlocks(blkio, blkio->Media->MediaId, blk, nblks * blkio->Media->BlockSize, buf); diff --git a/usr/src/boot/sys/boot/i386/libi386/bioscd.c b/usr/src/boot/sys/boot/i386/libi386/bioscd.c index a0101a1b68..ac76c08c69 100644 --- a/usr/src/boot/sys/boot/i386/libi386/bioscd.c +++ b/usr/src/boot/sys/boot/i386/libi386/bioscd.c @@ -268,7 +268,7 @@ bc_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size, return (EINVAL); #endif - if (rw != F_READ) + if ((rw & F_MASK) != F_READ) return(EROFS); dev = (struct i386_devdesc *)devdata; unit = dev->d_unit; diff --git a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c index 10efb5e422..c30008a734 100644 --- a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c +++ b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c @@ -508,7 +508,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size, DEBUG("short read %d", blks); } - switch(rw){ + switch (rw & F_MASK) { case F_READ: DEBUG("read %d from %lld to %p", blks, dblk, buf); diff --git a/usr/src/boot/sys/boot/uboot/lib/disk.c b/usr/src/boot/sys/boot/uboot/lib/disk.c index 10b049049c..26ae50e220 100644 --- a/usr/src/boot/sys/boot/uboot/lib/disk.c +++ b/usr/src/boot/sys/boot/uboot/lib/disk.c @@ -150,6 +150,7 @@ stor_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf, daddr_t bcount; int err; + rw &= F_MASK; if (rw != F_READ) { stor_printf("write attempt, operation not supported!\n"); return (EROFS); diff --git a/usr/src/boot/sys/boot/usb/storage/umass_loader.c b/usr/src/boot/sys/boot/usb/storage/umass_loader.c index a4183424ba..963e00b61b 100644 --- a/usr/src/boot/sys/boot/usb/storage/umass_loader.c +++ b/usr/src/boot/sys/boot/usb/storage/umass_loader.c @@ -92,6 +92,7 @@ umass_disk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, if (rsizep != NULL) *rsizep = 0; + flag &= F_MASK; if (flag == F_WRITE) { if (usb_msc_write_10(umass_uaa.device, 0, dblk, size >> 9, buf) != 0) return (EINVAL); diff --git a/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c b/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c index 74a80885ae..16bbc1b14c 100644 --- a/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c +++ b/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c @@ -178,6 +178,7 @@ userdisk_strategy(void *devdata, int rw, daddr_t dblk, size_t size, size_t resid; int rc; + rw &= F_MASK; if (rw == F_WRITE) return (EROFS); if (rw != F_READ) |