Print this page
NEX-9200 Improve the scalability of attribute locking in zfs_zget
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
6385 Fix unlocking order in zfs_zget
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Andriy Gapon <avg@freebsd.org>
Approved by: Robert Mustacchi <rm@joyent.com>
5961 Fix stack overflow in zfs_create_fs
Reviewed by: George Wilson <george@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>
4370 avoid transmitting holes during zfs send
4371 DMU code clean up
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Garrett D'Amore <garrett@damore.org>


1732             NULL, &zp->z_pflags, 8);
1733         zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime, B_TRUE);
1734         error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
1735         ASSERT(error == 0);
1736 
1737         zfs_log_truncate(zilog, tx, TX_TRUNCATE, zp, off, len);
1738 
1739         dmu_tx_commit(tx);
1740         return (0);
1741 }
1742 
1743 void
1744 zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
1745 {
1746         uint64_t        moid, obj, sa_obj, version;
1747         uint64_t        sense = ZFS_CASE_SENSITIVE;
1748         uint64_t        norm = 0;
1749         nvpair_t        *elem;
1750         int             error;
1751         int             i;

1752         znode_t         *rootzp = NULL;
1753         zfsvfs_t        *zfsvfs;
1754         vnode_t         *vp;
1755         vattr_t         vattr;
1756         znode_t         *zp;
1757         zfs_acl_ids_t   acl_ids;
1758 
1759         /*
1760          * First attempt to create master node.
1761          */
1762         /*
1763          * In an empty objset, there are no blocks to read and thus
1764          * there can be no i/o errors (which we assert below).
1765          */
1766         moid = MASTER_NODE_OBJ;
1767         error = zap_create_claim(os, moid, DMU_OT_MASTER_NODE,
1768             DMU_OT_NONE, 0, tx);
1769         ASSERT(error == 0);
1770 
1771         /*


1844         zfsvfs->z_use_fuids = USE_FUIDS(version, os);
1845         zfsvfs->z_use_sa = USE_SA(version, os);
1846         zfsvfs->z_norm = norm;
1847 
1848         error = sa_setup(os, sa_obj, zfs_attr_table, ZPL_END,
1849             &zfsvfs->z_attr_table);
1850 
1851         ASSERT(error == 0);
1852 
1853         /*
1854          * Fold case on file systems that are always or sometimes case
1855          * insensitive.
1856          */
1857         if (sense == ZFS_CASE_INSENSITIVE || sense == ZFS_CASE_MIXED)
1858                 zfsvfs->z_norm |= U8_TEXTPREP_TOUPPER;
1859 
1860         mutex_init(&zfsvfs->z_znodes_lock, NULL, MUTEX_DEFAULT, NULL);
1861         list_create(&zfsvfs->z_all_znodes, sizeof (znode_t),
1862             offsetof(znode_t, z_link_node));
1863 
1864         for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)


1865                 mutex_init(&zfsvfs->z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL);
1866 
1867         rootzp->z_zfsvfs = zfsvfs;
1868         VERIFY(0 == zfs_acl_ids_create(rootzp, IS_ROOT_NODE, &vattr,
1869             cr, NULL, &acl_ids));
1870         zfs_mknode(rootzp, &vattr, tx, cr, IS_ROOT_NODE, &zp, &acl_ids);
1871         ASSERT3P(zp, ==, rootzp);
1872         ASSERT(!vn_in_dnlc(ZTOV(rootzp))); /* not valid to move */
1873         error = zap_add(os, moid, ZFS_ROOT_OBJ, 8, 1, &rootzp->z_id, tx);
1874         ASSERT(error == 0);
1875         zfs_acl_ids_free(&acl_ids);
1876         POINTER_INVALIDATE(&rootzp->z_zfsvfs);
1877 
1878         ZTOV(rootzp)->v_count = 0;
1879         sa_handle_destroy(rootzp->z_sa_hdl);
1880         kmem_cache_free(znode_cache, rootzp);
1881 
1882         /*
1883          * Create shares directory
1884          */
1885 
1886         error = zfs_create_share_dir(zfsvfs, tx);
1887 
1888         ASSERT(error == 0);
1889 
1890         for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
1891                 mutex_destroy(&zfsvfs->z_hold_mtx[i]);


1892         kmem_free(zfsvfs, sizeof (zfsvfs_t));
1893 }
1894 
1895 #endif /* _KERNEL */
1896 
1897 static int
1898 zfs_sa_setup(objset_t *osp, sa_attr_type_t **sa_table)
1899 {
1900         uint64_t sa_obj = 0;
1901         int error;
1902 
1903         error = zap_lookup(osp, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1, &sa_obj);
1904         if (error != 0 && error != ENOENT)
1905                 return (error);
1906 
1907         error = sa_setup(osp, sa_obj, zfs_attr_table, ZPL_END, sa_table);
1908         return (error);
1909 }
1910 
1911 static int




