1688
1689 /*
1690 * Apply Postel's Law to length-checking. If they overshoot,
1691 * just blank out until the end, if there's a need to blank
1692 * out anything.
1693 */
1694 if (df.df_start >= zv->zv_volsize)
1695 break; /* No need to do anything... */
1696 if (df.df_start + df.df_length > zv->zv_volsize)
1697 df.df_length = DMU_OBJECT_END;
1698
1699 rl = zfs_range_lock(&zv->zv_znode, df.df_start, df.df_length,
1700 RL_WRITER);
1701 tx = dmu_tx_create(zv->zv_objset);
1702 error = dmu_tx_assign(tx, TXG_WAIT);
1703 if (error != 0) {
1704 dmu_tx_abort(tx);
1705 } else {
1706 zvol_log_truncate(zv, tx, df.df_start,
1707 df.df_length, B_TRUE);
1708 error = dmu_free_long_range(zv->zv_objset, ZVOL_OBJ,
1709 df.df_start, df.df_length);
1710 dmu_tx_commit(tx);
1711 }
1712
1713 zfs_range_unlock(rl);
1714
1715 if (error == 0) {
1716 /*
1717 * If the write-cache is disabled or 'sync' property
1718 * is set to 'always' then treat this as a synchronous
1719 * operation (i.e. commit to zil).
1720 */
1721 if (!(zv->zv_flags & ZVOL_WCE) ||
1722 (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS))
1723 zil_commit(zv->zv_zilog, ZVOL_OBJ);
1724
1725 /*
1726 * If the caller really wants synchronous writes, and
1727 * can't wait for them, don't return until the write
1728 * is done.
1729 */
1730 if (df.df_flags & DF_WAIT_SYNC) {
|
1688
1689 /*
1690 * Apply Postel's Law to length-checking. If they overshoot,
1691 * just blank out until the end, if there's a need to blank
1692 * out anything.
1693 */
1694 if (df.df_start >= zv->zv_volsize)
1695 break; /* No need to do anything... */
1696 if (df.df_start + df.df_length > zv->zv_volsize)
1697 df.df_length = DMU_OBJECT_END;
1698
1699 rl = zfs_range_lock(&zv->zv_znode, df.df_start, df.df_length,
1700 RL_WRITER);
1701 tx = dmu_tx_create(zv->zv_objset);
1702 error = dmu_tx_assign(tx, TXG_WAIT);
1703 if (error != 0) {
1704 dmu_tx_abort(tx);
1705 } else {
1706 zvol_log_truncate(zv, tx, df.df_start,
1707 df.df_length, B_TRUE);
1708 dmu_tx_commit(tx);
1709 error = dmu_free_long_range(zv->zv_objset, ZVOL_OBJ,
1710 df.df_start, df.df_length);
1711 }
1712
1713 zfs_range_unlock(rl);
1714
1715 if (error == 0) {
1716 /*
1717 * If the write-cache is disabled or 'sync' property
1718 * is set to 'always' then treat this as a synchronous
1719 * operation (i.e. commit to zil).
1720 */
1721 if (!(zv->zv_flags & ZVOL_WCE) ||
1722 (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS))
1723 zil_commit(zv->zv_zilog, ZVOL_OBJ);
1724
1725 /*
1726 * If the caller really wants synchronous writes, and
1727 * can't wait for them, don't return until the write
1728 * is done.
1729 */
1730 if (df.df_flags & DF_WAIT_SYNC) {
|