Deleted Added
full compact
vdev_cache.c (223622) vdev_cache.c (249195)
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

--- 8 unchanged lines hidden (view full) ---

17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
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

--- 8 unchanged lines hidden (view full) ---

17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25/*
26 * Copyright (c) 2013 by Delphix. All rights reserved.
27 */
25
26#include <sys/zfs_context.h>
27#include <sys/spa.h>
28#include <sys/vdev_impl.h>
29#include <sys/zio.h>
30#include <sys/kstat.h>
31
32/*

--- 233 unchanged lines hidden (view full) ---

266 vdev_cache_entry_t *ve, ve_search;
267 uint64_t cache_offset = P2ALIGN(zio->io_offset, VCBS);
268 uint64_t cache_phase = P2PHASE(zio->io_offset, VCBS);
269 zio_t *fio;
270
271 ASSERT(zio->io_type == ZIO_TYPE_READ);
272
273 if (zio->io_flags & ZIO_FLAG_DONT_CACHE)
28
29#include <sys/zfs_context.h>
30#include <sys/spa.h>
31#include <sys/vdev_impl.h>
32#include <sys/zio.h>
33#include <sys/kstat.h>
34
35/*

--- 233 unchanged lines hidden (view full) ---

269 vdev_cache_entry_t *ve, ve_search;
270 uint64_t cache_offset = P2ALIGN(zio->io_offset, VCBS);
271 uint64_t cache_phase = P2PHASE(zio->io_offset, VCBS);
272 zio_t *fio;
273
274 ASSERT(zio->io_type == ZIO_TYPE_READ);
275
276 if (zio->io_flags & ZIO_FLAG_DONT_CACHE)
274 return (EINVAL);
277 return (SET_ERROR(EINVAL));
275
276 if (zio->io_size > zfs_vdev_cache_max)
278
279 if (zio->io_size > zfs_vdev_cache_max)
277 return (EOVERFLOW);
280 return (SET_ERROR(EOVERFLOW));
278
279 /*
280 * If the I/O straddles two or more cache blocks, don't cache it.
281 */
282 if (P2BOUNDARY(zio->io_offset, zio->io_size, VCBS))
281
282 /*
283 * If the I/O straddles two or more cache blocks, don't cache it.
284 */
285 if (P2BOUNDARY(zio->io_offset, zio->io_size, VCBS))
283 return (EXDEV);
286 return (SET_ERROR(EXDEV));
284
285 ASSERT(cache_phase + zio->io_size <= VCBS);
286
287 mutex_enter(&vc->vc_lock);
288
289 ve_search.ve_offset = cache_offset;
290 ve = avl_find(&vc->vc_offset_tree, &ve_search, NULL);
291
292 if (ve != NULL) {
293 if (ve->ve_missed_update) {
294 mutex_exit(&vc->vc_lock);
287
288 ASSERT(cache_phase + zio->io_size <= VCBS);
289
290 mutex_enter(&vc->vc_lock);
291
292 ve_search.ve_offset = cache_offset;
293 ve = avl_find(&vc->vc_offset_tree, &ve_search, NULL);
294
295 if (ve != NULL) {
296 if (ve->ve_missed_update) {
297 mutex_exit(&vc->vc_lock);
295 return (ESTALE);
298 return (SET_ERROR(ESTALE));
296 }
297
298 if ((fio = ve->ve_fill_io) != NULL) {
299 zio_vdev_io_bypass(zio);
300 zio_add_child(zio, fio);
301 mutex_exit(&vc->vc_lock);
302 VDCSTAT_BUMP(vdc_stat_delegations);
303 return (0);

--- 6 unchanged lines hidden (view full) ---

310 VDCSTAT_BUMP(vdc_stat_hits);
311 return (0);
312 }
313
314 ve = vdev_cache_allocate(zio);
315
316 if (ve == NULL) {
317 mutex_exit(&vc->vc_lock);
299 }
300
301 if ((fio = ve->ve_fill_io) != NULL) {
302 zio_vdev_io_bypass(zio);
303 zio_add_child(zio, fio);
304 mutex_exit(&vc->vc_lock);
305 VDCSTAT_BUMP(vdc_stat_delegations);
306 return (0);

--- 6 unchanged lines hidden (view full) ---

313 VDCSTAT_BUMP(vdc_stat_hits);
314 return (0);
315 }
316
317 ve = vdev_cache_allocate(zio);
318
319 if (ve == NULL) {
320 mutex_exit(&vc->vc_lock);
318 return (ENOMEM);
321 return (SET_ERROR(ENOMEM));
319 }
320
321 fio = zio_vdev_delegated_io(zio->io_vd, cache_offset,
322 ve->ve_data, VCBS, ZIO_TYPE_READ, ZIO_PRIORITY_CACHE_FILL,
323 ZIO_FLAG_DONT_CACHE, vdev_cache_fill, ve);
324
325 ve->ve_fill_io = fio;
326 zio_vdev_io_bypass(zio);

--- 109 unchanged lines hidden ---
322 }
323
324 fio = zio_vdev_delegated_io(zio->io_vd, cache_offset,
325 ve->ve_data, VCBS, ZIO_TYPE_READ, ZIO_PRIORITY_CACHE_FILL,
326 ZIO_FLAG_DONT_CACHE, vdev_cache_fill, ve);
327
328 ve->ve_fill_io = fio;
329 zio_vdev_io_bypass(zio);

--- 109 unchanged lines hidden ---