dnode.c (277300) | dnode.c (284593) |
---|---|
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 --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 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. | 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 --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 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 (c) 2012, 2014 by Delphix. All rights reserved. | 23 * Copyright (c) 2012, 2015 by Delphix. All rights reserved. |
24 */ 25 26#include <sys/zfs_context.h> 27#include <sys/dbuf.h> 28#include <sys/dnode.h> 29#include <sys/dmu.h> 30#include <sys/dmu_impl.h> 31#include <sys/dmu_tx.h> --- 1455 unchanged lines hidden (view full) --- 1487 mutex_exit(&dn->dn_mtx); 1488 } 1489 1490out: 1491 if (have_read) 1492 rw_downgrade(&dn->dn_struct_rwlock); 1493} 1494 | 24 */ 25 26#include <sys/zfs_context.h> 27#include <sys/dbuf.h> 28#include <sys/dnode.h> 29#include <sys/dmu.h> 30#include <sys/dmu_impl.h> 31#include <sys/dmu_tx.h> --- 1455 unchanged lines hidden (view full) --- 1487 mutex_exit(&dn->dn_mtx); 1488 } 1489 1490out: 1491 if (have_read) 1492 rw_downgrade(&dn->dn_struct_rwlock); 1493} 1494 |
1495static void 1496dnode_dirty_l1(dnode_t *dn, uint64_t l1blkid, dmu_tx_t *tx) 1497{ 1498 dmu_buf_impl_t *db = dbuf_hold_level(dn, 1, l1blkid, FTAG); 1499 if (db != NULL) { 1500 dmu_buf_will_dirty(&db->db, tx); 1501 dbuf_rele(db, FTAG); 1502 } 1503} 1504 |
|
1495void 1496dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx) 1497{ 1498 dmu_buf_impl_t *db; 1499 uint64_t blkoff, blkid, nblks; 1500 int blksz, blkshift, head, tail; 1501 int trunc = FALSE; 1502 int epbs; --- 104 unchanged lines hidden (view full) --- 1607 ASSERT(IS_P2ALIGNED(off, blksz)); 1608 ASSERT(trunc || IS_P2ALIGNED(len, blksz)); 1609 blkid = off >> blkshift; 1610 nblks = len >> blkshift; 1611 if (trunc) 1612 nblks += 1; 1613 1614 /* | 1505void 1506dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx) 1507{ 1508 dmu_buf_impl_t *db; 1509 uint64_t blkoff, blkid, nblks; 1510 int blksz, blkshift, head, tail; 1511 int trunc = FALSE; 1512 int epbs; --- 104 unchanged lines hidden (view full) --- 1617 ASSERT(IS_P2ALIGNED(off, blksz)); 1618 ASSERT(trunc || IS_P2ALIGNED(len, blksz)); 1619 blkid = off >> blkshift; 1620 nblks = len >> blkshift; 1621 if (trunc) 1622 nblks += 1; 1623 1624 /* |
1615 * Dirty the first and last indirect blocks, as they (and/or their 1616 * parents) will need to be written out if they were only 1617 * partially freed. Interior indirect blocks will be themselves freed, 1618 * by free_children(), so they need not be dirtied. Note that these 1619 * interior blocks have already been prefetched by dmu_tx_hold_free(). | 1625 * Dirty all the indirect blocks in this range. Note that only 1626 * the first and last indirect blocks can actually be written 1627 * (if they were partially freed) -- they must be dirtied, even if 1628 * they do not exist on disk yet. The interior blocks will 1629 * be freed by free_children(), so they will not actually be written. 1630 * Even though these interior blocks will not be written, we 1631 * dirty them for two reasons: 1632 * 1633 * - It ensures that the indirect blocks remain in memory until 1634 * syncing context. (They have already been prefetched by 1635 * dmu_tx_hold_free(), so we don't have to worry about reading 1636 * them serially here.) 1637 * 1638 * - The dirty space accounting will put pressure on the txg sync 1639 * mechanism to begin syncing, and to delay transactions if there 1640 * is a large amount of freeing. Even though these indirect 1641 * blocks will not be written, we could need to write the same 1642 * amount of space if we copy the freed BPs into deadlists. |
1620 */ 1621 if (dn->dn_nlevels > 1) { 1622 uint64_t first, last; 1623 1624 first = blkid >> epbs; | 1643 */ 1644 if (dn->dn_nlevels > 1) { 1645 uint64_t first, last; 1646 1647 first = blkid >> epbs; |
1625 if (db = dbuf_hold_level(dn, 1, first, FTAG)) { 1626 dmu_buf_will_dirty(&db->db, tx); 1627 dbuf_rele(db, FTAG); 1628 } | 1648 dnode_dirty_l1(dn, first, tx); |
1629 if (trunc) 1630 last = dn->dn_maxblkid >> epbs; 1631 else 1632 last = (blkid + nblks - 1) >> epbs; | 1649 if (trunc) 1650 last = dn->dn_maxblkid >> epbs; 1651 else 1652 last = (blkid + nblks - 1) >> epbs; |
1633 if (last > first && (db = dbuf_hold_level(dn, 1, last, FTAG))) { 1634 dmu_buf_will_dirty(&db->db, tx); 1635 dbuf_rele(db, FTAG); | 1653 if (last != first) 1654 dnode_dirty_l1(dn, last, tx); 1655 1656 int shift = dn->dn_datablkshift + dn->dn_indblkshift - 1657 SPA_BLKPTRSHIFT; 1658 for (uint64_t i = first + 1; i < last; i++) { 1659 /* 1660 * Set i to the blockid of the next non-hole 1661 * level-1 indirect block at or after i. Note 1662 * that dnode_next_offset() operates in terms of 1663 * level-0-equivalent bytes. 1664 */ 1665 uint64_t ibyte = i << shift; 1666 int err = dnode_next_offset(dn, DNODE_FIND_HAVELOCK, 1667 &ibyte, 2, 1, 0); 1668 i = ibyte >> shift; 1669 if (i >= last) 1670 break; 1671 1672 /* 1673 * Normally we should not see an error, either 1674 * from dnode_next_offset() or dbuf_hold_level() 1675 * (except for ESRCH from dnode_next_offset). 1676 * If there is an i/o error, then when we read 1677 * this block in syncing context, it will use 1678 * ZIO_FLAG_MUSTSUCCEED, and thus hang/panic according 1679 * to the "failmode" property. dnode_next_offset() 1680 * doesn't have a flag to indicate MUSTSUCCEED. 1681 */ 1682 if (err != 0) 1683 break; 1684 1685 dnode_dirty_l1(dn, i, tx); |
1636 } 1637 } 1638 1639done: 1640 /* 1641 * Add this range to the dnode range list. 1642 * We will finish up this free operation in the syncing phase. 1643 */ --- 323 unchanged lines hidden --- | 1686 } 1687 } 1688 1689done: 1690 /* 1691 * Add this range to the dnode range list. 1692 * We will finish up this free operation in the syncing phase. 1693 */ --- 323 unchanged lines hidden --- |