Skip to content

Commit ddf4098

Browse files
davidhildenbrandmstsirkin
authored andcommitted
virtio-mem: convert most offline_and_remove_memory() errors to -EBUSY
Just like we do with alloc_contig_range(), let's convert all unknown errors to -EBUSY, but WARN so we can look into the issue. For example, offline_pages() could fail with -EINTR, which would be unexpected in our case. Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20230713145551.2824980-3-david@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent f504e15 commit ddf4098

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/virtio/virtio_mem.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,15 @@ static int virtio_mem_offline_and_remove_memory(struct virtio_mem *vm,
741741
* immediately instead of waiting.
742742
*/
743743
virtio_mem_retry(vm);
744-
} else {
745-
dev_dbg(&vm->vdev->dev,
746-
"offlining and removing memory failed: %d\n", rc);
744+
return 0;
747745
}
748-
return rc;
746+
dev_dbg(&vm->vdev->dev, "offlining and removing memory failed: %d\n", rc);
747+
/*
748+
* We don't really expect this to fail, because we fake-offlined all
749+
* memory already. But it could fail in corner cases.
750+
*/
751+
WARN_ON_ONCE(rc != -ENOMEM && rc != -EBUSY);
752+
return rc == -ENOMEM ? -ENOMEM : -EBUSY;
749753
}
750754

751755
/*

0 commit comments

Comments
 (0)