diff --git a/include/spdk/nvme_spec.h b/include/spdk/nvme_spec.h index 8f1edf19142..307cecc0556 100644 --- a/include/spdk/nvme_spec.h +++ b/include/spdk/nvme_spec.h @@ -4355,6 +4355,9 @@ SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_ns_streams_status) == 131072, "Incorr /** When set, reading of unwritten or deallocated block of a thin-provisioned device will fail * with SPDK_NVME_SC_DEALLOCATED_OR_UNWRITTEN_BLOCK */ #define SPDK_NVME_IO_FLAGS_UNWRITTEN_READ_FAIL (4U << 20) +/** When set, check for allocated blocks from current blob, rather checking from + * complete blob chain while doing read */ +#define SPDK_NVME_IO_FLAG_CURRENT_UNWRITTEN_READ_FAIL (4U << 19) /** Zone append specific, determines the contents of the reference tag written to the media */ #define SPDK_NVME_IO_FLAGS_ZONE_APPEND_PIREMAP (1U << 25) /** Enable protection information checking of the Logical Block Reference Tag field */ diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 3b9b6dd080f..f045edb7916 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -3322,6 +3322,10 @@ blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_chan if (read) { spdk_bs_sequence_t *seq; + if (!is_allocated && (ext_io_flags & SPDK_NVME_IO_FLAG_CURRENT_UNWRITTEN_READ_FAIL)) { + cb_fn(cb_arg, -ETXTBSY); + return; + } if (!is_allocated && (ext_io_flags & SPDK_NVME_IO_FLAGS_UNWRITTEN_READ_FAIL)) { is_allocated = blob_ancestor_calc_lba_and_lba_count(blob, offset, length, &lba, &lba_count); if (!is_allocated) {