FreeBSD Bugzilla – Attachment 244092 Details for
Bug 267654
UFS "cylinder checksum failed" on temporary storage or data disk on arm64 vm in Azure
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Disk alignment test
disk_align_test.c (text/plain), 1.88 KB, created by
Andrew Turner
on 2023-08-14 11:57:07 UTC
(
hide
)
Description:
Disk alignment test
Filename:
MIME Type:
Creator:
Andrew Turner
Created:
2023-08-14 11:57:07 UTC
Size:
1.88 KB
patch
obsolete
>/*- > * SPDX-License-Identifier: BSD-2-Clause > * > * Copyright (c) 2023, Arm Ltd > */ > >#include <sys/param.h> > >#include <assert.h> >#include <fcntl.h> >#include <stdbool.h> >#include <stdio.h> >#include <stdlib.h> >#include <string.h> >#include <unistd.h> > >#define PG_COUNT 2 > >int >main(int argc, char *argv[]) >{ > char *buf1, *buf2, *ptr; > ssize_t size; > int fd, rv; > bool print_bad, print_good; > > if (argc < 3) { >usage: > fprintf(stderr, "Usage:\n"); > fprintf(stderr, "%s /dev/<disk> [bad] [good]\n", argv[0]); > fprintf(stderr, " /dev/<disk>: The device to test\n"); > fprintf(stderr, " bad: Print alignments that have incorrect data\n"); > fprintf(stderr, " good: Print alignments that have correct data\n"); > return (1); > } > argv++; argc--; > > fd = open(argv[0], O_RDONLY); > assert(fd >= 0); > argv++; argc--; > > print_bad = false; > print_good = false; > while (argc != 0) { > if (strcmp(argv[0], "bad") == 0) > print_bad = true; > else if (strcmp(argv[0], "good") == 0) > print_good = true; > else > goto usage; > argv++; argc--; > } > > rv = posix_memalign((void **)&buf1, PAGE_SIZE, PAGE_SIZE * PG_COUNT); > assert(rv == 0); > rv = posix_memalign((void **)&buf2, PAGE_SIZE, PAGE_SIZE * (PG_COUNT + 1)); > assert(rv == 0); > > size = pread(fd, buf1, PAGE_SIZE * PG_COUNT, 0); > assert(size == PAGE_SIZE * PG_COUNT); > /* > * TODO: 1 byte alignment causes a checksum on Hyper-V on a > * Microsoft Dev Kit 2023 > */ > for (int i = 0; i < PAGE_SIZE; i+=2) { > ptr = buf2 + i; > > memset(buf2, 0xff, PAGE_SIZE * (PG_COUNT + 1)); > size = pread(fd, ptr, PAGE_SIZE * PG_COUNT, 0); > assert(size == PAGE_SIZE * PG_COUNT); > > if (memcmp(ptr, buf1, PAGE_SIZE) == 0) { > if (print_good) > printf("Good: %d\n", i); > } else { > if (print_bad) { > for (int j = 0; j < PAGE_SIZE * PG_COUNT; j++) { > if (ptr[j] != buf1[j]) { > printf("Bad: %d: %d %d\n", > i, j, i+j); > break; > } > } > } > } > } > printf("\n"); > > return (0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 267654
:
242385
| 244092 |
244186
|
244220
|
244573