bdev: add getter for write cache enable status

Change-Id: I93656deda8956c77e9565ee1f271795642e62ac9
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2017-05-16 12:57:33 -07:00
parent 0d56499d3a
commit 9d1e05d2f2
4 changed files with 24 additions and 1 deletions

View File

@ -249,6 +249,17 @@ uint32_t spdk_bdev_get_max_unmap_descriptors(const struct spdk_bdev *bdev);
*/
size_t spdk_bdev_get_buf_align(const struct spdk_bdev *bdev);
/**
* Query whether block device has an enabled write cache.
*
* \param bdev Block device to query.
* \return true if block device has a volatile write cache enabled.
*
* If this function returns true, written data may not be persistent until a flush command
* is issued.
*/
bool spdk_bdev_has_write_cache(const struct spdk_bdev *bdev);
struct spdk_bdev_io *spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);

View File

@ -574,6 +574,12 @@ spdk_bdev_get_buf_align(const struct spdk_bdev *bdev)
return 1;
}
bool
spdk_bdev_has_write_cache(const struct spdk_bdev *bdev)
{
return bdev->write_cache;
}
static int
spdk_bdev_io_valid(struct spdk_bdev *bdev, uint64_t offset, uint64_t nbytes)
{

View File

@ -888,7 +888,7 @@ spdk_bdev_scsi_mode_sense_page(struct spdk_bdev *bdev,
plen = 0x12 + 2;
mode_sense_page_init(cp, plen, page, subpage);
if (cp && bdev->write_cache && pc != 0x01)
if (cp && spdk_bdev_has_write_cache(bdev) && pc != 0x01)
cp[2] |= 0x4; /* WCE */
/* Read Cache Disable (RCD) = 1 */

View File

@ -115,6 +115,12 @@ spdk_bdev_get_max_unmap_descriptors(const struct spdk_bdev *bdev)
return 1;
}
bool
spdk_bdev_has_write_cache(const struct spdk_bdev *bdev)
{
return false;
}
void
spdk_scsi_lun_clear_all(struct spdk_scsi_lun *lun)
{