git: 7c667affb7b0 - main - CTL: Drop Format Device and Rigid Disk Geometry mode pages
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 27 Feb 2024 18:52:40 UTC
The branch main has been updated by mav:
URL: https://cgit.FreeBSD.org/src/commit/?id=7c667affb7b09fcdcb81f6f2635e9dfab7bc1fa8
commit 7c667affb7b09fcdcb81f6f2635e9dfab7bc1fa8
Author: Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2024-02-27 18:28:44 +0000
Commit: Alexander Motin <mav@FreeBSD.org>
CommitDate: 2024-02-27 18:28:44 +0000
CTL: Drop Format Device and Rigid Disk Geometry mode pages
Those mode pages are obsolete since SBC-2 specification almost 20
years ago. First I was trying to understand possible relations
between physical block and physical sector terms in different specs.
Then was thinking about possible relations to device CHS geometry
and compatibility issues. Finally I just decided that none of it
worth the efforts and should rest in piece.
PR: 276524
---
sys/cam/ctl/ctl.c | 194 ----------------------------------------------
sys/cam/ctl/ctl_private.h | 63 ---------------
2 files changed, 257 deletions(-)
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 3d6eb0382cc9..5230a2694544 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -124,72 +124,6 @@ const static struct scsi_da_rw_recovery_page rw_er_page_changeable = {
/*recovery_time_limit*/{0, 0},
};
-const static struct scsi_format_page format_page_default = {
- /*page_code*/SMS_FORMAT_DEVICE_PAGE,
- /*page_length*/sizeof(struct scsi_format_page) - 2,
- /*tracks_per_zone*/ {0, 0},
- /*alt_sectors_per_zone*/ {0, 0},
- /*alt_tracks_per_zone*/ {0, 0},
- /*alt_tracks_per_lun*/ {0, 0},
- /*sectors_per_track*/ {(CTL_DEFAULT_SECTORS_PER_TRACK >> 8) & 0xff,
- CTL_DEFAULT_SECTORS_PER_TRACK & 0xff},
- /*bytes_per_sector*/ {0, 0},
- /*interleave*/ {0, 0},
- /*track_skew*/ {0, 0},
- /*cylinder_skew*/ {0, 0},
- /*flags*/ SFP_HSEC,
- /*reserved*/ {0, 0, 0}
-};
-
-const static struct scsi_format_page format_page_changeable = {
- /*page_code*/SMS_FORMAT_DEVICE_PAGE,
- /*page_length*/sizeof(struct scsi_format_page) - 2,
- /*tracks_per_zone*/ {0, 0},
- /*alt_sectors_per_zone*/ {0, 0},
- /*alt_tracks_per_zone*/ {0, 0},
- /*alt_tracks_per_lun*/ {0, 0},
- /*sectors_per_track*/ {0, 0},
- /*bytes_per_sector*/ {0, 0},
- /*interleave*/ {0, 0},
- /*track_skew*/ {0, 0},
- /*cylinder_skew*/ {0, 0},
- /*flags*/ 0,
- /*reserved*/ {0, 0, 0}
-};
-
-const static struct scsi_rigid_disk_page rigid_disk_page_default = {
- /*page_code*/SMS_RIGID_DISK_PAGE,
- /*page_length*/sizeof(struct scsi_rigid_disk_page) - 2,
- /*cylinders*/ {0, 0, 0},
- /*heads*/ CTL_DEFAULT_HEADS,
- /*start_write_precomp*/ {0, 0, 0},
- /*start_reduced_current*/ {0, 0, 0},
- /*step_rate*/ {0, 0},
- /*landing_zone_cylinder*/ {0, 0, 0},
- /*rpl*/ SRDP_RPL_DISABLED,
- /*rotational_offset*/ 0,
- /*reserved1*/ 0,
- /*rotation_rate*/ {(CTL_DEFAULT_ROTATION_RATE >> 8) & 0xff,
- CTL_DEFAULT_ROTATION_RATE & 0xff},
- /*reserved2*/ {0, 0}
-};
-
-const static struct scsi_rigid_disk_page rigid_disk_page_changeable = {
- /*page_code*/SMS_RIGID_DISK_PAGE,
- /*page_length*/sizeof(struct scsi_rigid_disk_page) - 2,
- /*cylinders*/ {0, 0, 0},
- /*heads*/ 0,
- /*start_write_precomp*/ {0, 0, 0},
- /*start_reduced_current*/ {0, 0, 0},
- /*step_rate*/ {0, 0},
- /*landing_zone_cylinder*/ {0, 0, 0},
- /*rpl*/ 0,
- /*rotational_offset*/ 0,
- /*reserved1*/ 0,
- /*rotation_rate*/ {0, 0},
- /*reserved2*/ {0, 0}
-};
-
const static struct scsi_da_verify_recovery_page verify_er_page_default = {
/*page_code*/SMS_VERIFY_ERROR_RECOVERY_PAGE,
/*page_length*/sizeof(struct scsi_da_verify_recovery_page) - 2,
@@ -4124,134 +4058,6 @@ ctl_init_page_index(struct ctl_lun *lun)
(uint8_t *)lun->mode_pages.rw_er_page;
break;
}
- case SMS_FORMAT_DEVICE_PAGE: {
- struct scsi_format_page *format_page;
-
- KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0,
- ("subpage %#x for page %#x is incorrect!",
- page_index->subpage, page_code));
-
- /*
- * Sectors per track are set above. Bytes per
- * sector need to be set here on a per-LUN basis.
- */
- memcpy(&lun->mode_pages.format_page[CTL_PAGE_CURRENT],
- &format_page_default,
- sizeof(format_page_default));
- memcpy(&lun->mode_pages.format_page[
- CTL_PAGE_CHANGEABLE], &format_page_changeable,
- sizeof(format_page_changeable));
- memcpy(&lun->mode_pages.format_page[CTL_PAGE_DEFAULT],
- &format_page_default,
- sizeof(format_page_default));
- memcpy(&lun->mode_pages.format_page[CTL_PAGE_SAVED],
- &format_page_default,
- sizeof(format_page_default));
-
- format_page = &lun->mode_pages.format_page[
- CTL_PAGE_CURRENT];
- scsi_ulto2b(lun->be_lun->blocksize,
- format_page->bytes_per_sector);
-
- format_page = &lun->mode_pages.format_page[
- CTL_PAGE_DEFAULT];
- scsi_ulto2b(lun->be_lun->blocksize,
- format_page->bytes_per_sector);
-
- format_page = &lun->mode_pages.format_page[
- CTL_PAGE_SAVED];
- scsi_ulto2b(lun->be_lun->blocksize,
- format_page->bytes_per_sector);
-
- page_index->page_data =
- (uint8_t *)lun->mode_pages.format_page;
- break;
- }
- case SMS_RIGID_DISK_PAGE: {
- struct scsi_rigid_disk_page *rigid_disk_page;
- uint32_t sectors_per_cylinder;
- uint64_t cylinders;
-#ifndef __XSCALE__
- int shift;
-#endif /* !__XSCALE__ */
-
- KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0,
- ("subpage %#x for page %#x is incorrect!",
- page_index->subpage, page_code));
-
- /*
- * Rotation rate and sectors per track are set
- * above. We calculate the cylinders here based on
- * capacity. Due to the number of heads and
- * sectors per track we're using, smaller arrays
- * may turn out to have 0 cylinders. Linux and
- * FreeBSD don't pay attention to these mode pages
- * to figure out capacity, but Solaris does. It
- * seems to deal with 0 cylinders just fine, and
- * works out a fake geometry based on the capacity.
- */
- memcpy(&lun->mode_pages.rigid_disk_page[
- CTL_PAGE_DEFAULT], &rigid_disk_page_default,
- sizeof(rigid_disk_page_default));
- memcpy(&lun->mode_pages.rigid_disk_page[
- CTL_PAGE_CHANGEABLE],&rigid_disk_page_changeable,
- sizeof(rigid_disk_page_changeable));
-
- sectors_per_cylinder = CTL_DEFAULT_SECTORS_PER_TRACK *
- CTL_DEFAULT_HEADS;
-
- /*
- * The divide method here will be more accurate,
- * probably, but results in floating point being
- * used in the kernel on i386 (__udivdi3()). On the
- * XScale, though, __udivdi3() is implemented in
- * software.
- *
- * The shift method for cylinder calculation is
- * accurate if sectors_per_cylinder is a power of
- * 2. Otherwise it might be slightly off -- you
- * might have a bit of a truncation problem.
- */
-#ifdef __XSCALE__
- cylinders = (lun->be_lun->maxlba + 1) /
- sectors_per_cylinder;
-#else
- for (shift = 31; shift > 0; shift--) {
- if (sectors_per_cylinder & (1 << shift))
- break;
- }
- cylinders = (lun->be_lun->maxlba + 1) >> shift;
-#endif
-
- /*
- * We've basically got 3 bytes, or 24 bits for the
- * cylinder size in the mode page. If we're over,
- * just round down to 2^24.
- */
- if (cylinders > 0xffffff)
- cylinders = 0xffffff;
-
- rigid_disk_page = &lun->mode_pages.rigid_disk_page[
- CTL_PAGE_DEFAULT];
- scsi_ulto3b(cylinders, rigid_disk_page->cylinders);
-
- if ((value = dnvlist_get_string(lun->be_lun->options,
- "rpm", NULL)) != NULL) {
- scsi_ulto2b(strtol(value, NULL, 0),
- rigid_disk_page->rotation_rate);
- }
-
- memcpy(&lun->mode_pages.rigid_disk_page[CTL_PAGE_CURRENT],
- &lun->mode_pages.rigid_disk_page[CTL_PAGE_DEFAULT],
- sizeof(rigid_disk_page_default));
- memcpy(&lun->mode_pages.rigid_disk_page[CTL_PAGE_SAVED],
- &lun->mode_pages.rigid_disk_page[CTL_PAGE_DEFAULT],
- sizeof(rigid_disk_page_default));
-
- page_index->page_data =
- (uint8_t *)lun->mode_pages.rigid_disk_page;
- break;
- }
case SMS_VERIFY_ERROR_RECOVERY_PAGE: {
KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0,
("subpage %#x for page %#x is incorrect!",
diff --git a/sys/cam/ctl/ctl_private.h b/sys/cam/ctl/ctl_private.h
index 04846f80e913..9dfe979bcb7f 100644
--- a/sys/cam/ctl/ctl_private.h
+++ b/sys/cam/ctl/ctl_private.h
@@ -168,61 +168,6 @@ union ctl_softcs {
/*
* Mode page defaults.
*/
-#if 0
-/*
- * These values make Solaris trim off some of the capacity.
- */
-#define CTL_DEFAULT_SECTORS_PER_TRACK 63
-#define CTL_DEFAULT_HEADS 255
-/*
- * These values seem to work okay.
- */
-#define CTL_DEFAULT_SECTORS_PER_TRACK 63
-#define CTL_DEFAULT_HEADS 16
-/*
- * These values work reasonably well.
- */
-#define CTL_DEFAULT_SECTORS_PER_TRACK 512
-#define CTL_DEFAULT_HEADS 64
-#endif
-
-/*
- * Solaris is somewhat picky about how many heads and sectors per track you
- * have defined in mode pages 3 and 4. These values seem to cause Solaris
- * to get the capacity more or less right when you run the format tool.
- * They still have problems when dealing with devices larger than 1TB,
- * but there isn't anything we can do about that.
- *
- * For smaller LUN sizes, this ends up causing the number of cylinders to
- * work out to 0. Solaris actually recognizes that and comes up with its
- * own bogus geometry to fit the actual capacity of the drive. They really
- * should just give up on geometry and stick to the read capacity
- * information alone for modern disk drives.
- *
- * One thing worth mentioning about Solaris' mkfs command is that it
- * doesn't like sectors per track values larger than 256. 512 seems to
- * work okay for format, but causes problems when you try to make a
- * filesystem.
- *
- * Another caveat about these values: the product of these two values
- * really should be a power of 2. This is because of the simplistic
- * shift-based calculation that we have to use on the i386 platform to
- * calculate the number of cylinders here. (If you use a divide, you end
- * up calling __udivdi3(), which is a hardware FP call on the PC. On the
- * XScale, it is done in software, so you can do that from inside the
- * kernel.)
- *
- * So for the current values (256 S/T, 128 H), we get 32768, which works
- * very nicely for calculating cylinders.
- *
- * If you want to change these values so that their product is no longer a
- * power of 2, re-visit the calculation in ctl_init_page_index(). You may
- * need to make it a bit more complicated to get the number of cylinders
- * right.
- */
-#define CTL_DEFAULT_SECTORS_PER_TRACK 256
-#define CTL_DEFAULT_HEADS 128
-
#define CTL_DEFAULT_ROTATION_RATE SVPD_NON_ROTATING
struct ctl_page_index;
@@ -271,10 +216,6 @@ struct ctl_logical_block_provisioning_page {
static const struct ctl_page_index page_index_template[] = {
{SMS_RW_ERROR_RECOVERY_PAGE, 0, sizeof(struct scsi_da_rw_recovery_page), NULL,
CTL_PAGE_FLAG_DIRECT | CTL_PAGE_FLAG_CDROM, NULL, ctl_default_page_handler},
- {SMS_FORMAT_DEVICE_PAGE, 0, sizeof(struct scsi_format_page), NULL,
- CTL_PAGE_FLAG_DIRECT, NULL, NULL},
- {SMS_RIGID_DISK_PAGE, 0, sizeof(struct scsi_rigid_disk_page), NULL,
- CTL_PAGE_FLAG_DIRECT, NULL, NULL},
{SMS_VERIFY_ERROR_RECOVERY_PAGE, 0, sizeof(struct scsi_da_verify_recovery_page), NULL,
CTL_PAGE_FLAG_DIRECT | CTL_PAGE_FLAG_CDROM, NULL, ctl_default_page_handler},
{SMS_CACHING_PAGE, 0, sizeof(struct scsi_caching_page), NULL,
@@ -300,8 +241,6 @@ static const struct ctl_page_index page_index_template[] = {
struct ctl_mode_pages {
struct scsi_da_rw_recovery_page rw_er_page[4];
- struct scsi_format_page format_page[4];
- struct scsi_rigid_disk_page rigid_disk_page[4];
struct scsi_da_verify_recovery_page verify_er_page[4];
struct scsi_caching_page caching_page[4];
struct scsi_control_page control_page[4];
@@ -313,8 +252,6 @@ struct ctl_mode_pages {
};
#define MODE_RWER mode_pages.rw_er_page[CTL_PAGE_CURRENT]
-#define MODE_FMT mode_pages.format_page[CTL_PAGE_CURRENT]
-#define MODE_RDISK mode_pages.rigid_disk_page[CTL_PAGE_CURRENT]
#define MODE_VER mode_pages.verify_er_page[CTL_PAGE_CURRENT]
#define MODE_CACHING mode_pages.caching_page[CTL_PAGE_CURRENT]
#define MODE_CTRL mode_pages.control_page[CTL_PAGE_CURRENT]