Print this page
Possibility to physically reserve space without writing leaf blocks


 793                         dmu_buf_t *db = dbp[i];
 794 
 795                         ASSERT(size > 0);
 796 
 797                         bufoff = offset - db->db_offset;
 798                         tocpy = (int)MIN(db->db_size - bufoff, size);
 799 
 800                         bcopy((char *)db->db_data + bufoff, buf, tocpy);
 801 
 802                         offset += tocpy;
 803                         size -= tocpy;
 804                         buf = (char *)buf + tocpy;
 805                 }
 806                 dmu_buf_rele_array(dbp, numbufs, FTAG);
 807         }
 808         dnode_rele(dn, FTAG);
 809         return (err);
 810 }
 811 
 812 void






















 813 dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
 814     const void *buf, dmu_tx_t *tx)
 815 {
 816         dmu_buf_t **dbp;
 817         int numbufs, i;
 818 
 819         if (size == 0)
 820                 return;
 821 
 822         VERIFY(0 == dmu_buf_hold_array(os, object, offset, size,
 823             FALSE, FTAG, &numbufs, &dbp));
 824 
 825         for (i = 0; i < numbufs; i++) {
 826                 int tocpy;
 827                 int bufoff;
 828                 dmu_buf_t *db = dbp[i];
 829 
 830                 ASSERT(size > 0);
 831 
 832                 bufoff = offset - db->db_offset;


1779                 }
1780 
1781                 /*
1782                  * Enable nopwrite if we have a cryptographically secure
1783                  * checksum that has no known collisions (i.e. SHA-256)
1784                  * and compression is enabled.  We don't enable nopwrite if
1785                  * dedup is enabled as the two features are mutually exclusive.
1786                  */
1787                 nopwrite = (!dedup && zio_checksum_table[checksum].ci_dedup &&
1788                     compress != ZIO_COMPRESS_OFF && zfs_nopwrite_enabled);
1789         }
1790 
1791         zp->zp_checksum = checksum;
1792         zp->zp_compress = compress;
1793         zp->zp_type = (wp & WP_SPILL) ? dn->dn_bonustype : type;
1794         zp->zp_level = level;
1795         zp->zp_copies = MIN(copies, spa_max_replication(os->os_spa));
1796         zp->zp_dedup = dedup;
1797         zp->zp_dedup_verify = dedup && dedup_verify;
1798         zp->zp_nopwrite = nopwrite;

1799 }
1800 
1801 int
1802 dmu_offset_next(objset_t *os, uint64_t object, boolean_t hole, uint64_t *off)
1803 {
1804         dnode_t *dn;
1805         int i, err;
1806 
1807         err = dnode_hold(os, object, FTAG, &dn);
1808         if (err)
1809                 return (err);
1810         /*
1811          * Sync any current changes before
1812          * we go trundling through the block pointers.
1813          */
1814         for (i = 0; i < TXG_SIZE; i++) {
1815                 if (list_link_active(&dn->dn_dirty_link[i]))
1816                         break;
1817         }
1818         if (i != TXG_SIZE) {




 793                         dmu_buf_t *db = dbp[i];
 794 
 795                         ASSERT(size > 0);
 796 
 797                         bufoff = offset - db->db_offset;
 798                         tocpy = (int)MIN(db->db_size - bufoff, size);
 799 
 800                         bcopy((char *)db->db_data + bufoff, buf, tocpy);
 801 
 802                         offset += tocpy;
 803                         size -= tocpy;
 804                         buf = (char *)buf + tocpy;
 805                 }
 806                 dmu_buf_rele_array(dbp, numbufs, FTAG);
 807         }
 808         dnode_rele(dn, FTAG);
 809         return (err);
 810 }
 811 
 812 void
 813 dmu_write_zero(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_tx_t *tx)
 814 {
 815         dmu_buf_t       **dbp;
 816         int             numbufs, i;
 817 
 818         VERIFY(0 == dmu_buf_hold_array(os, object, offset, size,
 819             FALSE, FTAG, &numbufs, &dbp));
 820 
 821         for (i = 0; i < numbufs; i++) {
 822                 dmu_buf_t *db = dbp[i];
 823 
 824                 dmu_buf_will_zero_fill(db, tx);
 825 
 826                 memset(db->db_data, 0, db->db_size);
 827 
 828                 dmu_buf_fill_done(db, tx);
 829         }
 830 
 831         dmu_buf_rele_array(dbp, numbufs, FTAG);
 832 }
 833 
 834 void
 835 dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
 836     const void *buf, dmu_tx_t *tx)
 837 {
 838         dmu_buf_t **dbp;
 839         int numbufs, i;
 840 
 841         if (size == 0)
 842                 return;
 843 
 844         VERIFY(0 == dmu_buf_hold_array(os, object, offset, size,
 845             FALSE, FTAG, &numbufs, &dbp));
 846 
 847         for (i = 0; i < numbufs; i++) {
 848                 int tocpy;
 849                 int bufoff;
 850                 dmu_buf_t *db = dbp[i];
 851 
 852                 ASSERT(size > 0);
 853 
 854                 bufoff = offset - db->db_offset;


1801                 }
1802 
1803                 /*
1804                  * Enable nopwrite if we have a cryptographically secure
1805                  * checksum that has no known collisions (i.e. SHA-256)
1806                  * and compression is enabled.  We don't enable nopwrite if
1807                  * dedup is enabled as the two features are mutually exclusive.
1808                  */
1809                 nopwrite = (!dedup && zio_checksum_table[checksum].ci_dedup &&
1810                     compress != ZIO_COMPRESS_OFF && zfs_nopwrite_enabled);
1811         }
1812 
1813         zp->zp_checksum = checksum;
1814         zp->zp_compress = compress;
1815         zp->zp_type = (wp & WP_SPILL) ? dn->dn_bonustype : type;
1816         zp->zp_level = level;
1817         zp->zp_copies = MIN(copies, spa_max_replication(os->os_spa));
1818         zp->zp_dedup = dedup;
1819         zp->zp_dedup_verify = dedup && dedup_verify;
1820         zp->zp_nopwrite = nopwrite;
1821         zp->zp_zero_write = B_FALSE;
1822 }
1823 
1824 int
1825 dmu_offset_next(objset_t *os, uint64_t object, boolean_t hole, uint64_t *off)
1826 {
1827         dnode_t *dn;
1828         int i, err;
1829 
1830         err = dnode_hold(os, object, FTAG, &dn);
1831         if (err)
1832                 return (err);
1833         /*
1834          * Sync any current changes before
1835          * we go trundling through the block pointers.
1836          */
1837         for (i = 0; i < TXG_SIZE; i++) {
1838                 if (list_link_active(&dn->dn_dirty_link[i]))
1839                         break;
1840         }
1841         if (i != TXG_SIZE) {