Make bioctl(4) print cache policy

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Make bioctl(4) print cache policy

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 Online        72746008576 sd0     RAID1 WB
          0 Online        73407820800 1:0.0   noencl <HITACHI HUS153073VLS300 A598>
          1 Online        73407820800 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.c 10 Sep 2012 11:28:47 -0000 1.112
+++ sbin/bioctl/bioctl.c 22 Oct 2013 12:47:36 -0000
@@ -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;
+ char size[64], scsiname[16], volname[32];
  char percent[10], seconds[20];
  int i, d, volheader, hotspare, unused;
  char encname[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.h 20 Jan 2012 12:38:19 -0000 1.42
+++ sys/dev/biovar.h 22 Oct 2013 12:47:37 -0000
@@ -139,6 +139,13 @@ struct bioc_vol {
  u_quad_t bv_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_CVWRITETHROUGH 0x02
+#define BIOC_CVWRITETHROUGH_S "WT"
 
  char bv_dev[16]; /* device */
  char bv_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.c 9 Oct 2013 09:40:01 -0000 1.147
+++ sys/dev/ic/mfi.c 22 Oct 2013 12:47:37 -0000
@@ -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.

Reply | Threaded
Open this post in threaded view
|

Re: Make bioctl(4) print cache policy

Mike Belopuhov-5
On 22 October 2013 15:22, Mark Kettenis <[hidden email]> 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 Online        72746008576 sd0     RAID1 WB
>           0 Online        73407820800 1:0.0   noencl <HITACHI HUS153073VLS300 A598>
>           1 Online        73407820800 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.

Reply | Threaded
Open this post in threaded view
|

Re: Make bioctl(4) print cache policy

Nick Holland
On 10/22/13 09:47, Mike Belopuhov wrote:

> On 22 October 2013 15:22, Mark Kettenis <[hidden email]> 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 Online        72746008576 sd0     RAID1 WB
>>           0 Online        73407820800 1:0.0   noencl <HITACHI HUS153073VLS300 A598>
>>           1 Online        73407820800 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 loooong 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.


Reply | Threaded
Open this post in threaded view
|

Re: Make bioctl(4) print cache policy

Mark Kettenis
In reply to this post by Mike Belopuhov-5
> From: Mike Belopuhov <[hidden email]>
> Date: Tue, 22 Oct 2013 15:48:22 +0200
>
> On 22 October 2013 15:22, Mark Kettenis <[hidden email]> 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 Online        72746008576 sd0     RAID1 WB
> >           0 Online        73407820800 1:0.0   noencl <HITACHI HUS153073VLS300 A598>
> >           1 Online        73407820800 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.