Deleted Added
full compact
dbuf.c (339109) dbuf.c (339114)
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

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

16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
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

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

16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
24 * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
25 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
26 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
27 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
28 * Copyright (c) 2014 Integros [integros.com]
29 */
30
31#include <sys/zfs_context.h>
32#include <sys/dmu.h>

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

995 mutex_enter(&db->db_mtx);
996 ASSERT3U(db->db_state, ==, DB_READ);
997 /*
998 * All reads are synchronous, so we must have a hold on the dbuf
999 */
1000 ASSERT(refcount_count(&db->db_holds) > 0);
1001 ASSERT(db->db_buf == NULL);
1002 ASSERT(db->db.db_data == NULL);
25 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
26 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
27 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
28 * Copyright (c) 2014 Integros [integros.com]
29 */
30
31#include <sys/zfs_context.h>
32#include <sys/dmu.h>

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

995 mutex_enter(&db->db_mtx);
996 ASSERT3U(db->db_state, ==, DB_READ);
997 /*
998 * All reads are synchronous, so we must have a hold on the dbuf
999 */
1000 ASSERT(refcount_count(&db->db_holds) > 0);
1001 ASSERT(db->db_buf == NULL);
1002 ASSERT(db->db.db_data == NULL);
1003 if (db->db_level == 0 && db->db_freed_in_flight) {
1004 /* we were freed in flight; disregard any error */
1003 if (buf == NULL) {
1004 /* i/o error */
1005 ASSERT(zio == NULL || zio->io_error != 0);
1006 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
1007 ASSERT3P(db->db_buf, ==, NULL);
1008 db->db_state = DB_UNCACHED;
1009 } else if (db->db_level == 0 && db->db_freed_in_flight) {
1010 /* freed in flight */
1011 ASSERT(zio == NULL || zio->io_error == 0);
1005 if (buf == NULL) {
1006 buf = arc_alloc_buf(db->db_objset->os_spa,
1007 db, DBUF_GET_BUFC_TYPE(db), db->db.db_size);
1008 }
1009 arc_release(buf, db);
1010 bzero(buf->b_data, db->db.db_size);
1011 arc_buf_freeze(buf);
1012 db->db_freed_in_flight = FALSE;
1013 dbuf_set_data(db, buf);
1014 db->db_state = DB_CACHED;
1012 if (buf == NULL) {
1013 buf = arc_alloc_buf(db->db_objset->os_spa,
1014 db, DBUF_GET_BUFC_TYPE(db), db->db.db_size);
1015 }
1016 arc_release(buf, db);
1017 bzero(buf->b_data, db->db.db_size);
1018 arc_buf_freeze(buf);
1019 db->db_freed_in_flight = FALSE;
1020 dbuf_set_data(db, buf);
1021 db->db_state = DB_CACHED;
1015 } else if (buf != NULL) {
1022 } else {
1023 /* success */
1024 ASSERT(zio == NULL || zio->io_error == 0);
1016 dbuf_set_data(db, buf);
1017 db->db_state = DB_CACHED;
1025 dbuf_set_data(db, buf);
1026 db->db_state = DB_CACHED;
1018 } else {
1019 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
1020 ASSERT3P(db->db_buf, ==, NULL);
1021 db->db_state = DB_UNCACHED;
1022 }
1023 cv_broadcast(&db->db_changed);
1024 dbuf_rele_and_unlock(db, NULL);
1025}
1026
1027static void
1028dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags)
1029{

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

2427dbuf_prefetch_indirect_done(zio_t *zio, const zbookmark_phys_t *zb,
2428 const blkptr_t *iobp, arc_buf_t *abuf, void *private)
2429{
2430 dbuf_prefetch_arg_t *dpa = private;
2431
2432 ASSERT3S(dpa->dpa_zb.zb_level, <, dpa->dpa_curlevel);
2433 ASSERT3S(dpa->dpa_curlevel, >, 0);
2434
1027 }
1028 cv_broadcast(&db->db_changed);
1029 dbuf_rele_and_unlock(db, NULL);
1030}
1031
1032static void
1033dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags)
1034{

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

2432dbuf_prefetch_indirect_done(zio_t *zio, const zbookmark_phys_t *zb,
2433 const blkptr_t *iobp, arc_buf_t *abuf, void *private)
2434{
2435 dbuf_prefetch_arg_t *dpa = private;
2436
2437 ASSERT3S(dpa->dpa_zb.zb_level, <, dpa->dpa_curlevel);
2438 ASSERT3S(dpa->dpa_curlevel, >, 0);
2439
2440 if (abuf == NULL) {
2441 ASSERT(zio == NULL || zio->io_error != 0);
2442 kmem_free(dpa, sizeof (*dpa));
2443 return;
2444 }
2445 ASSERT(zio == NULL || zio->io_error == 0);
2446
2435 /*
2436 * The dpa_dnode is only valid if we are called with a NULL
2437 * zio. This indicates that the arc_read() returned without
2438 * first calling zio_read() to issue a physical read. Once
2439 * a physical read is made the dpa_dnode must be invalidated
2440 * as the locks guarding it may have been dropped. If the
2441 * dpa_dnode is still valid, then we want to add it to the dbuf
2442 * cache. To do so, we must hold the dbuf associated with the block

--- 1437 unchanged lines hidden ---
2447 /*
2448 * The dpa_dnode is only valid if we are called with a NULL
2449 * zio. This indicates that the arc_read() returned without
2450 * first calling zio_read() to issue a physical read. Once
2451 * a physical read is made the dpa_dnode must be invalidated
2452 * as the locks guarding it may have been dropped. If the
2453 * dpa_dnode is still valid, then we want to add it to the dbuf
2454 * cache. To do so, we must hold the dbuf associated with the block

--- 1437 unchanged lines hidden ---