diff options
author | Maxim Levitsky <mlevitsk@redhat.com> | 2020-12-17 19:09:03 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2021-02-15 15:10:14 +0100 |
commit | a890f08e586fd81946c51dae6a878d64486b1364 (patch) | |
tree | 8a35618d720e9e07f7f063ef2431a3898a999cac /block | |
parent | dcb6699512b6235eac383fc84e8e27302e08d7e3 (diff) |
block: add bdrv_co_delete_file_noerr
This function wraps bdrv_co_delete_file for the common case of removing a file,
which was just created by format driver, on an error condition.
It hides the -ENOTSUPP error, and reports all other errors otherwise.
Use it in luks driver
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-Id: <20201217170904.946013-3-mlevitsk@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/crypto.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/block/crypto.c b/block/crypto.c index b3a5275132..1d30fde38e 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -725,19 +725,8 @@ fail: * If an error occurred, delete 'filename'. Even if the file existed * beforehand, it has been truncated and corrupted in the process. */ - if (ret && bs) { - Error *local_delete_err = NULL; - int r_del = bdrv_co_delete_file(bs, &local_delete_err); - /* - * ENOTSUP will happen if the block driver doesn't support - * the 'bdrv_co_delete_file' interface. This is a predictable - * scenario and shouldn't be reported back to the user. - */ - if ((r_del < 0) && (r_del != -ENOTSUP)) { - error_report_err(local_delete_err); - } else { - error_free(local_delete_err); - } + if (ret) { + bdrv_co_delete_file_noerr(bs); } bdrv_unref(bs); |