iscsi.c (7e0019a7196ebed177c95824875cf852e1a6f667) iscsi.c (e24d813b29d3a478a9309078487efc8ce8599f22)
1/*
2 * QEMU Block driver for iSCSI images
3 *
4 * Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com>
5 * Copyright (c) 2012-2017 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

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

1872 iscsilun->type = inq->periperal_device_type;
1873 scsi_free_scsi_task(task);
1874 task = NULL;
1875
1876 iscsi_modesense_sync(iscsilun);
1877 if (iscsilun->dpofua) {
1878 bs->supported_write_flags = BDRV_REQ_FUA;
1879 }
1/*
2 * QEMU Block driver for iSCSI images
3 *
4 * Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com>
5 * Copyright (c) 2012-2017 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

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

1872 iscsilun->type = inq->periperal_device_type;
1873 scsi_free_scsi_task(task);
1874 task = NULL;
1875
1876 iscsi_modesense_sync(iscsilun);
1877 if (iscsilun->dpofua) {
1878 bs->supported_write_flags = BDRV_REQ_FUA;
1879 }
1880 bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
1881
1882 /* Check the write protect flag of the LUN if we want to write */
1883 if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
1884 iscsilun->write_protected) {
1885 error_setg(errp, "Cannot open a write protected LUN as read-write");
1886 ret = -EACCES;
1887 goto out;
1888 }

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

1956 iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {
1957 iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran *
1958 iscsilun->block_size) >> BDRV_SECTOR_BITS;
1959 if (iscsilun->lbprz) {
1960 ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
1961 }
1962 }
1963
1880
1881 /* Check the write protect flag of the LUN if we want to write */
1882 if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
1883 iscsilun->write_protected) {
1884 error_setg(errp, "Cannot open a write protected LUN as read-write");
1885 ret = -EACCES;
1886 goto out;
1887 }

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

1955 iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {
1956 iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran *
1957 iscsilun->block_size) >> BDRV_SECTOR_BITS;
1958 if (iscsilun->lbprz) {
1959 ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
1960 }
1961 }
1962
1963 if (iscsilun->lbprz && iscsilun->lbp.lbpws) {
1964 bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
1965 }
1966
1964out:
1965 qemu_opts_del(opts);
1966 g_free(initiator_name);
1967 if (task != NULL) {
1968 scsi_free_scsi_task(task);
1969 }
1970
1971 if (ret) {

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

2155 bdrv_unref(bs);
2156 return ret;
2157}
2158
2159static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
2160{
2161 IscsiLun *iscsilun = bs->opaque;
2162 bdi->unallocated_blocks_are_zero = iscsilun->lbprz;
1967out:
1968 qemu_opts_del(opts);
1969 g_free(initiator_name);
1970 if (task != NULL) {
1971 scsi_free_scsi_task(task);
1972 }
1973
1974 if (ret) {

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

2158 bdrv_unref(bs);
2159 return ret;
2160}
2161
2162static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
2163{
2164 IscsiLun *iscsilun = bs->opaque;
2165 bdi->unallocated_blocks_are_zero = iscsilun->lbprz;
2163 bdi->can_write_zeroes_with_unmap = iscsilun->lbprz && iscsilun->lbp.lbpws;
2164 bdi->cluster_size = iscsilun->cluster_sectors * BDRV_SECTOR_SIZE;
2165 return 0;
2166}
2167
2168static void iscsi_invalidate_cache(BlockDriverState *bs,
2169 Error **errp)
2170{
2171 IscsiLun *iscsilun = bs->opaque;

--- 95 unchanged lines hidden ---
2166 bdi->cluster_size = iscsilun->cluster_sectors * BDRV_SECTOR_SIZE;
2167 return 0;
2168}
2169
2170static void iscsi_invalidate_cache(BlockDriverState *bs,
2171 Error **errp)
2172{
2173 IscsiLun *iscsilun = bs->opaque;

--- 95 unchanged lines hidden ---