mfi_volume.c (220363) | mfi_volume.c (222899) |
---|---|
1/*- 2 * Copyright (c) 2008, 2009 Yahoo!, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2008, 2009 Yahoo!, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/usr.sbin/mfiutil/mfi_volume.c 220363 2011-04-05 14:19:05Z jhb $ | 29 * $FreeBSD: head/usr.sbin/mfiutil/mfi_volume.c 222899 2011-06-09 19:52:28Z bz $ |
30 */ 31 32#include <sys/types.h> 33#include <sys/errno.h> 34#include <err.h> 35#include <libutil.h> 36#include <stdio.h> 37#include <stdlib.h> --- 131 unchanged lines hidden (view full) --- 169 error = errno; 170 warn("mfi_open"); 171 return (error); 172 } 173 174 if (mfi_lookup_volume(fd, av[1], &target_id) < 0) { 175 error = errno; 176 warn("Invalid volume: %s", av[1]); | 30 */ 31 32#include <sys/types.h> 33#include <sys/errno.h> 34#include <err.h> 35#include <libutil.h> 36#include <stdio.h> 37#include <stdlib.h> --- 131 unchanged lines hidden (view full) --- 169 error = errno; 170 warn("mfi_open"); 171 return (error); 172 } 173 174 if (mfi_lookup_volume(fd, av[1], &target_id) < 0) { 175 error = errno; 176 warn("Invalid volume: %s", av[1]); |
177 close(fd); |
|
177 return (error); 178 } 179 180 if (mfi_ld_get_props(fd, target_id, &props) < 0) { 181 error = errno; 182 warn("Failed to fetch volume properties"); | 178 return (error); 179 } 180 181 if (mfi_ld_get_props(fd, target_id, &props) < 0) { 182 error = errno; 183 warn("Failed to fetch volume properties"); |
184 close(fd); |
|
183 return (error); 184 } 185 186 if (ac == 2) { 187 printf("mfi%u volume %s cache settings:\n", mfi_unit, 188 mfi_volume_name(fd, target_id)); 189 printf(" I/O caching: "); 190 switch (props.default_cache_policy & --- 68 unchanged lines hidden (view full) --- 259 MR_LD_CACHE_WRITE_BACK, 260 MR_LD_CACHE_WRITE_BACK); 261 else if (strcmp(av[2], "write-through") == 0) 262 error = update_cache_policy(fd, &props, 0, 263 MR_LD_CACHE_WRITE_BACK); 264 else if (strcmp(av[2], "read-ahead") == 0) { 265 if (ac < 4) { 266 warnx("cache: read-ahead setting required"); | 185 return (error); 186 } 187 188 if (ac == 2) { 189 printf("mfi%u volume %s cache settings:\n", mfi_unit, 190 mfi_volume_name(fd, target_id)); 191 printf(" I/O caching: "); 192 switch (props.default_cache_policy & --- 68 unchanged lines hidden (view full) --- 261 MR_LD_CACHE_WRITE_BACK, 262 MR_LD_CACHE_WRITE_BACK); 263 else if (strcmp(av[2], "write-through") == 0) 264 error = update_cache_policy(fd, &props, 0, 265 MR_LD_CACHE_WRITE_BACK); 266 else if (strcmp(av[2], "read-ahead") == 0) { 267 if (ac < 4) { 268 warnx("cache: read-ahead setting required"); |
269 close(fd); |
|
267 return (EINVAL); 268 } 269 if (strcmp(av[3], "none") == 0) 270 policy = 0; 271 else if (strcmp(av[3], "always") == 0) 272 policy = MR_LD_CACHE_READ_AHEAD; 273 else if (strcmp(av[3], "adaptive") == 0) 274 policy = MR_LD_CACHE_READ_AHEAD | 275 MR_LD_CACHE_READ_ADAPTIVE; 276 else { 277 warnx("cache: invalid read-ahead setting"); | 270 return (EINVAL); 271 } 272 if (strcmp(av[3], "none") == 0) 273 policy = 0; 274 else if (strcmp(av[3], "always") == 0) 275 policy = MR_LD_CACHE_READ_AHEAD; 276 else if (strcmp(av[3], "adaptive") == 0) 277 policy = MR_LD_CACHE_READ_AHEAD | 278 MR_LD_CACHE_READ_ADAPTIVE; 279 else { 280 warnx("cache: invalid read-ahead setting"); |
281 close(fd); |
|
278 return (EINVAL); 279 } 280 error = update_cache_policy(fd, &props, policy, 281 MR_LD_CACHE_READ_AHEAD | 282 MR_LD_CACHE_READ_ADAPTIVE); 283 } else if (strcmp(av[2], "bad-bbu-write-cache") == 0) { 284 if (ac < 4) { 285 warnx("cache: bad BBU setting required"); | 282 return (EINVAL); 283 } 284 error = update_cache_policy(fd, &props, policy, 285 MR_LD_CACHE_READ_AHEAD | 286 MR_LD_CACHE_READ_ADAPTIVE); 287 } else if (strcmp(av[2], "bad-bbu-write-cache") == 0) { 288 if (ac < 4) { 289 warnx("cache: bad BBU setting required"); |
290 close(fd); |
|
286 return (EINVAL); 287 } 288 if (strcmp(av[3], "enable") == 0) 289 policy = MR_LD_CACHE_WRITE_CACHE_BAD_BBU; 290 else if (strcmp(av[3], "disable") == 0) 291 policy = 0; 292 else { 293 warnx("cache: invalid bad BBU setting"); | 291 return (EINVAL); 292 } 293 if (strcmp(av[3], "enable") == 0) 294 policy = MR_LD_CACHE_WRITE_CACHE_BAD_BBU; 295 else if (strcmp(av[3], "disable") == 0) 296 policy = 0; 297 else { 298 warnx("cache: invalid bad BBU setting"); |
299 close(fd); |
|
294 return (EINVAL); 295 } 296 error = update_cache_policy(fd, &props, policy, 297 MR_LD_CACHE_WRITE_CACHE_BAD_BBU); 298 } else if (strcmp(av[2], "write-cache") == 0) { 299 if (ac < 4) { 300 warnx("cache: write-cache setting required"); | 300 return (EINVAL); 301 } 302 error = update_cache_policy(fd, &props, policy, 303 MR_LD_CACHE_WRITE_CACHE_BAD_BBU); 304 } else if (strcmp(av[2], "write-cache") == 0) { 305 if (ac < 4) { 306 warnx("cache: write-cache setting required"); |
307 close(fd); |
|
301 return (EINVAL); 302 } 303 if (strcmp(av[3], "enable") == 0) 304 policy = MR_PD_CACHE_ENABLE; 305 else if (strcmp(av[3], "disable") == 0) 306 policy = MR_PD_CACHE_DISABLE; 307 else if (strcmp(av[3], "default") == 0) 308 policy = MR_PD_CACHE_UNCHANGED; 309 else { 310 warnx("cache: invalid write-cache setting"); | 308 return (EINVAL); 309 } 310 if (strcmp(av[3], "enable") == 0) 311 policy = MR_PD_CACHE_ENABLE; 312 else if (strcmp(av[3], "disable") == 0) 313 policy = MR_PD_CACHE_DISABLE; 314 else if (strcmp(av[3], "default") == 0) 315 policy = MR_PD_CACHE_UNCHANGED; 316 else { 317 warnx("cache: invalid write-cache setting"); |
318 close(fd); |
|
311 return (EINVAL); 312 } 313 error = 0; 314 if (policy != props.disk_cache_policy) { 315 switch (policy) { 316 case MR_PD_CACHE_ENABLE: 317 printf("Enabling write-cache on physical drives\n"); 318 break; --- 7 unchanged lines hidden (view full) --- 326 props.disk_cache_policy = policy; 327 if (mfi_ld_set_props(fd, &props) < 0) { 328 error = errno; 329 warn("Failed to set volume properties"); 330 } 331 } 332 } else { 333 warnx("cache: Invalid command"); | 319 return (EINVAL); 320 } 321 error = 0; 322 if (policy != props.disk_cache_policy) { 323 switch (policy) { 324 case MR_PD_CACHE_ENABLE: 325 printf("Enabling write-cache on physical drives\n"); 326 break; --- 7 unchanged lines hidden (view full) --- 334 props.disk_cache_policy = policy; 335 if (mfi_ld_set_props(fd, &props) < 0) { 336 error = errno; 337 warn("Failed to set volume properties"); 338 } 339 } 340 } else { 341 warnx("cache: Invalid command"); |
342 close(fd); |
|
334 return (EINVAL); 335 } 336 } 337 close(fd); 338 339 return (error); 340} 341MFI_COMMAND(top, cache, volume_cache); --- 20 unchanged lines hidden (view full) --- 362 error = errno; 363 warn("mfi_open"); 364 return (error); 365 } 366 367 if (mfi_lookup_volume(fd, av[1], &target_id) < 0) { 368 error = errno; 369 warn("Invalid volume: %s", av[1]); | 343 return (EINVAL); 344 } 345 } 346 close(fd); 347 348 return (error); 349} 350MFI_COMMAND(top, cache, volume_cache); --- 20 unchanged lines hidden (view full) --- 371 error = errno; 372 warn("mfi_open"); 373 return (error); 374 } 375 376 if (mfi_lookup_volume(fd, av[1], &target_id) < 0) { 377 error = errno; 378 warn("Invalid volume: %s", av[1]); |
379 close(fd); |
|
370 return (error); 371 } 372 373 if (mfi_ld_get_props(fd, target_id, &props) < 0) { 374 error = errno; 375 warn("Failed to fetch volume properties"); | 380 return (error); 381 } 382 383 if (mfi_ld_get_props(fd, target_id, &props) < 0) { 384 error = errno; 385 warn("Failed to fetch volume properties"); |
386 close(fd); |
|
376 return (error); 377 } 378 379 printf("mfi%u volume %s name changed from \"%s\" to \"%s\"\n", mfi_unit, 380 mfi_volume_name(fd, target_id), props.name, av[2]); 381 bzero(props.name, sizeof(props.name)); 382 strcpy(props.name, av[2]); 383 if (mfi_ld_set_props(fd, &props) < 0) { 384 error = errno; 385 warn("Failed to set volume properties"); | 387 return (error); 388 } 389 390 printf("mfi%u volume %s name changed from \"%s\" to \"%s\"\n", mfi_unit, 391 mfi_volume_name(fd, target_id), props.name, av[2]); 392 bzero(props.name, sizeof(props.name)); 393 strcpy(props.name, av[2]); 394 if (mfi_ld_set_props(fd, &props) < 0) { 395 error = errno; 396 warn("Failed to set volume properties"); |
397 close(fd); |
|
386 return (error); 387 } 388 389 close(fd); 390 391 return (0); 392} 393MFI_COMMAND(top, name, volume_name); --- 16 unchanged lines hidden (view full) --- 410 error = errno; 411 warn("mfi_open"); 412 return (error); 413 } 414 415 if (mfi_lookup_volume(fd, av[1], &target_id) < 0) { 416 error = errno; 417 warn("Invalid volume: %s", av[1]); | 398 return (error); 399 } 400 401 close(fd); 402 403 return (0); 404} 405MFI_COMMAND(top, name, volume_name); --- 16 unchanged lines hidden (view full) --- 422 error = errno; 423 warn("mfi_open"); 424 return (error); 425 } 426 427 if (mfi_lookup_volume(fd, av[1], &target_id) < 0) { 428 error = errno; 429 warn("Invalid volume: %s", av[1]); |
430 close(fd); |
|
418 return (error); 419 } 420 421 /* Get the info for this drive. */ 422 if (mfi_ld_get_info(fd, target_id, &info, NULL) < 0) { 423 error = errno; 424 warn("Failed to fetch info for volume %s", 425 mfi_volume_name(fd, target_id)); | 431 return (error); 432 } 433 434 /* Get the info for this drive. */ 435 if (mfi_ld_get_info(fd, target_id, &info, NULL) < 0) { 436 error = errno; 437 warn("Failed to fetch info for volume %s", 438 mfi_volume_name(fd, target_id)); |
439 close(fd); |
|
426 return (error); 427 } 428 429 /* Display any of the active events. */ 430 if (info.progress.active & MFI_LD_PROGRESS_CC) 431 mfi_display_progress("Consistency Check", &info.progress.cc); 432 if (info.progress.active & MFI_LD_PROGRESS_BGI) 433 mfi_display_progress("Background Init", &info.progress.bgi); --- 13 unchanged lines hidden --- | 440 return (error); 441 } 442 443 /* Display any of the active events. */ 444 if (info.progress.active & MFI_LD_PROGRESS_CC) 445 mfi_display_progress("Consistency Check", &info.progress.cc); 446 if (info.progress.active & MFI_LD_PROGRESS_BGI) 447 mfi_display_progress("Background Init", &info.progress.bgi); --- 13 unchanged lines hidden --- |