1732             NULL, &zp->z_pflags, 8);
1733         zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime, B_TRUE);
1734         error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
1735         ASSERT(error == 0);
1736 
1737         zfs_log_truncate(zilog, tx, TX_TRUNCATE, zp, off, len);
1738 
1739         dmu_tx_commit(tx);
1740         return (0);
1741 }
1742 
1743 void
1744 zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
1745 {
1746         uint64_t        moid, obj, sa_obj, version;
1747         uint64_t        sense = ZFS_CASE_SENSITIVE;
1748         uint64_t        norm = 0;
1749         nvpair_t        *elem;
1750         int             error;
1751         int             i;
1752         int size = spa_get_obj_mtx_sz(dmu_objset_spa(os));
1753         znode_t         *rootzp = NULL;
1754         zfsvfs_t        *zfsvfs;
1755         vnode_t         *vp;
1756         vattr_t         vattr;
1757         znode_t         *zp;
1758         zfs_acl_ids_t   acl_ids;
1759 
1760         /*
1761          * First attempt to create master node.
1762          */
1763         /*
1764          * In an empty objset, there are no blocks to read and thus
1765          * there can be no i/o errors (which we assert below).
1766          */
1767         moid = MASTER_NODE_OBJ;
1768         error = zap_create_claim(os, moid, DMU_OT_MASTER_NODE,
1769             DMU_OT_NONE, 0, tx);
1770         ASSERT(error == 0);
1771 
1772         /*


1845         zfsvfs->z_use_fuids = USE_FUIDS(version, os);
1846         zfsvfs->z_use_sa = USE_SA(version, os);
1847         zfsvfs->z_norm = norm;
1848 
1849         error = sa_setup(os, sa_obj, zfs_attr_table, ZPL_END,
1850             &zfsvfs->z_attr_table);
1851 
1852         ASSERT(error == 0);
1853 
1854         /*
1855          * Fold case on file systems that are always or sometimes case
1856          * insensitive.
1857          */
1858         if (sense == ZFS_CASE_INSENSITIVE || sense == ZFS_CASE_MIXED)
1859                 zfsvfs->z_norm |= U8_TEXTPREP_TOUPPER;
1860 
1861         mutex_init(&zfsvfs->z_znodes_lock, NULL, MUTEX_DEFAULT, NULL);
1862         list_create(&zfsvfs->z_all_znodes, sizeof (znode_t),
1863             offsetof(znode_t, z_link_node));
1864 
1865         zfsvfs->z_hold_mtx_sz = size;
1866         zfsvfs->z_hold_mtx = kmem_zalloc(sizeof (kmutex_t) * size, KM_SLEEP);
1867         for (i = 0; i != size; i++)
1868                 mutex_init(&zfsvfs->z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL);
1869 
1870         rootzp->z_zfsvfs = zfsvfs;
1871         VERIFY(0 == zfs_acl_ids_create(rootzp, IS_ROOT_NODE, &vattr,
1872             cr, NULL, &acl_ids));
1873         zfs_mknode(rootzp, &vattr, tx, cr, IS_ROOT_NODE, &zp, &acl_ids);
1874         ASSERT3P(zp, ==, rootzp);
1875         ASSERT(!vn_in_dnlc(ZTOV(rootzp))); /* not valid to move */
1876         error = zap_add(os, moid, ZFS_ROOT_OBJ, 8, 1, &rootzp->z_id, tx);
1877         ASSERT(error == 0);
1878         zfs_acl_ids_free(&acl_ids);
1879         POINTER_INVALIDATE(&rootzp->z_zfsvfs);
1880 
1881         ZTOV(rootzp)->v_count = 0;
1882         sa_handle_destroy(rootzp->z_sa_hdl);
1883         kmem_cache_free(znode_cache, rootzp);
1884 
1885         /*
1886          * Create shares directory
1887          */
1888 
1889         error = zfs_create_share_dir(zfsvfs, tx);
1890 
1891         ASSERT(error == 0);
1892 
1893         for (i = 0; i != size; i++)
1894                 mutex_destroy(&zfsvfs->z_hold_mtx[i]);
1895 
1896         kmem_free(zfsvfs->z_hold_mtx, sizeof (kmutex_t) * size);
1897         kmem_free(zfsvfs, sizeof (zfsvfs_t));
1898 }
1899 
1900 #endif /* _KERNEL */
1901 
1902 static int
1903 zfs_sa_setup(objset_t *osp, sa_attr_type_t **sa_table)
1904 {
1905         uint64_t sa_obj = 0;
1906         int error;
1907 
1908         error = zap_lookup(osp, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1, &sa_obj);
1909         if (error != 0 && error != ENOENT)
1910                 return (error);
1911 
1912         error = sa_setup(osp, sa_obj, zfs_attr_table, ZPL_END, sa_table);
1913         return (error);
1914 }
1915 
1916 static int