mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-27 04:32:16 +03:00
Allow and prefer special vdevs as ZIL
Before this change ZIL blocks were allocated only from normal or SLOG vdevs. In typical situation when special vdevs are SSDs and normal are HDDs it could cause weird inversions when data blocks are written to SSDs, but ZIL referencing them to HDDs. This change assumes that special vdevs typically have much better (or at least not worse) latency than normal, and so in absence of SLOGs should store ZIL blocks. It means similar to normal vdevs introduction of special embedded log allocation class and updating the allocation fallback order to: SLOG -> special embedded log -> special -> normal embedded log -> normal. The code tries to guess whether data block is going to be written to normal or special vdev (it can not be done precisely before compression) and prefer indirect writes for blocks written to a special vdev to avoid double-write. For blocks that are going to be written to normal vdev, special vdev by default plays as SLOG, reducing write latency by the cost of higher special vdev wear, but it is tunable via module parameter. This should allow HDD pools with decent SSD as special vdev to work under synchronous workloads without requiring additional SLOG SSD, impractical in many scenarios. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rob Norris <rob.norris@klarasystems.com> Reviewed-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #17505
This commit is contained in:
@@ -2095,6 +2095,19 @@ zil_max_waste_space(zilog_t *zilog)
|
||||
*/
|
||||
static uint_t zil_maxcopied = 7680;
|
||||
|
||||
/*
|
||||
* Largest write size to store the data directly into ZIL.
|
||||
*/
|
||||
uint_t zfs_immediate_write_sz = 32768;
|
||||
|
||||
/*
|
||||
* When enabled and blocks go to normal vdev, treat special vdevs as SLOG,
|
||||
* writing data to ZIL (WR_COPIED/WR_NEED_COPY). Disabling this forces the
|
||||
* indirect writes (WR_INDIRECT) to preserve special vdev throughput and
|
||||
* endurance, likely at the cost of normal vdev latency.
|
||||
*/
|
||||
int zil_special_is_slog = 1;
|
||||
|
||||
uint64_t
|
||||
zil_max_copied_data(zilog_t *zilog)
|
||||
{
|
||||
@@ -2102,6 +2115,46 @@ zil_max_copied_data(zilog_t *zilog)
|
||||
return (MIN(max_data, zil_maxcopied));
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the appropriate write state for ZIL transactions based on
|
||||
* pool configuration, data placement, write size, and logbias settings.
|
||||
*/
|
||||
itx_wr_state_t
|
||||
zil_write_state(zilog_t *zilog, uint64_t size, uint32_t blocksize,
|
||||
boolean_t o_direct, boolean_t commit)
|
||||
{
|
||||
if (zilog->zl_logbias == ZFS_LOGBIAS_THROUGHPUT || o_direct)
|
||||
return (WR_INDIRECT);
|
||||
|
||||
/*
|
||||
* Don't use indirect for too small writes to reduce overhead.
|
||||
* Don't use indirect if written less than a half of a block if
|
||||
* we are going to commit it immediately, since next write might
|
||||
* rewrite the same block again, causing inflation. If commit
|
||||
* is not planned, then next writes might coalesce, and so the
|
||||
* indirect may be perfect.
|
||||
*/
|
||||
boolean_t indirect = (size >= zfs_immediate_write_sz &&
|
||||
(size >= blocksize / 2 || !commit));
|
||||
|
||||
if (spa_has_slogs(zilog->zl_spa)) {
|
||||
/* Dedicated slogs: never use indirect */
|
||||
indirect = B_FALSE;
|
||||
} else if (spa_has_special(zilog->zl_spa)) {
|
||||
/* Special vdevs: only when beneficial */
|
||||
boolean_t on_special = (blocksize <=
|
||||
zilog->zl_os->os_zpl_special_smallblock);
|
||||
indirect &= (on_special || !zil_special_is_slog);
|
||||
}
|
||||
|
||||
if (indirect)
|
||||
return (WR_INDIRECT);
|
||||
else if (commit)
|
||||
return (WR_COPIED);
|
||||
else
|
||||
return (WR_NEED_COPY);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
zil_itx_record_size(itx_t *itx)
|
||||
{
|
||||
@@ -4418,3 +4471,9 @@ ZFS_MODULE_PARAM(zfs_zil, zil_, maxblocksize, UINT, ZMOD_RW,
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_zil, zil_, maxcopied, UINT, ZMOD_RW,
|
||||
"Limit in bytes WR_COPIED size");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs, zfs_, immediate_write_sz, UINT, ZMOD_RW,
|
||||
"Largest write size to store data into ZIL");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_zil, zil_, special_is_slog, INT, ZMOD_RW,
|
||||
"Treat special vdevs as SLOG");
|
||||
|
||||
Reference in New Issue
Block a user