Skip to content

Commit d151432

Browse files
authored
ZIL: Make allocations more flexible
When ZIL allocates space for new LWBs without knowing how much it will require, it can use new metaslab_alloc_range() function to allocate slightly more or less than it predicted. It allows to improve space efficiency by allocating bigger LWBs on RAIDZ/dRAID instead of padding and possibly packing more ZIL records there. It may also allow to reduce ganging in some cases by allowing to allocate smaller LWBs when we are not sure we'll need bigger. On the opposite side, when we allocate space for already closed LWBs, when we precisely know how much space we need, we may just allocate what we need instead of relying on writing less than allocated, that does not work for RAIDZ. Space for LWBs in open state (still being filled) is allocated same as before. Reviewed-by: Rob Norris <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Closes #17613
1 parent 8d35a02 commit d151432

File tree

4 files changed

+180
-105
lines changed

4 files changed

+180
-105
lines changed

include/sys/zil_impl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ extern "C" {
4141
*
4242
* An lwb will start out in the "new" state, and transition to the "opened"
4343
* state via a call to zil_lwb_write_open() on first itx assignment. When
44-
* transitioning from "new" to "opened" the zilog's "zl_issuer_lock" must be
45-
* held.
44+
* transitioning from "new" to "opened" the zilog's "zl_issuer_lock" and
45+
* LWB's "lwb_lock" must be held.
4646
*
4747
* After the lwb is "opened", it can be assigned number of itxs and transition
4848
* into the "closed" state via zil_lwb_write_close() when full or on timeout.
@@ -115,6 +115,7 @@ typedef struct lwb {
115115
int lwb_nused; /* # used bytes in buffer */
116116
int lwb_nfilled; /* # filled bytes in buffer */
117117
int lwb_sz; /* size of block and buffer */
118+
int lwb_min_sz; /* min size for range allocation */
118119
lwb_state_t lwb_state; /* the state of this lwb */
119120
char *lwb_buf; /* log write buffer */
120121
zio_t *lwb_child_zio; /* parent zio for children */
@@ -129,7 +130,7 @@ typedef struct lwb {
129130
list_t lwb_itxs; /* list of itx's */
130131
list_t lwb_waiters; /* list of zil_commit_waiter's */
131132
avl_tree_t lwb_vdev_tree; /* vdevs to flush after lwb write */
132-
kmutex_t lwb_vdev_lock; /* protects lwb_vdev_tree */
133+
kmutex_t lwb_lock; /* protects lwb_vdev_tree and size */
133134
} lwb_t;
134135

135136
/*

include/sys/zio.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ extern zio_t *zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg,
622622
const blkptr_t *bp, zio_flag_t flags);
623623

624624
extern int zio_alloc_zil(spa_t *spa, objset_t *os, uint64_t txg,
625-
blkptr_t *new_bp, uint64_t size, boolean_t *slog);
625+
blkptr_t *new_bp, uint64_t min_size, uint64_t max_size, boolean_t *slog,
626+
boolean_t allow_larger);
626627
extern void zio_flush(zio_t *zio, vdev_t *vd);
627628
extern void zio_shrink(zio_t *zio, uint64_t size);
628629

0 commit comments

Comments
 (0)