Fix couple panics on forced unmount of backing file.
MFC after: 1 week Sponsored by: iXsystems, Inc.
This commit is contained in:
parent
faf2d8305c
commit
b9b4269c1d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285030
@ -810,24 +810,27 @@ ctl_be_block_getattr_file(struct ctl_be_block_lun *be_lun, const char *attrname)
|
||||
{
|
||||
struct vattr vattr;
|
||||
struct statfs statfs;
|
||||
uint64_t val;
|
||||
int error;
|
||||
|
||||
val = UINT64_MAX;
|
||||
if (be_lun->vn == NULL)
|
||||
return (UINT64_MAX);
|
||||
return (val);
|
||||
vn_lock(be_lun->vn, LK_SHARED | LK_RETRY);
|
||||
if (strcmp(attrname, "blocksused") == 0) {
|
||||
error = VOP_GETATTR(be_lun->vn, &vattr, curthread->td_ucred);
|
||||
if (error != 0)
|
||||
return (UINT64_MAX);
|
||||
return (vattr.va_bytes >> be_lun->blocksize_shift);
|
||||
if (error == 0)
|
||||
val = vattr.va_bytes >> be_lun->blocksize_shift;
|
||||
}
|
||||
if (strcmp(attrname, "blocksavail") == 0) {
|
||||
if (strcmp(attrname, "blocksavail") == 0 &&
|
||||
(be_lun->vn->v_iflag & VI_DOOMED) == 0) {
|
||||
error = VFS_STATFS(be_lun->vn->v_mount, &statfs);
|
||||
if (error != 0)
|
||||
return (UINT64_MAX);
|
||||
return ((statfs.f_bavail * statfs.f_bsize) >>
|
||||
be_lun->blocksize_shift);
|
||||
if (error == 0)
|
||||
val = (statfs.f_bavail * statfs.f_bsize) >>
|
||||
be_lun->blocksize_shift;
|
||||
}
|
||||
return (UINT64_MAX);
|
||||
VOP_UNLOCK(be_lun->vn, 0);
|
||||
return (val);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2666,10 +2669,12 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
|
||||
oldsize = be_lun->size_bytes;
|
||||
if (be_lun->vn == NULL)
|
||||
error = ctl_be_block_open(softc, be_lun, req);
|
||||
else if (vn_isdisk(be_lun->vn, &error))
|
||||
error = ctl_be_block_modify_dev(be_lun, req);
|
||||
else if (be_lun->vn->v_type == VREG)
|
||||
error = ctl_be_block_modify_file(be_lun, req);
|
||||
else
|
||||
error = ctl_be_block_modify_dev(be_lun, req);
|
||||
error = EINVAL;
|
||||
|
||||
if (error == 0 && be_lun->size_bytes != oldsize) {
|
||||
be_lun->size_blocks = be_lun->size_bytes >>
|
||||
|
Loading…
Reference in New Issue
Block a user