block: Use common write req handling in truncate
commitcd47d792d7a27a57f4b621e2ff1ed8f4e83de1e9
authorFam Zheng <famz@redhat.com>
Tue, 10 Jul 2018 06:31:24 +0000 (10 14:31 +0800)
committerKevin Wolf <kwolf@redhat.com>
Tue, 10 Jul 2018 14:46:22 +0000 (10 16:46 +0200)
tree14b32cab5683d54a74d576768cc0c1cce8fb90a7
parent5416a11eb55d46c376dde97c429b89e9b4e1a94f
block: Use common write req handling in truncate

Truncation is the last to convert from open coded req handling to
reusing helpers. This time the permission check in prepare has to adapt
to the new caller: it checks a different permission bit, and doesn't
trigger the before write notifier.

Also, truncation should always trigger a bs->total_sectors update and in
turn call parent resize_cb. Update the condition in finish helper, too.

It's intended to do a duplicated bs->read_only check before calling
bdrv_co_write_req_prepare() so that we can be more informative with the
error message, as bdrv_co_write_req_prepare() doesn't have Error
parameter.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/io.c