mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-01-15 01:32:04 +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)
|
||||
{
|
||||
(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"
|
||||
"\n");
|
||||
|
||||
@ -1169,7 +1170,7 @@ main(int argc, char **argv)
|
||||
dprintf_setup(&argc, argv);
|
||||
zfs_prop_init();
|
||||
|
||||
while ((c = getopt(argc, argv, "+c:d:")) != -1) {
|
||||
while ((c = getopt(argc, argv, "+c:d:o:")) != -1) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
g_importargs.cachefile = optarg;
|
||||
@ -1178,6 +1179,10 @@ main(int argc, char **argv)
|
||||
assert(g_importargs.paths < MAX_NUM_PATHS);
|
||||
g_importargs.path[g_importargs.paths++] = optarg;
|
||||
break;
|
||||
case 'o':
|
||||
if (handle_tunable_option(optarg, B_FALSE) != 0)
|
||||
exit(1);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
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_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_pread(zfs_file_t *fp, void *buf, size_t len, loff_t off,
|
||||
ssize_t *resid);
|
||||
|
||||
@ -1238,7 +1238,7 @@ zfs_file_write(zfs_file_t *fp, const void *buf, size_t count, ssize_t *resid)
|
||||
*/
|
||||
int
|
||||
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;
|
||||
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.
|
||||
* This is used by ztest to simulate realistic failure modes.
|
||||
*/
|
||||
sectors = count >> SPA_MINBLOCKSHIFT;
|
||||
split = (sectors > 0 ? rand() % sectors : 0) << SPA_MINBLOCKSHIFT;
|
||||
sectors = count >> ashift;
|
||||
split = (sectors > 0 ? rand() % sectors : 0) << ashift;
|
||||
rc = pwrite64(fp->f_fd, buf, split, pos);
|
||||
if (rc != -1) {
|
||||
done = rc;
|
||||
|
||||
@ -161,6 +161,8 @@ Search for
|
||||
members in
|
||||
.Ar dir .
|
||||
Can be specified more than once.
|
||||
.It Fl o Ar var Ns = Ns Ar value
|
||||
Set the given tunable to the provided value.
|
||||
.El
|
||||
.
|
||||
.Sh EXAMPLES
|
||||
|
||||
@ -164,8 +164,9 @@ zfs_file_write(zfs_file_t *fp, const void *buf, size_t count, ssize_t *resid)
|
||||
|
||||
int
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@ -115,8 +115,9 @@ zfs_file_write(zfs_file_t *fp, const void *buf, size_t count, ssize_t *resid)
|
||||
*/
|
||||
int
|
||||
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;
|
||||
|
||||
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);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
zio->io_error = err;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user