Sfoglia il codice sorgente

block: Use BDRV_REQUEST_MAX_BYTES instead of BDRV_REQUEST_MAX_SECTORS

There are a few places in which we turn a number of bytes into sectors
in order to compare the result against BDRV_REQUEST_MAX_SECTORS
instead of using BDRV_REQUEST_MAX_BYTES directly.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
tags/v4.1.0-rc0
Alberto Garcia 2 mesi fa
parent
commit
41ae31e3d7
2 ha cambiato i file con 6 aggiunte e 7 eliminazioni
  1. 3
    3
      block/io.c
  2. 3
    4
      qemu-io-cmds.c

+ 3
- 3
block/io.c Vedi File

@@ -769,7 +769,7 @@ static bool coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
769 769
 static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
770 770
                                    size_t size)
771 771
 {
772
-    if (size > BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS) {
772
+    if (size > BDRV_REQUEST_MAX_BYTES) {
773 773
         return -EIO;
774 774
     }
775 775
 
@@ -1017,7 +1017,7 @@ static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs,
1017 1017
 
1018 1018
     assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
1019 1019
     assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
1020
-    assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
1020
+    assert(bytes <= BDRV_REQUEST_MAX_BYTES);
1021 1021
     assert(drv->bdrv_co_readv);
1022 1022
 
1023 1023
     return drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov);
@@ -1070,7 +1070,7 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
1070 1070
 
1071 1071
     assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
1072 1072
     assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
1073
-    assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
1073
+    assert(bytes <= BDRV_REQUEST_MAX_BYTES);
1074 1074
 
1075 1075
     assert(drv->bdrv_co_writev);
1076 1076
     ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov,

+ 3
- 4
qemu-io-cmds.c Vedi File

@@ -538,7 +538,7 @@ static int do_write_compressed(BlockBackend *blk, char *buf, int64_t offset,
538 538
 {
539 539
     int ret;
540 540
 
541
-    if (bytes >> 9 > BDRV_REQUEST_MAX_SECTORS) {
541
+    if (bytes > BDRV_REQUEST_MAX_BYTES) {
542 542
         return -ERANGE;
543 543
     }
544 544
 
@@ -1781,10 +1781,9 @@ static int discard_f(BlockBackend *blk, int argc, char **argv)
1781 1781
     if (bytes < 0) {
1782 1782
         print_cvtnum_err(bytes, argv[optind]);
1783 1783
         return bytes;
1784
-    } else if (bytes >> BDRV_SECTOR_BITS > BDRV_REQUEST_MAX_SECTORS) {
1784
+    } else if (bytes > BDRV_REQUEST_MAX_BYTES) {
1785 1785
         printf("length cannot exceed %"PRIu64", given %s\n",
1786
-               (uint64_t)BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS,
1787
-               argv[optind]);
1786
+               (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
1788 1787
         return -EINVAL;
1789 1788
     }
1790 1789
 

Loading…
Annulla
Salva