Re: Make bioctl(4) print cache policy

2013-10-23 Thread Mark Kettenis
 From: Mike Belopuhov m...@belopuhov.com
 Date: Tue, 22 Oct 2013 15:48:22 +0200
 
 On 22 October 2013 15:22, Mark Kettenis mark.kette...@xs4all.nl wrote:
  Diff below makes bioctl(4) print the cache policy for that's currently
  in effect for RAID volumes.  It only prints the state (WB for
  write-back, WT for write-through) if the RAID controller driver fills
  in the details in response to a BIOCVOL ioctl.  This diff adds such
  support to mfi(4).
 
  # bioctl mfi0
  Volume  Status   Size Device
   mfi0 0 Online72746008576 sd0 RAID1 WB
0 Online73407820800 1:0.0   noencl HITACHI 
  HUS153073VLS300 A598
1 Online73407820800 1:1.0   noencl HITACHI 
  HUS153073VLS300 A598
 
  ok?
 
 
 
 mpii specs do not use terms write-back or write-through, they rather
 talk about write cache being enabled or disabled.  they obviously
 mean write-back cache.  i believe for the bioctl user it's more
 important to know if actual writes are deferred or not, so i would
 rather say Write Cache Enabled/Disabled or Write Cache On/Off or
 something similar rather then if it's WB or WT.  oterwise people will
 have to look in the man page for what WB or WT stands for and then
 search wikipedia for what does it mean..
 
 just my 2 cents.

I committed the diff as-is.  As dlg@ pointed out things are a bit more
complicated than just a binary on/off.  At least the mechanism is
there now, and it is easy to change the way bioctl(8) presents this
information to the user.



Make bioctl(4) print cache policy

2013-10-22 Thread Mark Kettenis
Diff below makes bioctl(4) print the cache policy for that's currently
in effect for RAID volumes.  It only prints the state (WB for
write-back, WT for write-through) if the RAID controller driver fills
in the details in response to a BIOCVOL ioctl.  This diff adds such
support to mfi(4).

# bioctl mfi0
Volume  Status   Size Device  
 mfi0 0 Online72746008576 sd0 RAID1 WB
  0 Online73407820800 1:0.0   noencl HITACHI HUS153073VLS300 
A598
  1 Online73407820800 1:1.0   noencl HITACHI HUS153073VLS300 
A598

ok?


Index: sbin/bioctl/bioctl.c
===
RCS file: /cvs/src/sbin/bioctl/bioctl.c,v
retrieving revision 1.112
diff -u -p -r1.112 bioctl.c
--- sbin/bioctl/bioctl.c10 Sep 2012 11:28:47 -  1.112
+++ sbin/bioctl/bioctl.c22 Oct 2013 12:47:36 -
@@ -334,7 +334,8 @@ bio_status(struct bio_status *bs)
 void
 bio_inq(char *name)
 {
-   char*status, size[64], scsiname[16], volname[32];
+   char*status, *cache;
+   charsize[64], scsiname[16], volname[32];
charpercent[10], seconds[20];
int i, d, volheader, hotspare, unused;
charencname[16], serial[32];
@@ -409,6 +410,17 @@ bio_inq(char *name)
default:
status = BIOC_SVINVALID_S;
}
+   switch (bv.bv_cache) {
+   case BIOC_CVWRITEBACK:
+   cache = BIOC_CVWRITEBACK_S;
+   break;
+   case BIOC_CVWRITETHROUGH:
+   cache = BIOC_CVWRITETHROUGH_S;
+   break;
+   case BIOC_CVUNKNOWN:
+   default:
+   cache = BIOC_CVUNKNOWN_S;
+   }
 
snprintf(volname, sizeof volname, %s %u,
bi.bi_dev, bv.bv_volid);
@@ -437,9 +449,9 @@ bio_inq(char *name)
percent, seconds);
break;
default:
-   printf(%11s %-10s %14s %-7s RAID%u%s%s\n,
+   printf(%11s %-10s %14s %-7s RAID%u%s%s %s\n,
volname, status, size, bv.bv_dev,
-   bv.bv_level, percent, seconds);
+   bv.bv_level, percent, seconds, cache);
break;
}

