Add the ability to manage the state of write caching when the battery
back-up is missing or dead. The current state of this field is reported in 'mfiutil cache <volume>' and can be adjusted via 'mfiutil cache <volume> bad-bbu-write-cache <enable|disable>'. This setting should generally be disabled to avoid data loss. MFC after: 1 week
This commit is contained in:
parent
d61e085348
commit
4fde1ce654
@ -138,6 +138,10 @@ update_cache_policy(int fd, struct mfi_ld_props *props, uint8_t new_policy,
|
|||||||
policy & MR_LD_CACHE_READ_AHEAD ?
|
policy & MR_LD_CACHE_READ_AHEAD ?
|
||||||
(policy & MR_LD_CACHE_READ_ADAPTIVE ?
|
(policy & MR_LD_CACHE_READ_ADAPTIVE ?
|
||||||
"adaptive" : "always") : "none");
|
"adaptive" : "always") : "none");
|
||||||
|
if (changes & MR_LD_CACHE_WRITE_CACHE_BAD_BBU)
|
||||||
|
printf("%s write caching with bad BBU\n",
|
||||||
|
policy & MR_LD_CACHE_WRITE_CACHE_BAD_BBU ? "Enabling" :
|
||||||
|
"Disabling");
|
||||||
|
|
||||||
props->default_cache_policy = policy;
|
props->default_cache_policy = policy;
|
||||||
if (mfi_ld_set_props(fd, props) < 0) {
|
if (mfi_ld_set_props(fd, props) < 0) {
|
||||||
@ -182,7 +186,7 @@ volume_cache(int ac, char **av)
|
|||||||
if (ac == 2) {
|
if (ac == 2) {
|
||||||
printf("mfi%u volume %s cache settings:\n", mfi_unit,
|
printf("mfi%u volume %s cache settings:\n", mfi_unit,
|
||||||
mfi_volume_name(fd, target_id));
|
mfi_volume_name(fd, target_id));
|
||||||
printf(" I/O caching: ");
|
printf(" I/O caching: ");
|
||||||
switch (props.default_cache_policy &
|
switch (props.default_cache_policy &
|
||||||
(MR_LD_CACHE_ALLOW_WRITE_CACHE |
|
(MR_LD_CACHE_ALLOW_WRITE_CACHE |
|
||||||
MR_LD_CACHE_ALLOW_READ_CACHE)) {
|
MR_LD_CACHE_ALLOW_READ_CACHE)) {
|
||||||
@ -200,14 +204,17 @@ volume_cache(int ac, char **av)
|
|||||||
printf("writes and reads\n");
|
printf("writes and reads\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf(" write caching: %s\n",
|
printf(" write caching: %s\n",
|
||||||
props.default_cache_policy & MR_LD_CACHE_WRITE_BACK ?
|
props.default_cache_policy & MR_LD_CACHE_WRITE_BACK ?
|
||||||
"write-back" : "write-through");
|
"write-back" : "write-through");
|
||||||
printf(" read ahead: %s\n",
|
printf("write cache with bad BBU: %s\n",
|
||||||
|
props.default_cache_policy &
|
||||||
|
MR_LD_CACHE_WRITE_CACHE_BAD_BBU ? "enabled" : "disabled");
|
||||||
|
printf(" read ahead: %s\n",
|
||||||
props.default_cache_policy & MR_LD_CACHE_READ_AHEAD ?
|
props.default_cache_policy & MR_LD_CACHE_READ_AHEAD ?
|
||||||
(props.default_cache_policy & MR_LD_CACHE_READ_ADAPTIVE ?
|
(props.default_cache_policy & MR_LD_CACHE_READ_ADAPTIVE ?
|
||||||
"adaptive" : "always") : "none");
|
"adaptive" : "always") : "none");
|
||||||
printf("drive write cache: ");
|
printf(" drive write cache: ");
|
||||||
switch (props.disk_cache_policy) {
|
switch (props.disk_cache_policy) {
|
||||||
case MR_PD_CACHE_UNCHANGED:
|
case MR_PD_CACHE_UNCHANGED:
|
||||||
printf("default\n");
|
printf("default\n");
|
||||||
@ -273,6 +280,21 @@ volume_cache(int ac, char **av)
|
|||||||
error = update_cache_policy(fd, &props, policy,
|
error = update_cache_policy(fd, &props, policy,
|
||||||
MR_LD_CACHE_READ_AHEAD |
|
MR_LD_CACHE_READ_AHEAD |
|
||||||
MR_LD_CACHE_READ_ADAPTIVE);
|
MR_LD_CACHE_READ_ADAPTIVE);
|
||||||
|
} else if (strcmp(av[2], "bad-bbu-write-cache") == 0) {
|
||||||
|
if (ac < 4) {
|
||||||
|
warnx("cache: bad BBU setting required");
|
||||||
|
return (EINVAL);
|
||||||
|
}
|
||||||
|
if (strcmp(av[3], "enable") == 0)
|
||||||
|
policy = MR_LD_CACHE_WRITE_CACHE_BAD_BBU;
|
||||||
|
else if (strcmp(av[3], "disable") == 0)
|
||||||
|
policy = 0;
|
||||||
|
else {
|
||||||
|
warnx("cache: invalid bad BBU setting");
|
||||||
|
return (EINVAL);
|
||||||
|
}
|
||||||
|
error = update_cache_policy(fd, &props, policy,
|
||||||
|
MR_LD_CACHE_WRITE_CACHE_BAD_BBU);
|
||||||
} else if (strcmp(av[2], "write-cache") == 0) {
|
} else if (strcmp(av[2], "write-cache") == 0) {
|
||||||
if (ac < 4) {
|
if (ac < 4) {
|
||||||
warnx("cache: write-cache setting required");
|
warnx("cache: write-cache setting required");
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd August 16, 2009
|
.Dd April 5, 2011
|
||||||
.Dt MFIUTIL 8
|
.Dt MFIUTIL 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -367,7 +367,7 @@ Enable caching only for write I/O operations.
|
|||||||
Use write-back policy for cached writes.
|
Use write-back policy for cached writes.
|
||||||
.It Cm write-through
|
.It Cm write-through
|
||||||
Use write-through policy for cached writes.
|
Use write-through policy for cached writes.
|
||||||
.It Cm read-ahead Op Ar value
|
.It Cm read-ahead Ar value
|
||||||
Set the read ahead policy for cached reads.
|
Set the read ahead policy for cached reads.
|
||||||
The
|
The
|
||||||
.Ar value
|
.Ar value
|
||||||
@ -376,7 +376,18 @@ argument can be set to either
|
|||||||
.Dq adaptive ,
|
.Dq adaptive ,
|
||||||
or
|
or
|
||||||
.Dq always .
|
.Dq always .
|
||||||
.It Cm write-cache Op Ar value
|
.It Cm bad-bbu-write-cache Ar value
|
||||||
|
Control the behavior of I/O write caching if the battery is dead or
|
||||||
|
missing.
|
||||||
|
The
|
||||||
|
.Ar value
|
||||||
|
argument can be set to either
|
||||||
|
.Dq disable
|
||||||
|
or
|
||||||
|
.Dq enable .
|
||||||
|
In general this setting should be left disabled to avoid data loss when
|
||||||
|
the system loses power.
|
||||||
|
.It Cm write-cache Ar value
|
||||||
Control the write caches on the physical drives backing
|
Control the write caches on the physical drives backing
|
||||||
.Ar volume .
|
.Ar volume .
|
||||||
The
|
The
|
||||||
|
Loading…
x
Reference in New Issue
Block a user