Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Jun 2011 21:10:55 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r222873 - stable/7/usr.sbin/mfiutil
Message-ID:  <201106082110.p58LAtNn047428@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Jun  8 21:10:55 2011
New Revision: 222873
URL: http://svn.freebsd.org/changeset/base/222873

Log:
  MFC 221208:
  Add a 'show progress' command that shows a summary of all in-progress
  commands for a given adapter.  Specifically, it shows the status of any
  drive or volume activities currently in progress similar to the
  'drive process' and 'volume progress' commands.

Modified:
  stable/7/usr.sbin/mfiutil/mfi_show.c
  stable/7/usr.sbin/mfiutil/mfiutil.8
  stable/7/usr.sbin/mfiutil/mfiutil.c
Directory Properties:
  stable/7/usr.sbin/mfiutil/   (props changed)

Modified: stable/7/usr.sbin/mfiutil/mfi_show.c
==============================================================================
--- stable/7/usr.sbin/mfiutil/mfi_show.c	Wed Jun  8 21:10:44 2011	(r222872)
+++ stable/7/usr.sbin/mfiutil/mfi_show.c	Wed Jun  8 21:10:55 2011	(r222873)
@@ -571,7 +571,7 @@ show_firmware(int ac, char **av)
 	u_int i;
 
 	if (ac != 1) {
-		warnx("show drives: extra arguments");
+		warnx("show firmware: extra arguments");
 		return (EINVAL);
 	}
 
@@ -616,3 +616,112 @@ show_firmware(int ac, char **av)
 	return (0);
 }
 MFI_COMMAND(show, firmware, show_firmware);
+
+static int
+show_progress(int ac, char **av)
+{
+	struct mfi_ld_list llist;
+	struct mfi_pd_list *plist;
+	struct mfi_ld_info linfo;
+	struct mfi_pd_info pinfo;
+	int busy, error, fd;
+	u_int i;
+	
+	uint16_t device_id;
+	uint8_t target_id;
+
+	if (ac != 1) {
+		warnx("show progress: extra arguments");
+		return (EINVAL);
+	}
+
+	fd = mfi_open(mfi_unit);
+	if (fd < 0) {
+		error = errno;
+		warn("mfi_open");
+		return (error);
+	}
+	busy = 0;
+
+	if (mfi_ld_get_list(fd, &llist, NULL) < 0) {
+		error = errno;
+		warn("Failed to get volume list");
+		return (error);
+	}
+	if (mfi_pd_get_list(fd, &plist, NULL) < 0) {
+		error = errno;
+		warn("Failed to get drive list");
+		return (error);
+	}
+
+	for (i = 0; i < llist.ld_count; i++) {
+		target_id = llist.ld_list[i].ld.v.target_id;
+		if (mfi_ld_get_info(fd, target_id, &linfo, NULL) < 0) {
+			error = errno;
+			warn("Failed to get info for volume %s",
+			    mfi_volume_name(fd, target_id));
+			return (error);
+		}
+		if (linfo.progress.active & MFI_LD_PROGRESS_CC) {
+			printf("volume %s ", mfi_volume_name(fd, target_id));
+			mfi_display_progress("Consistency Check",
+			    &linfo.progress.cc);
+			busy = 1;
+		}
+		if (linfo.progress.active & MFI_LD_PROGRESS_BGI) {
+			printf("volume %s ", mfi_volume_name(fd, target_id));
+			mfi_display_progress("Background Init",
+			    &linfo.progress.bgi);
+			busy = 1;
+		}
+		if (linfo.progress.active & MFI_LD_PROGRESS_FGI) {
+			printf("volume %s ", mfi_volume_name(fd, target_id));
+			mfi_display_progress("Foreground Init",
+			    &linfo.progress.fgi);
+			busy = 1;
+		}
+		if (linfo.progress.active & MFI_LD_PROGRESS_RECON) {
+			printf("volume %s ", mfi_volume_name(fd, target_id));
+			mfi_display_progress("Reconstruction",
+			    &linfo.progress.recon);
+			busy = 1;
+		}
+	}
+
+	for (i = 0; i < plist->count; i++) {
+		if (plist->addr[i].scsi_dev_type != 0)
+			continue;
+
+		device_id = plist->addr[i].device_id;
+		if (mfi_pd_get_info(fd, device_id, &pinfo, NULL) < 0) {
+			error = errno;
+			warn("Failed to fetch info for drive %u", device_id);
+			return (error);
+		}
+
+		if (pinfo.prog_info.active & MFI_PD_PROGRESS_REBUILD) {
+			printf("drive %u ", device_id);
+			mfi_display_progress("Rebuild", &pinfo.prog_info.rbld);
+			busy = 1;
+		}
+		if (pinfo.prog_info.active & MFI_PD_PROGRESS_PATROL) {
+			printf("drive %u ", device_id);
+			mfi_display_progress("Patrol Read",
+			    &pinfo.prog_info.patrol);
+			busy = 1;
+		}
+		if (pinfo.prog_info.active & MFI_PD_PROGRESS_CLEAR) {
+			printf("drive %u ", device_id);
+			mfi_display_progress("Clear", &pinfo.prog_info.clear);
+			busy = 1;
+		}
+	}
+
+	close(fd);
+
+	if (!busy)
+		printf("No activity in progress for adapter mfi%d\n", mfi_unit);
+
+	return (0);
+}
+MFI_COMMAND(show, progress, show_progress);

Modified: stable/7/usr.sbin/mfiutil/mfiutil.8
==============================================================================
--- stable/7/usr.sbin/mfiutil/mfiutil.8	Wed Jun  8 21:10:44 2011	(r222872)
+++ stable/7/usr.sbin/mfiutil/mfiutil.8	Wed Jun  8 21:10:55 2011	(r222873)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 5, 2011
+.Dd April 29, 2011
 .Dt MFIUTIL 8
 .Os
 .Sh NAME
@@ -67,6 +67,9 @@
 .Cm show patrol
 .Nm
 .Op Fl u Ar unit
+.Cm show progress
+.Nm
+.Op Fl u Ar unit
 .Cm show volumes
 .Nm
 .Op Fl u Ar unit
@@ -296,6 +299,9 @@ Lists all of the firmware images present
 Display the various sequence numbers associated with the event log.
 .It Cm show patrol
 Display the status of the controller's patrol read operation.
+.It Cm show progress
+Report the current progress and estimated completion time for active
+operations on all volumes and drives.
 .It Cm show volumes
 Lists all of the logical volumes managed by the controller.
 .El

Modified: stable/7/usr.sbin/mfiutil/mfiutil.c
==============================================================================
--- stable/7/usr.sbin/mfiutil/mfiutil.c	Wed Jun  8 21:10:44 2011	(r222872)
+++ stable/7/usr.sbin/mfiutil/mfiutil.c	Wed Jun  8 21:10:55 2011	(r222873)
@@ -60,6 +60,7 @@ usage(void)
 	fprintf(stderr, "    show firmware             - list firmware images\n");
 	fprintf(stderr, "    show volumes              - list logical volumes\n");
 	fprintf(stderr, "    show patrol               - display patrol read status\n");
+	fprintf(stderr, "    show progress             - display status of active operations\n");
 	fprintf(stderr, "    fail <drive>              - fail a physical drive\n");
 	fprintf(stderr, "    good <drive>              - mark a bad physical drive as good\n");
 	fprintf(stderr, "    rebuild <drive>           - mark failed drive ready for rebuild\n");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106082110.p58LAtNn047428>