From owner-svn-src-stable-8@FreeBSD.ORG Wed Jun 8 21:10:45 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 322EE106564A; Wed, 8 Jun 2011 21:10:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20A2E8FC0A; Wed, 8 Jun 2011 21:10:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p58LAj3M047389; Wed, 8 Jun 2011 21:10:45 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p58LAise047385; Wed, 8 Jun 2011 21:10:44 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201106082110.p58LAise047385@svn.freebsd.org> From: John Baldwin Date: Wed, 8 Jun 2011 21:10:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222872 - stable/8/usr.sbin/mfiutil X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2011 21:10:45 -0000 Author: jhb Date: Wed Jun 8 21:10:44 2011 New Revision: 222872 URL: http://svn.freebsd.org/changeset/base/222872 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/8/usr.sbin/mfiutil/mfi_show.c stable/8/usr.sbin/mfiutil/mfiutil.8 stable/8/usr.sbin/mfiutil/mfiutil.c Directory Properties: stable/8/usr.sbin/mfiutil/ (props changed) Modified: stable/8/usr.sbin/mfiutil/mfi_show.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_show.c Wed Jun 8 20:57:22 2011 (r222871) +++ stable/8/usr.sbin/mfiutil/mfi_show.c Wed Jun 8 21:10:44 2011 (r222872) @@ -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/8/usr.sbin/mfiutil/mfiutil.8 ============================================================================== --- stable/8/usr.sbin/mfiutil/mfiutil.8 Wed Jun 8 20:57:22 2011 (r222871) +++ stable/8/usr.sbin/mfiutil/mfiutil.8 Wed Jun 8 21:10:44 2011 (r222872) @@ -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/8/usr.sbin/mfiutil/mfiutil.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfiutil.c Wed Jun 8 20:57:22 2011 (r222871) +++ stable/8/usr.sbin/mfiutil/mfiutil.c Wed Jun 8 21:10:44 2011 (r222872) @@ -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 - fail a physical drive\n"); fprintf(stderr, " good - mark a bad physical drive as good\n"); fprintf(stderr, " rebuild - mark failed drive ready for rebuild\n");