trim_map.c (240868) | trim_map.c (244187) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 14 unchanged lines hidden (view full) --- 23 * All rights reserved. 24 */ 25 26#include <sys/zfs_context.h> 27#include <sys/spa_impl.h> 28#include <sys/vdev_impl.h> 29#include <sys/trim_map.h> 30 | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 14 unchanged lines hidden (view full) --- 23 * All rights reserved. 24 */ 25 26#include <sys/zfs_context.h> 27#include <sys/spa_impl.h> 28#include <sys/vdev_impl.h> 29#include <sys/trim_map.h> 30 |
31/* 32 * Calculate the zio end, upgrading based on ashift which would be 33 * done by zio_vdev_io_start. 34 * 35 * This makes free range consolidation much more effective 36 * than it would otherwise be as well as ensuring that entire 37 * blocks are invalidated by writes. 38 */ 39#define TRIM_ZIO_END(zio) ((zio)->io_offset + \ 40 P2ROUNDUP((zio)->io_size, 1ULL << (zio)->io_vd->vdev_top->vdev_ashift)) 41 |
|
31typedef struct trim_map { 32 list_t tm_head; /* List of segments sorted by txg. */ 33 avl_tree_t tm_queued_frees; /* AVL tree of segments waiting for TRIM. */ 34 avl_tree_t tm_inflight_frees; /* AVL tree of in-flight TRIMs. */ 35 avl_tree_t tm_inflight_writes; /* AVL tree of in-flight writes. */ 36 list_t tm_pending_writes; /* Writes blocked on in-flight frees. */ 37 kmutex_t tm_lock; 38} trim_map_t; --- 226 unchanged lines hidden (view full) --- 265{ 266 vdev_t *vd = zio->io_vd; 267 trim_map_t *tm = vd->vdev_trimmap; 268 269 if (zfs_notrim || vd->vdev_notrim || tm == NULL) 270 return; 271 272 mutex_enter(&tm->tm_lock); | 42typedef struct trim_map { 43 list_t tm_head; /* List of segments sorted by txg. */ 44 avl_tree_t tm_queued_frees; /* AVL tree of segments waiting for TRIM. */ 45 avl_tree_t tm_inflight_frees; /* AVL tree of in-flight TRIMs. */ 46 avl_tree_t tm_inflight_writes; /* AVL tree of in-flight writes. */ 47 list_t tm_pending_writes; /* Writes blocked on in-flight frees. */ 48 kmutex_t tm_lock; 49} trim_map_t; --- 226 unchanged lines hidden (view full) --- 276{ 277 vdev_t *vd = zio->io_vd; 278 trim_map_t *tm = vd->vdev_trimmap; 279 280 if (zfs_notrim || vd->vdev_notrim || tm == NULL) 281 return; 282 283 mutex_enter(&tm->tm_lock); |
273 trim_map_free_locked(tm, zio->io_offset, zio->io_offset + zio->io_size, | 284 trim_map_free_locked(tm, zio->io_offset, TRIM_ZIO_END(zio), |
274 vd->vdev_spa->spa_syncing_txg); 275 mutex_exit(&tm->tm_lock); 276} 277 278boolean_t 279trim_map_write_start(zio_t *zio) 280{ 281 vdev_t *vd = zio->io_vd; 282 trim_map_t *tm = vd->vdev_trimmap; 283 trim_seg_t tsearch, *ts; 284 boolean_t left_over, right_over; 285 uint64_t start, end; 286 287 if (zfs_notrim || vd->vdev_notrim || tm == NULL) 288 return (B_TRUE); 289 290 start = zio->io_offset; | 285 vd->vdev_spa->spa_syncing_txg); 286 mutex_exit(&tm->tm_lock); 287} 288 289boolean_t 290trim_map_write_start(zio_t *zio) 291{ 292 vdev_t *vd = zio->io_vd; 293 trim_map_t *tm = vd->vdev_trimmap; 294 trim_seg_t tsearch, *ts; 295 boolean_t left_over, right_over; 296 uint64_t start, end; 297 298 if (zfs_notrim || vd->vdev_notrim || tm == NULL) 299 return (B_TRUE); 300 301 start = zio->io_offset; |
291 end = start + zio->io_size; | 302 end = TRIM_ZIO_END(zio); |
292 tsearch.ts_start = start; 293 tsearch.ts_end = end; 294 295 mutex_enter(&tm->tm_lock); 296 297 /* 298 * Checking for colliding in-flight frees. 299 */ --- 242 unchanged lines hidden --- | 303 tsearch.ts_start = start; 304 tsearch.ts_end = end; 305 306 mutex_enter(&tm->tm_lock); 307 308 /* 309 * Checking for colliding in-flight frees. 310 */ --- 242 unchanged lines hidden --- |