Index: sys/dev/biovar.h
===
RCS file: /cvs/src/sys/dev/biovar.h,v
retrieving revision 1.42
diff -u -p -r1.42 biovar.h
--- sys/dev/biovar.h20 Jan 2012 12:38:19 -  1.42
+++ sys/dev/biovar.h22 Oct 2013 12:47:37 -
@@ -139,6 +139,13 @@ struct bioc_vol {
u_quad_tbv_size;/* size of the disk */
int bv_level;   /* raid level */
int bv_nodisk;  /* nr of drives */
+   int bv_cache;   /* cache mode */
+#define BIOC_CVUNKNOWN 0x00
+#define BIOC_CVUNKNOWN_S   
+#define BIOC_CVWRITEBACK   0x01
+#define BIOC_CVWRITEBACK_S WB
+#define BIOC_CVWRITETHROUGH0x02
+#define BIOC_CVWRITETHROUGH_S  WT
 
charbv_dev[16]; /* device */
charbv_vendor[32];  /* scsi string */
Index: sys/dev/ic/mfi.c
===
RCS file: /cvs/src/sys/dev/ic/mfi.c,v
retrieving revision 1.147
diff -u -p -r1.147 mfi.c
--- sys/dev/ic/mfi.c9 Oct 2013 09:40:01 -   1.147
+++ sys/dev/ic/mfi.c22 Oct 2013 12:47:37 -
@@ -1629,6 +1629,11 @@ mfi_ioctl_vol(struct mfi_softc *sc, stru
break;
}
 
+   if (sc-sc_ld_details[i].mld_cfg.mlc_prop.mlp_cur_cache_policy  0x01)
+   bv-bv_cache = BIOC_CVWRITEBACK;
+   else
+   bv-bv_cache = BIOC_CVWRITETHROUGH;
+
/*
 * The RAID levels are determined per the SNIA DDF spec, this is only
 * a subset that is valid for the MFI controller.



Re: Make bioctl(4) print cache policy

2013-10-22 Thread Mike Belopuhov
On 22 October 2013 15:22, Mark Kettenis mark.kette...@xs4all.nl wrote:
 Diff below makes bioctl(4) print the cache policy for that's currently
 in effect for RAID volumes.  It only prints the state (WB for
 write-back, WT for write-through) if the RAID controller driver fills
 in the details in response to a BIOCVOL ioctl.  This diff adds such
 support to mfi(4).

 # bioctl mfi0
 Volume  Status   Size Device
  mfi0 0 Online72746008576 sd0 RAID1 WB
   0 Online73407820800 1:0.0   noencl HITACHI HUS153073VLS300 
 A598
   1 Online73407820800 1:1.0   noencl HITACHI HUS153073VLS300 
 A598

 ok?



mpii specs do not use terms write-back or write-through, they rather
talk about write cache being enabled or disabled.  they obviously
mean write-back cache.  i believe for the bioctl user it's more
important to know if actual writes are deferred or not, so i would
rather say Write Cache Enabled/Disabled or Write Cache On/Off or
something similar rather then if it's WB or WT.  oterwise people will
have to look in the man page for what WB or WT stands for and then
search wikipedia for what does it mean..

just my 2 cents.



Re: Make bioctl(4) print cache policy

2013-10-22 Thread Nick Holland
On 10/22/13 09:47, Mike Belopuhov wrote:
 On 22 October 2013 15:22, Mark Kettenis mark.kette...@xs4all.nl wrote:
 Diff below makes bioctl(4) print the cache policy for that's currently
 in effect for RAID volumes.  It only prints the state (WB for
 write-back, WT for write-through) if the RAID controller driver fills
 in the details in response to a BIOCVOL ioctl.  This diff adds such
 support to mfi(4).

 # bioctl mfi0
 Volume  Status   Size Device
  mfi0 0 Online72746008576 sd0 RAID1 WB
   0 Online73407820800 1:0.0   noencl HITACHI 
 HUS153073VLS300 A598
   1 Online73407820800 1:1.0   noencl HITACHI 
 HUS153073VLS300 A598

 ok?


 
 mpii specs do not use terms write-back or write-through, they rather
 talk about write cache being enabled or disabled.  they obviously
 mean write-back cache.  i believe for the bioctl user it's more
 important to know if actual writes are deferred or not, so i would
 rather say Write Cache Enabled/Disabled or Write Cache On/Off or
 something similar rather then if it's WB or WT.  oterwise people will
 have to look in the man page for what WB or WT stands for and then
 search wikipedia for what does it mean..
 
 just my 2 cents.

And my 1 cent is that I agree...  I live, work and play with Dell
hardware, been working with their RAID controllers for a lng time,
but I STILL need to think about write through...write back...
lessee... write THROUGH means it is going right to the disk, so not
using the cache, that's bad, I want 'write back'

Nick.