summaryrefslogtreecommitdiff
path: root/usr/src/cmd/format
diff options
context:
space:
mode:
authoryl194034 <none@none>2008-05-08 23:19:58 -0700
committeryl194034 <none@none>2008-05-08 23:19:58 -0700
commitaf007057247046b266b7b580708a7c33f76a97e4 (patch)
tree26310c00c5b022dae59c4a112e62670e21b44900 /usr/src/cmd/format
parent5d2c258bdb0523a7ae5ee344ea50c0122737bcb1 (diff)
downloadillumos-joyent-af007057247046b266b7b580708a7c33f76a97e4.tar.gz
PSARC 2006/373 Dynamic Lun Expansion
6241086 Format should allow label adjustment when disk/lun size changes 6430818 Solaris needs mechanism of dynamically increasing lun size
Diffstat (limited to 'usr/src/cmd/format')
-rw-r--r--usr/src/cmd/format/init_menus.c15
-rw-r--r--usr/src/cmd/format/label.c3
-rw-r--r--usr/src/cmd/format/main.c60
-rw-r--r--usr/src/cmd/format/menu.c19
-rw-r--r--usr/src/cmd/format/menu.h8
-rw-r--r--usr/src/cmd/format/menu_partition.c34
-rw-r--r--usr/src/cmd/format/menu_partition.h8
7 files changed, 102 insertions, 45 deletions
diff --git a/usr/src/cmd/format/init_menus.c b/usr/src/cmd/format/init_menus.c
index 9545627dbc..0831e19205 100644
--- a/usr/src/cmd/format/init_menus.c
+++ b/usr/src/cmd/format/init_menus.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,13 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1991-1996, 1999, 2001-2003 Sun Microsystems, Inc.
- * All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * Copyright 1991-1996, 1999, 2001-2002 Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -148,6 +141,8 @@ struct menu_item menu_partition[] = {
{ "9 - change `9' partition",
p_jpart, expert },
#endif
+ { "expand - expand label to use whole disk",
+ p_expand, disp_expand_efi },
{ "select - select a predefined table",
p_select, true },
{ "modify - modify a predefined partition table",
diff --git a/usr/src/cmd/format/label.c b/usr/src/cmd/format/label.c
index 023aa3870a..d4362250a2 100644
--- a/usr/src/cmd/format/label.c
+++ b/usr/src/cmd/format/label.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -642,6 +642,7 @@ vtoc64_to_label(struct efi_info *label, struct dk_gpt *vtoc)
lmap->efi_last_lba = vtoc->efi_last_lba;
lmap->efi_first_u_lba = vtoc->efi_first_u_lba;
lmap->efi_last_u_lba = vtoc->efi_last_u_lba;
+ lmap->efi_altern_lba = vtoc->efi_altern_lba;
lmap->efi_flags = vtoc->efi_flags;
(void) memcpy((uchar_t *)&lmap->efi_disk_uguid,
(uchar_t *)&vtoc->efi_disk_uguid, sizeof (struct uuid));
diff --git a/usr/src/cmd/format/main.c b/usr/src/cmd/format/main.c
index 01180cd12a..a1a5b28297 100644
--- a/usr/src/cmd/format/main.c
+++ b/usr/src/cmd/format/main.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -104,7 +104,7 @@ main(int argc, char *argv[])
if (option_f) {
if (freopen(option_f, "r", stdin) == NULL) {
err_print("Unable to open command file '%s'.\n",
- option_f);
+ option_f);
fullabort();
}
}
@@ -114,7 +114,7 @@ main(int argc, char *argv[])
if (option_l) {
if ((log_file = fopen(option_l, "w")) == NULL) {
err_print("Unable to open log file '%s'.\n",
- option_l);
+ option_l);
fullabort();
}
}
@@ -151,7 +151,7 @@ main(int argc, char *argv[])
act.sa_flags = SA_RESTART | SA_NODEFER;
if (sigaction(SIGINT, &act, (struct sigaction *)NULL) == -1) {
err_print("sigaction(SIGINT) failed - %s\n",
- strerror(errno));
+ strerror(errno));
fullabort();
}
@@ -160,7 +160,7 @@ main(int argc, char *argv[])
act.sa_flags = SA_RESTART | SA_NODEFER;
if (sigaction(SIGTSTP, &act, (struct sigaction *)NULL) == -1) {
err_print("sigaction(SIGTSTP) failed - %s\n",
- strerror(errno));
+ strerror(errno));
fullabort();
}
@@ -169,7 +169,7 @@ main(int argc, char *argv[])
act.sa_flags = SA_RESTART;
if (sigaction(SIGALRM, &act, (struct sigaction *)NULL) == -1) {
err_print("sigaction(SIGALRM) failed - %s\n",
- strerror(errno));
+ strerror(errno));
fullabort();
}
@@ -330,6 +330,8 @@ init_globals(disk)
struct disk_info *disk;
{
int status;
+ int found_mount;
+ int found_inuse;
#ifdef sparc
int i;
caddr_t bad_ptr = (caddr_t)&badmap;
@@ -540,20 +542,42 @@ Continue"))
* Check to see if there are any mounted file systems on the
* disk. If there are, print a warning.
*/
- if (checkmount((daddr_t)-1, (daddr_t)-1))
+ if ((found_mount = checkmount((daddr_t)-1, (daddr_t)-1)) != 0)
err_print("Warning: Current Disk has mounted partitions.\n");
/*
* If any part of this device is also part of an SVM, VxVM or
* Live Upgrade device, print a warning.
*/
- (void) checkdevinuse(cur_disk->disk_name, (diskaddr_t)-1,
+ found_inuse = checkdevinuse(cur_disk->disk_name, (diskaddr_t)-1,
(diskaddr_t)-1, 1, 0);
/*
* Get the Solaris Fdisk Partition information
*/
(void) copy_solaris_part(&cur_disk->fdisk_part);
+
+ if (!found_mount && !found_inuse &&
+ cur_disk->label_type == L_TYPE_EFI) {
+
+ /*
+ * If alter_lba is 1, we are using the backup label.
+ * Since we can locate the backup label by disk capacity,
+ * there must be no space expanded after backup label.
+ */
+ if ((cur_parts->etoc->efi_altern_lba != 1) &&
+ (cur_parts->etoc->efi_altern_lba <
+ cur_parts->etoc->efi_last_lba)) {
+
+ /*
+ * Lun expansion detected. Prompt user now and actually
+ * adjust the label in <partition> command.
+ */
+ fmt_print(
+"Note: capacity in disk label is smaller than the real disk capacity.\n\
+Select <partition> <expand> to adjust the label capacity. \n");
+ }
+ }
}
@@ -602,28 +626,28 @@ get_disk_characteristics()
cur_dtype->dtype_pcyl = get_pcyl(ncyl, cur_dtype->dtype_acyl);
cur_dtype->dtype_bpt = get_bpt(cur_dtype->dtype_nsect,
- &cur_dtype->dtype_options);
+ &cur_dtype->dtype_options);
cur_dtype->dtype_rpm = get_rpm();
cur_dtype->dtype_fmt_time =
- get_fmt_time(&cur_dtype->dtype_options);
+ get_fmt_time(&cur_dtype->dtype_options);
cur_dtype->dtype_cyl_skew =
- get_cyl_skew(&cur_dtype->dtype_options);
+ get_cyl_skew(&cur_dtype->dtype_options);
cur_dtype->dtype_trk_skew =
- get_trk_skew(&cur_dtype->dtype_options);
+ get_trk_skew(&cur_dtype->dtype_options);
cur_dtype->dtype_trks_zone =
- get_trks_zone(&cur_dtype->dtype_options);
+ get_trks_zone(&cur_dtype->dtype_options);
cur_dtype->dtype_atrks = get_atrks(&cur_dtype->dtype_options);
cur_dtype->dtype_asect = get_asect(&cur_dtype->dtype_options);
cur_dtype->dtype_cache = get_cache(&cur_dtype->dtype_options);
cur_dtype->dtype_threshold =
- get_threshold(&cur_dtype->dtype_options);
+ get_threshold(&cur_dtype->dtype_options);
cur_dtype->dtype_prefetch_min =
- get_min_prefetch(&cur_dtype->dtype_options);
+ get_min_prefetch(&cur_dtype->dtype_options);
cur_dtype->dtype_prefetch_max =
- get_max_prefetch(cur_dtype->dtype_prefetch_min,
- &cur_dtype->dtype_options);
+ get_max_prefetch(cur_dtype->dtype_prefetch_min,
+ &cur_dtype->dtype_options);
cur_dtype->dtype_phead =
- get_phead(nhead, &cur_dtype->dtype_options);
+ get_phead(nhead, &cur_dtype->dtype_options);
cur_dtype->dtype_psect = get_psect(&cur_dtype->dtype_options);
cur_dtype->dtype_bps = get_bps();
#ifdef sparc
diff --git a/usr/src/cmd/format/menu.c b/usr/src/cmd/format/menu.c
index d19dff20ef..ea2cb1d248 100644
--- a/usr/src/cmd/format/menu.c
+++ b/usr/src/cmd/format/menu.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1991-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -304,6 +303,18 @@ disp_expert_change_expert_efi()
}
int
+disp_expand_efi()
+{
+ if ((cur_disk == NULL) && option_f)
+ return (0);
+ if (cur_disk->label_type != L_TYPE_EFI)
+ return (0);
+ if (cur_parts == NULL)
+ return (0);
+ return (1);
+}
+
+int
disp_all_change_expert_efi()
{
if ((cur_disk == NULL) && option_f)
diff --git a/usr/src/cmd/format/menu.h b/usr/src/cmd/format/menu.h
index 2c3b55720c..facc950678 100644
--- a/usr/src/cmd/format/menu.h
+++ b/usr/src/cmd/format/menu.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1991-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -66,6 +65,7 @@ int not_embedded_scsi(void);
int not_scsi(void);
int not_efi(void);
int disp_expert_change_expert_efi(void);
+int disp_expand_efi(void);
int disp_all_change_expert_efi(void);
int scsi(void);
int scsi_expert(void);
diff --git a/usr/src/cmd/format/menu_partition.c b/usr/src/cmd/format/menu_partition.c
index 3223dd5bc9..9b5b5b6749 100644
--- a/usr/src/cmd/format/menu_partition.c
+++ b/usr/src/cmd/format/menu_partition.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -165,6 +164,33 @@ p_jpart()
}
#endif /* defined(i386) */
+int
+p_expand()
+{
+ uint64_t delta;
+ uint_t nparts;
+ struct dk_gpt *efi_label = cur_parts->etoc;
+
+ if (cur_parts->etoc->efi_altern_lba == 1 ||
+ (cur_parts->etoc->efi_altern_lba >=
+ cur_parts->etoc->efi_last_lba)) {
+ err_print("Warning: No expanded capacity is found.\n");
+ return (0);
+ }
+
+ delta = efi_label->efi_last_lba - efi_label->efi_altern_lba;
+ nparts = efi_label->efi_nparts;
+
+ enter_critical();
+ efi_label->efi_parts[nparts - 1].p_start += delta;
+ efi_label->efi_last_u_lba += delta;
+ efi_label->efi_altern_lba = cur_parts->etoc->efi_last_lba;
+ exit_critical();
+
+ fmt_print("The expanded capacity is added to the unallocated space.\n");
+ return (0);
+}
+
/*
* This routine implements the 'select' command. It allows the user
* to make a pre-defined partition map the current map.
diff --git a/usr/src/cmd/format/menu_partition.h b/usr/src/cmd/format/menu_partition.h
index 836a203c9d..481309903a 100644
--- a/usr/src/cmd/format/menu_partition.h
+++ b/usr/src/cmd/format/menu_partition.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1991-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -52,6 +51,7 @@ int p_jpart(void);
#endif /* defined(i386) */
int p_select(void);
+int p_expand(void);
int p_modify(void);
int p_name(void);
int p_print(void);