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