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 --- 93 unchanged lines hidden (view full) --- 102 * pushing cached pages (which acquires range locks) and syncing out 103 * cached atime changes. Third, zfs_zinactive() may require a new tx, 104 * which could deadlock the system if you were already holding one. 105 * If you must call VN_RELE() within a tx then use VN_RELE_ASYNC(). 106 * 107 * (3) All range locks must be grabbed before calling dmu_tx_assign(), 108 * as they can span dmu_tx_assign() calls. 109 * |
110 * (4) If ZPL locks are held, pass TXG_NOWAIT as the second argument to 111 * dmu_tx_assign(). This is critical because we don't want to block 112 * while holding locks. |
113 * |
114 * If no ZPL locks are held (aside from ZFS_ENTER()), use TXG_WAIT. This 115 * reduces lock contention and CPU usage when we must wait (note that if 116 * throughput is constrained by the storage, nearly every transaction 117 * must wait). 118 * 119 * Note, in particular, that if a lock is sometimes acquired before 120 * the tx assigns, and sometimes after (e.g. z_lock), then failing 121 * to use a non-blocking assign can deadlock the system. The scenario: 122 * |
123 * Thread A has grabbed a lock before calling dmu_tx_assign(). 124 * Thread B is in an already-assigned tx, and blocks for this lock. 125 * Thread A calls dmu_tx_assign(TXG_WAIT) and blocks in txg_wait_open() 126 * forever, because the previous txg can't quiesce until B's tx commits. 127 * 128 * If dmu_tx_assign() returns ERESTART and zfsvfs->z_assign is TXG_NOWAIT, 129 * then drop all locks, call dmu_tx_wait(), and try again. On subsequent 130 * calls to dmu_tx_assign(), pass TXG_WAITED rather than TXG_NOWAIT, --- 839 unchanged lines hidden (view full) --- 970 /* 971 * Write the file in reasonable size chunks. Each chunk is written 972 * in a separate transaction; this keeps the intent log records small 973 * and allows us to do more fine-grained space accounting. 974 */ 975 while (n > 0) { 976 abuf = NULL; 977 woff = uio->uio_loffset; |
978 if (zfs_owner_overquota(zfsvfs, zp, B_FALSE) || 979 zfs_owner_overquota(zfsvfs, zp, B_TRUE)) { 980 if (abuf != NULL) 981 dmu_return_arcbuf(abuf); 982 error = SET_ERROR(EDQUOT); 983 break; 984 } 985 --- 35 unchanged lines hidden (view full) --- 1021 1022 /* 1023 * Start a transaction. 1024 */ 1025 tx = dmu_tx_create(zfsvfs->z_os); 1026 dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); 1027 dmu_tx_hold_write(tx, zp->z_id, woff, MIN(n, max_blksz)); 1028 zfs_sa_upgrade_txholds(tx, zp); |
1029 error = dmu_tx_assign(tx, TXG_WAIT); |
1030 if (error) { |
1031 dmu_tx_abort(tx); 1032 if (abuf != NULL) 1033 dmu_return_arcbuf(abuf); 1034 break; 1035 } 1036 1037 /* 1038 * If zfs_range_lock() over-locked we grow the blocksize --- 2367 unchanged lines hidden (view full) --- 3406 } 3407 3408 fuid_dirtied = zfsvfs->z_fuid_dirty; 3409 if (fuid_dirtied) 3410 zfs_fuid_txhold(zfsvfs, tx); 3411 3412 zfs_sa_upgrade_txholds(tx, zp); 3413 |
3414 err = dmu_tx_assign(tx, TXG_WAIT); 3415 if (err) |
3416 goto out; |
3417 3418 count = 0; 3419 /* 3420 * Set each attribute requested. 3421 * We group settings according to the locks they need to acquire. 3422 * 3423 * Note: you cannot set ctime directly, although it will be 3424 * updated as a side-effect of calling this function. --- 1096 unchanged lines hidden (view full) --- 4521 len = zp->z_size - off; 4522 } 4523 4524 if (zfs_owner_overquota(zfsvfs, zp, B_FALSE) || 4525 zfs_owner_overquota(zfsvfs, zp, B_TRUE)) { 4526 err = SET_ERROR(EDQUOT); 4527 goto out; 4528 } |
4529 tx = dmu_tx_create(zfsvfs->z_os); 4530 dmu_tx_hold_write(tx, zp->z_id, off, len); 4531 4532 dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); 4533 zfs_sa_upgrade_txholds(tx, zp); |
4534 err = dmu_tx_assign(tx, TXG_WAIT); |
4535 if (err != 0) { |
4536 dmu_tx_abort(tx); 4537 goto out; 4538 } 4539 4540 if (zp->z_blksz <= PAGESIZE) { 4541 caddr_t va = zfs_map_page(pp, S_READ); 4542 ASSERT3U(len, <=, PAGESIZE); 4543 dmu_write(zfsvfs->z_os, zp->z_id, off, len, va, tx); --- 2452 unchanged lines hidden --- |