Date: Fri, 29 Apr 2011 14:06:37 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r221208 - head/usr.sbin/mfiutil Message-ID: <201104291406.p3TE6bHD002161@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Fri Apr 29 14:06:37 2011 New Revision: 221208 URL: http://svn.freebsd.org/changeset/base/221208 Log: 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. Reviewed by: emaste MFC after: 1 week Modified: head/usr.sbin/mfiutil/mfi_show.c head/usr.sbin/mfiutil/mfiutil.8 head/usr.sbin/mfiutil/mfiutil.c Modified: head/usr.sbin/mfiutil/mfi_show.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_show.c Fri Apr 29 14:01:49 2011 (r221207) +++ head/usr.sbin/mfiutil/mfi_show.c Fri Apr 29 14:06:37 2011 (r221208) @@ -572,7 +572,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); } @@ -617,3 +617,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: head/usr.sbin/mfiutil/mfiutil.8 ============================================================================== --- head/usr.sbin/mfiutil/mfiutil.8 Fri Apr 29 14:01:49 2011 (r221207) +++ head/usr.sbin/mfiutil/mfiutil.8 Fri Apr 29 14:06:37 2011 (r221208) @@ -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: head/usr.sbin/mfiutil/mfiutil.c ============================================================================== --- head/usr.sbin/mfiutil/mfiutil.c Fri Apr 29 14:01:49 2011 (r221207) +++ head/usr.sbin/mfiutil/mfiutil.c Fri Apr 29 14:06:37 2011 (r221208) @@ -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?201104291406.p3TE6bHD002161>