[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/18] block: use bdrv_is_sg() helper instead of raw bs->sg readin
From: |
Kevin Wolf |
Subject: |
[PULL 06/18] block: use bdrv_is_sg() helper instead of raw bs->sg reading |
Date: |
Fri, 30 Sep 2022 18:52:10 +0200 |
From: "Denis V. Lunev" <den@openvz.org>
I believe that if the helper exists, it must be used always for reading
of the value. It breaks expectations in the other case.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Peter Lieven <pl@kamp.de>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Message-Id: <20220817083736.40981-2-den@openvz.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/file-posix.c | 2 +-
block/iscsi.c | 2 +-
block/raw-format.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 48cd096624..256de1f456 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1295,7 +1295,7 @@ static void raw_refresh_limits(BlockDriverState *bs,
Error **errp)
}
#endif
- if (bs->sg || S_ISBLK(st.st_mode)) {
+ if (bdrv_is_sg(bs) || S_ISBLK(st.st_mode)) {
int ret = hdev_get_max_hw_transfer(s->fd, &st);
if (ret > 0 && ret <= BDRV_REQUEST_MAX_BYTES) {
diff --git a/block/iscsi.c b/block/iscsi.c
index d707d0b354..612de127e5 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -2065,7 +2065,7 @@ static void iscsi_refresh_limits(BlockDriverState *bs,
Error **errp)
uint64_t max_xfer_len = iscsilun->use_16_for_rw ? 0xffffffff : 0xffff;
unsigned int block_size = MAX(BDRV_SECTOR_SIZE, iscsilun->block_size);
- assert(iscsilun->block_size >= BDRV_SECTOR_SIZE || bs->sg);
+ assert(iscsilun->block_size >= BDRV_SECTOR_SIZE || bdrv_is_sg(bs));
bs->bl.request_alignment = block_size;
diff --git a/block/raw-format.c b/block/raw-format.c
index 69fd650eaf..c7278e348e 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -463,7 +463,7 @@ static int raw_open(BlockDriverState *bs, QDict *options,
int flags,
return -EINVAL;
}
- bs->sg = bs->file->bs->sg;
+ bs->sg = bdrv_is_sg(bs->file->bs);
bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
(BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
@@ -489,7 +489,7 @@ static int raw_open(BlockDriverState *bs, QDict *options,
int flags,
return ret;
}
- if (bs->sg && (s->offset || s->has_size)) {
+ if (bdrv_is_sg(bs) && (s->offset || s->has_size)) {
error_setg(errp, "Cannot use offset/size with SCSI generic devices");
return -EINVAL;
}
--
2.37.3
- [PULL 00/18] Block layer patches, Kevin Wolf, 2022/09/30
- [PULL 02/18] block/qcow2-bitmap: Add missing cast to silent GCC error, Kevin Wolf, 2022/09/30
- [PULL 01/18] qcow2: fix memory leak in qcow2_read_extensions, Kevin Wolf, 2022/09/30
- [PULL 06/18] block: use bdrv_is_sg() helper instead of raw bs->sg reading,
Kevin Wolf <=
- [PULL 04/18] block: pass OnOffAuto instead of bool to block_acct_setup(), Kevin Wolf, 2022/09/30
- [PULL 03/18] qemu-img: Wean documentation and help output off '?' for help, Kevin Wolf, 2022/09/30
- [PULL 07/18] block: make serializing requests functions 'void', Kevin Wolf, 2022/09/30
- [PULL 05/18] block: add missed block_acct_setup with new block device init procedure, Kevin Wolf, 2022/09/30
- [PULL 08/18] gluster: stop using .bdrv_needs_filename, Kevin Wolf, 2022/09/30
- [PULL 14/18] piix_ide_reset: Use pci_set_* functions instead of direct access, Kevin Wolf, 2022/09/30
- [PULL 09/18] block/qcow2: Keep auto_backing_file if possible, Kevin Wolf, 2022/09/30
- [PULL 12/18] block: move bdrv_qiov_is_aligned to file-posix, Kevin Wolf, 2022/09/30
- [PULL 10/18] block/qed: Keep auto_backing_file if possible, Kevin Wolf, 2022/09/30
- [PULL 16/18] hw/ide/core: Clear LBA and drive bits for EXECUTE DEVICE DIAGNOSTIC, Kevin Wolf, 2022/09/30