Lines Matching refs:trim

65  * Set sysctl vfs.generic.jnl.kdebug.trim=1 to enable KERNEL_DEBUG_CONSTANT
66 * logging of trim-related calls within the journal. (They're
75 SYSCTL_INT(_vfs_generic_jnl_kdebug, OID_AUTO, trim, CTLFLAG_RW|CTLFLAG_LOCKED, &jnl_kdebug, 0, "Enable kdebug logging for journal TRIM");
127 // By default, we grow the list of extents to trim by one page at a time.
2985 ; trim - The trim list to be resized.
2991 ; The allocated_count and extents fields of tr->trim are updated
2996 trim_realloc(struct jnl_trim_list *trim)
3002 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_REALLOC | DBG_FUNC_START, trim, 0, trim->allocated_count, trim->extent_count, 0);
3004 new_allocated_count = trim->allocated_count + JOURNAL_DEFAULT_TRIM_EXTENTS;
3012 trim->extent_count = 0;
3014 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_REALLOC | DBG_FUNC_END, ENOMEM, 0, trim->allocated_count, 0, 0);
3019 if (trim->extents != NULL) {
3021 trim->extents,
3022 trim->allocated_count * sizeof(dk_extent_t));
3023 kfree(trim->extents,
3024 trim->allocated_count * sizeof(dk_extent_t));
3027 trim->allocated_count = new_allocated_count;
3028 trim->extents = new_extents;
3031 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_REALLOC | DBG_FUNC_END, 0, 0, new_allocated_count, trim->extent_count, 0);
3045 ; trim - The trim list to be searched.
3054 trim_search_extent(struct jnl_trim_list *trim, uint64_t offset, uint64_t length)
3058 uint32_t upper = trim->extent_count; /* Highest index to search + 1 */
3065 if (trim->extents[middle].offset >= end)
3067 else if (trim->extents[middle].offset + trim->extents[middle].length <= offset)
3086 ; SSDs can support trim/unmap and avoid having to recopy those
3114 /* TODO: Is it OK to manipulate the trim list even if JOURNAL_INVALID is set? I think so... */
3123 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_ADD | DBG_FUNC_START, jnl, offset, length, tr->trim.extent_count, 0);
3140 extent = tr->trim.extents;
3142 while (insert_index < tr->trim.extent_count && extent->offset + extent->length < offset) {
3147 while (insert_index + replace_count < tr->trim.extent_count && extent->offset <= end) {
3158 if (tr->trim.extent_count == tr->trim.allocated_count) {
3159 if (trim_realloc(&tr->trim) != 0) {
3162 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_ADD | DBG_FUNC_END, ENOMEM, 0, 0, tr->trim.extent_count, 0);
3168 if (insert_index < tr->trim.extent_count) {
3169 memmove(&tr->trim.extents[insert_index+1],
3170 &tr->trim.extents[insert_index],
3171 (tr->trim.extent_count - insert_index) * sizeof(dk_extent_t));
3173 tr->trim.extent_count++;
3176 tr->trim.extents[insert_index].offset = offset;
3177 tr->trim.extents[insert_index].length = length;
3181 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_ADD | DBG_FUNC_END, 0, 0, 0, tr->trim.extent_count, 0);
3189 if (tr->trim.extents[insert_index].offset < offset)
3190 offset = tr->trim.extents[insert_index].offset;
3191 extent = &tr->trim.extents[insert_index + replace_count - 1];
3194 tr->trim.extents[insert_index].offset = offset;
3195 tr->trim.extents[insert_index].length = end - offset;
3205 if (replace_count > 1 && (insert_index + replace_count) < tr->trim.extent_count) {
3206 memmove(&tr->trim.extents[insert_index + 1],
3207 &tr->trim.extents[insert_index + replace_count],
3208 (tr->trim.extent_count - insert_index - replace_count) * sizeof(dk_extent_t));
3210 tr->trim.extent_count -= replace_count - 1;
3213 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_ADD | DBG_FUNC_END, 0, 0, 0, tr->trim.extent_count, 0);
3225 ; Any overlapping ranges currently in the journal's trim list will
3235 ; trim - The trim list to update.
3241 trim_remove_extent(struct jnl_trim_list *trim, uint64_t offset, uint64_t length)
3255 extent = trim->extents;
3257 while (keep_before < trim->extent_count && extent->offset < offset) {
3267 while (keep_after < trim->extent_count && (extent->offset + extent->length) <= end) {
3287 if (trim->extent_count == trim->allocated_count) {
3288 if (trim_realloc(trim) != 0) {
3300 memmove(&trim->extents[keep_before],
3301 &trim->extents[keep_after],
3302 (trim->extent_count - keep_after) * sizeof(dk_extent_t));
3303 ++trim->extent_count;
3318 extent = &trim->extents[keep_before - 1];
3328 if (keep_after < trim->extent_count) {
3329 extent = &trim->extents[keep_after];
3340 if (keep_after > keep_before && keep_after < trim->extent_count) {
3341 memmove(&trim->extents[keep_before],
3342 &trim->extents[keep_after],
3343 (trim->extent_count - keep_after) * sizeof(dk_extent_t));
3345 trim->extent_count -= keep_after - keep_before;
3358 ; this transaction, or a pending trim of a transaction being
3375 /* TODO: Is it OK to manipulate the trim list even if JOURNAL_INVALID is set? I think so... */
3384 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_REMOVE | DBG_FUNC_START, jnl, offset, length, tr->trim.extent_count, 0);
3393 error = trim_remove_extent(&tr->trim, offset, length);
3398 * See if a pending trim has any extents that overlap with the
3429 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_REMOVE | DBG_FUNC_END, error, 0, 0, tr->trim.extent_count, 0);
3440 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_FLUSH | DBG_FUNC_START, jnl, tr, 0, tr->trim.extent_count, 0);
3443 if (tr->trim.extent_count > 0) {
3448 unmap.extents = tr->trim.extents;
3449 unmap.extentsCount = tr->trim.extent_count;
3451 KERNEL_DEBUG_CONSTANT(DBG_JOURNAL_TRIM_UNMAP | DBG_FUNC_START, jnl, tr, 0, tr->trim.extent_count, 0);
3456 printf("jnl: error %d from DKIOCUNMAP (extents=%lx, count=%u); disabling trim for %s\n",
3473 jnl->trim_callback(jnl->trim_callback_arg, tr->trim.extent_count, tr->trim.extents);
3479 * tell the current transaction that there is no pending trim
3488 if (jnl->async_trim == &tr->trim)
3494 * of "tr", so it is safe for us to manipulate tr->trim without
3497 if (tr->trim.extents) {
3498 kfree(tr->trim.extents, tr->trim.allocated_count * sizeof(dk_extent_t));
3499 tr->trim.allocated_count = 0;
3500 tr->trim.extent_count = 0;
3501 tr->trim.extents = NULL;
3596 // trim error, then we stop issuing trims for this
3603 && (!(jnl->flags & JOURNAL_USE_UNMAP) || (tr->trim.extent_count < jnl_trim_flush_limit))) {
3630 * Store a pointer to this transaction's trim list so that
3633 * Note: if there are no extents in the trim list, then don't
3636 * there is a trim pending).
3641 if (tr->trim.extent_count > 0)
3642 jnl->async_trim = &tr->trim;
4274 * tell the current transaction that there is no pending trim
4278 if (jnl->async_trim == &tr->trim)
4283 if (tr->trim.extents) {
4284 kfree(tr->trim.extents, tr->trim.allocated_count * sizeof(dk_extent_t));
4286 tr->trim.allocated_count = 0;
4287 tr->trim.extent_count = 0;
4288 tr->trim.extents = NULL;