Bug 184405 - [regression] [patch] mfiutil(8): 'mfiutil show drives' from 9.2-REL shows 0.0 size for all drives
Summary: [regression] [patch] mfiutil(8): 'mfiutil show drives' from 9.2-REL shows 0.0...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Sean Bruno
URL:
Keywords:
: 186835 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-12-01 05:30 UTC by zurvan.akarana
Modified: 2014-08-04 17:43 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (1.00 KB, patch)
2013-12-01 05:30 UTC, zurvan.akarana
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zurvan.akarana 2013-12-01 05:30:00 UTC
Upgraded to 9.2-RELEASE on Nov. 29, 2013.

Have an LSI-2108-based raid controller supported without issues by mfi(4).

Prior to upgrade 'mfiutil show drives' showed drive sizes correctly.

After upgrade the output became like this

 0 (   0.0) ONLINE <[redacted] serial=[redacted]> SATA E1:S4

I.e., drive size was reported to be 0.0.

All other aspects of mfi(4) that I have tested so far seem to work fine, as they did before.

Fix: Traced the problem to usr.sbin/mfiutil/mfi_show.c file, function print_pd.

It makes a call to humanize_number(3) from libutil and supplies a 256-byte buffer named 'buf' to be filled for this purpose. Then prints it with format string '%6s' which results in this incorrect behavior.

Just using a 6-byte buffer, supplying it to humanize_number(3), and printing it fixes the problem. As seen in the other function print_ld in the same source file.

This bug has been introduced as the larger sized 'buf' was added to source to allow for formatting status messages for foreign configurations present in the array, a new mfiutil functionality.

Patch attached with submission follows:
How-To-Repeat: Any run of 'mfiutil show drives' reproduces the problem. I use 3 TB drives connected to the controller but the problem is unaffected by drive size.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-12-01 22:30:06 UTC
Responsible Changed
From-To: freebsd-amd64->freebsd-bugs

reclassify.
Comment 2 Mark Linimon 2013-12-03 04:30:13 UTC
----- Forwarded message from John Baldwin <jhb@freebsd.org> -----

Date: Mon, 2 Dec 2013 15:46:03 -0500
From: John Baldwin <jhb@freebsd.org>
To: freebsd-amd64@freebsd.org
Cc: linimon@freebsd.org, freebsd-bugs@freebsd.org, Sean Bruno <sbruno@freebsd.org>
Subject: Re: bin/184405: [regression] [patch] mfiutil(8): 'mfiutil show drives' from 9.2-REL shows 0.0 size for all drives
User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20130906; KDE/4.5.5; amd64; ; )

Sean, can you take care of this since you committed the foreign config stuff?

I think you can simply replace sizeof(buf) in the call to humanize_number with
6 instead rather than using a separate array for the size as in the patch.

-- 
John Baldwin

----- End forwarded message -----
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2013-12-03 04:30:20 UTC
Responsible Changed
From-To: freebsd-bugs->sbruno

by suggestion of jhb.
Comment 4 dfilter service freebsd_committer freebsd_triage 2013-12-04 00:28:58 UTC
Author: sbruno
Date: Wed Dec  4 00:28:44 2013
New Revision: 258901
URL: http://svnweb.freebsd.org/changeset/base/258901

Log:
  svn r251516 resized the buf argument a bit too much.  Pass a hardcoded
  size of 6 to humanize_number() to resolve this.
  
  PR:		184405
  Submitted by:	jhb
  MFC after:	2 weeks

Modified:
  head/usr.sbin/mfiutil/mfi_show.c

Modified: head/usr.sbin/mfiutil/mfi_show.c
==============================================================================
--- head/usr.sbin/mfiutil/mfi_show.c	Wed Dec  4 00:10:37 2013	(r258900)
+++ head/usr.sbin/mfiutil/mfi_show.c	Wed Dec  4 00:28:44 2013	(r258901)
@@ -320,7 +320,7 @@ print_pd(struct mfi_pd_info *info, int s
 	const char *s;
 	char buf[256];
 
-	humanize_number(buf, sizeof(buf), info->raw_size * 512, "",
+	humanize_number(buf, 6, info->raw_size * 512, "",
 	    HN_AUTOSCALE, HN_B | HN_NOSPACE |HN_DECIMAL);
 	printf("(%6s) ", buf);
 	if (info->state.ddf.v.pd_type.is_foreign) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 5 dfilter service freebsd_committer freebsd_triage 2014-01-05 17:30:06 UTC
Author: sbruno
Date: Sun Jan  5 17:29:53 2014
New Revision: 260324
URL: http://svnweb.freebsd.org/changeset/base/260324

Log:
  MFC r258901:
  
  svn r251516 resized the buf argument a bit too much. Pass a hardcoded
  size of 6 to humanize_number() to resolve this.
  
  PR:	bin/184405
  Submitted by:	jhb

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

Modified: stable/10/usr.sbin/mfiutil/mfi_show.c
==============================================================================
--- stable/10/usr.sbin/mfiutil/mfi_show.c	Sun Jan  5 16:45:34 2014	(r260323)
+++ stable/10/usr.sbin/mfiutil/mfi_show.c	Sun Jan  5 17:29:53 2014	(r260324)
@@ -320,7 +320,7 @@ print_pd(struct mfi_pd_info *info, int s
 	const char *s;
 	char buf[256];
 
-	humanize_number(buf, sizeof(buf), info->raw_size * 512, "",
+	humanize_number(buf, 6, info->raw_size * 512, "",
 	    HN_AUTOSCALE, HN_B | HN_NOSPACE |HN_DECIMAL);
 	printf("(%6s) ", buf);
 	if (info->state.ddf.v.pd_type.is_foreign) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 dfilter service freebsd_committer freebsd_triage 2014-01-05 17:33:18 UTC
Author: sbruno
Date: Sun Jan  5 17:33:10 2014
New Revision: 260325
URL: http://svnweb.freebsd.org/changeset/base/260325

Log:
  MFC r258901:
  
  svn r251516 resized the buf argument a bit too much. Pass a hardcoded
  size of 6 to humanize_number() to resolve this.
  
  PR:     bin/184405
  Submitted by:   jhb

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

Modified: stable/9/usr.sbin/mfiutil/mfi_show.c
==============================================================================
--- stable/9/usr.sbin/mfiutil/mfi_show.c	Sun Jan  5 17:29:53 2014	(r260324)
+++ stable/9/usr.sbin/mfiutil/mfi_show.c	Sun Jan  5 17:33:10 2014	(r260325)
@@ -320,7 +320,7 @@ print_pd(struct mfi_pd_info *info, int s
 	const char *s;
 	char buf[256];
 
-	humanize_number(buf, sizeof(buf), info->raw_size * 512, "",
+	humanize_number(buf, 6, info->raw_size * 512, "",
 	    HN_AUTOSCALE, HN_B | HN_NOSPACE |HN_DECIMAL);
 	printf("(%6s) ", buf);
 	if (info->state.ddf.v.pd_type.is_foreign) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 7 Sean Bruno freebsd_committer freebsd_triage 2014-01-05 18:40:16 UTC
State Changed
From-To: open->closed

MFC to stable/9 and stable/10 complete
Comment 8 Mark Johnston freebsd_committer freebsd_triage 2014-08-04 17:43:12 UTC
*** Bug 186835 has been marked as a duplicate of this bug. ***