iscsi.c (3c9331c47f22224118d5019b0af8eac704824d8d) iscsi.c (67a0fd2a9bca204d2b39f910a97c7137636a0715)
1/*
2 * QEMU Block driver for iSCSI images
3 *
4 * Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com>
5 * Copyright (c) 2012-2015 Peter Lieven <pl@kamp.de>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal

--- 518 unchanged lines hidden (view full) ---

527 }
528 size = DIV_ROUND_UP(sector_num + nb_sectors, iscsilun->cluster_sectors);
529 return !(find_next_bit(iscsilun->allocationmap, size,
530 sector_num / iscsilun->cluster_sectors) == size);
531}
532
533static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs,
534 int64_t sector_num,
1/*
2 * QEMU Block driver for iSCSI images
3 *
4 * Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com>
5 * Copyright (c) 2012-2015 Peter Lieven <pl@kamp.de>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal

--- 518 unchanged lines hidden (view full) ---

527 }
528 size = DIV_ROUND_UP(sector_num + nb_sectors, iscsilun->cluster_sectors);
529 return !(find_next_bit(iscsilun->allocationmap, size,
530 sector_num / iscsilun->cluster_sectors) == size);
531}
532
533static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs,
534 int64_t sector_num,
535 int nb_sectors, int *pnum)
535 int nb_sectors, int *pnum,
536 BlockDriverState **file)
536{
537 IscsiLun *iscsilun = bs->opaque;
538 struct scsi_get_lba_status *lbas = NULL;
539 struct scsi_lba_status_descriptor *lbasd = NULL;
540 struct IscsiTask iTask;
541 int64_t ret;
542
543 iscsi_co_init_iscsitask(iscsilun, &iTask);

--- 101 unchanged lines hidden (view full) ---

645 "of %d sectors", nb_sectors, bs->bl.max_transfer_length);
646 return -EINVAL;
647 }
648
649 if (iscsilun->lbprz && nb_sectors >= ISCSI_CHECKALLOC_THRES &&
650 !iscsi_allocationmap_is_allocated(iscsilun, sector_num, nb_sectors)) {
651 int64_t ret;
652 int pnum;
537{
538 IscsiLun *iscsilun = bs->opaque;
539 struct scsi_get_lba_status *lbas = NULL;
540 struct scsi_lba_status_descriptor *lbasd = NULL;
541 struct IscsiTask iTask;
542 int64_t ret;
543
544 iscsi_co_init_iscsitask(iscsilun, &iTask);

--- 101 unchanged lines hidden (view full) ---

646 "of %d sectors", nb_sectors, bs->bl.max_transfer_length);
647 return -EINVAL;
648 }
649
650 if (iscsilun->lbprz && nb_sectors >= ISCSI_CHECKALLOC_THRES &&
651 !iscsi_allocationmap_is_allocated(iscsilun, sector_num, nb_sectors)) {
652 int64_t ret;
653 int pnum;
653 ret = iscsi_co_get_block_status(bs, sector_num, INT_MAX, &pnum);
654 BlockDriverState *file;
655 ret = iscsi_co_get_block_status(bs, sector_num, INT_MAX, &pnum, &file);
654 if (ret < 0) {
655 return ret;
656 }
657 if (ret & BDRV_BLOCK_ZERO && pnum >= nb_sectors) {
658 qemu_iovec_memset(iov, 0, 0x00, iov->size);
659 return 0;
660 }
661 }

--- 1218 unchanged lines hidden ---
656 if (ret < 0) {
657 return ret;
658 }
659 if (ret & BDRV_BLOCK_ZERO && pnum >= nb_sectors) {
660 qemu_iovec_memset(iov, 0, 0x00, iov->size);
661 return 0;
662 }
663 }

--- 1218 unchanged lines hidden ---