mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-01-25 10:12:13 +03:00
Enable zhack to work properly with 4k sector size disks
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Closes #17576
This commit is contained in:
parent
26983d6fa7
commit
e2e708241a
@ -70,7 +70,8 @@ static __attribute__((noreturn)) void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
(void) fprintf(stderr,
|
(void) fprintf(stderr,
|
||||||
"Usage: zhack [-c cachefile] [-d dir] <subcommand> <args> ...\n"
|
"Usage: zhack [-o tunable] [-c cachefile] [-d dir] <subcommand> "
|
||||||
|
"<args> ...\n"
|
||||||
"where <subcommand> <args> is one of the following:\n"
|
"where <subcommand> <args> is one of the following:\n"
|
||||||
"\n");
|
"\n");
|
||||||
|
|
||||||
@ -1169,7 +1170,7 @@ main(int argc, char **argv)
|
|||||||
dprintf_setup(&argc, argv);
|
dprintf_setup(&argc, argv);
|
||||||
zfs_prop_init();
|
zfs_prop_init();
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "+c:d:")) != -1) {
|
while ((c = getopt(argc, argv, "+c:d:o:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
g_importargs.cachefile = optarg;
|
g_importargs.cachefile = optarg;
|
||||||
@ -1178,6 +1179,10 @@ main(int argc, char **argv)
|
|||||||
assert(g_importargs.paths < MAX_NUM_PATHS);
|
assert(g_importargs.paths < MAX_NUM_PATHS);
|
||||||
g_importargs.path[g_importargs.paths++] = optarg;
|
g_importargs.path[g_importargs.paths++] = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
if (handle_tunable_option(optarg, B_FALSE) != 0)
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ void zfs_file_close(zfs_file_t *fp);
|
|||||||
|
|
||||||
int zfs_file_write(zfs_file_t *fp, const void *buf, size_t len, ssize_t *resid);
|
int zfs_file_write(zfs_file_t *fp, const void *buf, size_t len, ssize_t *resid);
|
||||||
int zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t len, loff_t off,
|
int zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t len, loff_t off,
|
||||||
ssize_t *resid);
|
uint8_t ashift, ssize_t *resid);
|
||||||
int zfs_file_read(zfs_file_t *fp, void *buf, size_t len, ssize_t *resid);
|
int zfs_file_read(zfs_file_t *fp, void *buf, size_t len, ssize_t *resid);
|
||||||
int zfs_file_pread(zfs_file_t *fp, void *buf, size_t len, loff_t off,
|
int zfs_file_pread(zfs_file_t *fp, void *buf, size_t len, loff_t off,
|
||||||
ssize_t *resid);
|
ssize_t *resid);
|
||||||
|
|||||||
@ -1238,7 +1238,7 @@ zfs_file_write(zfs_file_t *fp, const void *buf, size_t count, ssize_t *resid)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
zfs_file_pwrite(zfs_file_t *fp, const void *buf,
|
zfs_file_pwrite(zfs_file_t *fp, const void *buf,
|
||||||
size_t count, loff_t pos, ssize_t *resid)
|
size_t count, loff_t pos, uint8_t ashift, ssize_t *resid)
|
||||||
{
|
{
|
||||||
ssize_t rc, split, done;
|
ssize_t rc, split, done;
|
||||||
int sectors;
|
int sectors;
|
||||||
@ -1248,8 +1248,8 @@ zfs_file_pwrite(zfs_file_t *fp, const void *buf,
|
|||||||
* system calls so that the process can be killed in between.
|
* system calls so that the process can be killed in between.
|
||||||
* This is used by ztest to simulate realistic failure modes.
|
* This is used by ztest to simulate realistic failure modes.
|
||||||
*/
|
*/
|
||||||
sectors = count >> SPA_MINBLOCKSHIFT;
|
sectors = count >> ashift;
|
||||||
split = (sectors > 0 ? rand() % sectors : 0) << SPA_MINBLOCKSHIFT;
|
split = (sectors > 0 ? rand() % sectors : 0) << ashift;
|
||||||
rc = pwrite64(fp->f_fd, buf, split, pos);
|
rc = pwrite64(fp->f_fd, buf, split, pos);
|
||||||
if (rc != -1) {
|
if (rc != -1) {
|
||||||
done = rc;
|
done = rc;
|
||||||
|
|||||||
@ -161,6 +161,8 @@ Search for
|
|||||||
members in
|
members in
|
||||||
.Ar dir .
|
.Ar dir .
|
||||||
Can be specified more than once.
|
Can be specified more than once.
|
||||||
|
.It Fl o Ar var Ns = Ns Ar value
|
||||||
|
Set the given tunable to the provided value.
|
||||||
.El
|
.El
|
||||||
.
|
.
|
||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
|
|||||||
@ -164,8 +164,9 @@ zfs_file_write(zfs_file_t *fp, const void *buf, size_t count, ssize_t *resid)
|
|||||||
|
|
||||||
int
|
int
|
||||||
zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t count, loff_t off,
|
zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t count, loff_t off,
|
||||||
ssize_t *resid)
|
uint8_t ashift, ssize_t *resid)
|
||||||
{
|
{
|
||||||
|
(void) ashift;
|
||||||
return (zfs_file_write_impl(fp, buf, count, &off, resid));
|
return (zfs_file_write_impl(fp, buf, count, &off, resid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -115,8 +115,9 @@ zfs_file_write(zfs_file_t *fp, const void *buf, size_t count, ssize_t *resid)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t count, loff_t off,
|
zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t count, loff_t off,
|
||||||
ssize_t *resid)
|
uint8_t ashift, ssize_t *resid)
|
||||||
{
|
{
|
||||||
|
(void) ashift;
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
|
|
||||||
rc = kernel_write(fp, buf, count, &off);
|
rc = kernel_write(fp, buf, count, &off);
|
||||||
|
|||||||
@ -228,7 +228,8 @@ vdev_file_io_strategy(void *arg)
|
|||||||
abd_return_buf_copy(zio->io_abd, buf, size);
|
abd_return_buf_copy(zio->io_abd, buf, size);
|
||||||
} else {
|
} else {
|
||||||
buf = abd_borrow_buf_copy(zio->io_abd, zio->io_size);
|
buf = abd_borrow_buf_copy(zio->io_abd, zio->io_size);
|
||||||
err = zfs_file_pwrite(vf->vf_file, buf, size, off, &resid);
|
err = zfs_file_pwrite(vf->vf_file, buf, size, off,
|
||||||
|
vd->vdev_ashift, &resid);
|
||||||
abd_return_buf(zio->io_abd, buf, size);
|
abd_return_buf(zio->io_abd, buf, size);
|
||||||
}
|
}
|
||||||
zio->io_error = err;
|
zio->io_error = err;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user