1 /* 2 * QEMU System Emulator block write threshold notification 3 * 4 * Copyright Red Hat, Inc. 2014 5 * 6 * Authors: 7 * Francesco Romani <fromani@redhat.com> 8 * 9 * This work is licensed under the terms of the GNU LGPL, version 2 or later. 10 * See the COPYING.LIB file in the top-level directory. 11 */ 12 #ifndef BLOCK_WRITE_THRESHOLD_H 13 #define BLOCK_WRITE_THRESHOLD_H 14 15 16 /* 17 * bdrv_write_threshold_set: 18 * 19 * Set the write threshold for block devices, in bytes. 20 * Notify when a write exceeds the threshold, meaning the device 21 * is becoming full, so it can be transparently resized. 22 * To be used with thin-provisioned block devices. 23 * 24 * Use threshold_bytes == 0 to disable. 25 */ 26 void bdrv_write_threshold_set(BlockDriverState *bs, uint64_t threshold_bytes); 27 28 /* 29 * bdrv_write_threshold_get 30 * 31 * Get the configured write threshold, in bytes. 32 * Zero means no threshold configured. 33 */ 34 uint64_t bdrv_write_threshold_get(const BlockDriverState *bs); 35 36 /* 37 * bdrv_write_threshold_is_set 38 * 39 * Tell if a write threshold is set for a given BDS. 40 */ 41 bool bdrv_write_threshold_is_set(const BlockDriverState *bs); 42 43 /* 44 * bdrv_write_threshold_exceeded 45 * 46 * Return the extent of a write request that exceeded the threshold, 47 * or zero if the request is below the threshold. 48 * Return zero also if the threshold was not set. 49 * 50 * NOTE: here we assume the following holds for each request this code 51 * deals with: 52 * 53 * assert((req->offset + req->bytes) <= UINT64_MAX) 54 * 55 * Please not there is *not* an actual C assert(). 56 */ 57 uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs, 58 const BdrvTrackedRequest *req); 59 60 #endif 61