mirror of
https://github.com/opnsense/src.git
synced 2026-06-06 07:12:52 -04:00
bhyve: get mediasize for character devices when resizing virtio-blk
Reviewed by: imp, allanjude, jhb Differential Revision: https://reviews.freebsd.org/D33403
This commit is contained in:
parent
89889ab470
commit
ae9ea22e14
1 changed files with 12 additions and 2 deletions
|
|
@ -667,14 +667,24 @@ blockif_resized(int fd, enum ev_type type, void *arg)
|
||||||
{
|
{
|
||||||
struct blockif_ctxt *bc;
|
struct blockif_ctxt *bc;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
off_t mediasize;
|
||||||
|
|
||||||
if (fstat(fd, &sb) != 0)
|
if (fstat(fd, &sb) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (S_ISCHR(sb.st_mode)) {
|
||||||
|
if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) < 0) {
|
||||||
|
EPRINTLN("blockif_resized: get mediasize failed: %s",
|
||||||
|
strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
mediasize = sb.st_size;
|
||||||
|
|
||||||
bc = arg;
|
bc = arg;
|
||||||
pthread_mutex_lock(&bc->bc_mtx);
|
pthread_mutex_lock(&bc->bc_mtx);
|
||||||
if (sb.st_size != bc->bc_size) {
|
if (mediasize != bc->bc_size) {
|
||||||
bc->bc_size = sb.st_size;
|
bc->bc_size = mediasize;
|
||||||
bc->bc_resize_cb(bc, bc->bc_resize_cb_arg, bc->bc_size);
|
bc->bc_resize_cb(bc, bc->bc_resize_cb_arg, bc->bc_size);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&bc->bc_mtx);
|
pthread_mutex_unlock(&bc->bc_mtx);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue