From owner-svn-src-stable@freebsd.org Sat Nov 12 23:53:39 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4824FC3E0B0; Sat, 12 Nov 2016 23:53:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E32D129A; Sat, 12 Nov 2016 23:53:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uACNrc0W087251; Sat, 12 Nov 2016 23:53:38 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uACNrcXK087248; Sat, 12 Nov 2016 23:53:38 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201611122353.uACNrcXK087248@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 12 Nov 2016 23:53:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r308595 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Nov 2016 23:53:39 -0000 Author: mav Date: Sat Nov 12 23:53:37 2016 New Revision: 308595 URL: https://svnweb.freebsd.org/changeset/base/308595 Log: MFC r308173: Fix ZIL records ordering when ZVOL opened both with and without FSYNC. Before this an earlier writes to a ZVOL opened without FSYNC could get to ZIL after later writes to the same ZVOL opened with FSYNC. Fix this by replicating functionality of ZPL (zv_sync_cnt equivalent to z_sync_cnt), marking all log records sync if anybody opened the ZVOL with FSYNC. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h Sat Nov 12 23:52:39 2016 (r308594) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h Sat Nov 12 23:53:37 2016 (r308595) @@ -405,6 +405,7 @@ extern itx_t *zil_itx_create(uint64_t tx extern void zil_itx_destroy(itx_t *itx); extern void zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx); +extern void zil_async_to_sync(zilog_t *zilog, uint64_t oid); extern void zil_commit(zilog_t *zilog, uint64_t oid); extern int zil_vdev_offline(const char *osname, void *txarg); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Sat Nov 12 23:52:39 2016 (r308594) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Sat Nov 12 23:53:37 2016 (r308595) @@ -90,8 +90,6 @@ SYSCTL_INT(_vfs_zfs_trim, OID_AUTO, enab static kmem_cache_t *zil_lwb_cache; -static void zil_async_to_sync(zilog_t *zilog, uint64_t foid); - #define LWB_EMPTY(lwb) ((BP_GET_LSIZE(&lwb->lwb_blk) - \ sizeof (zil_chain_t)) == (lwb->lwb_sz - lwb->lwb_nused)) @@ -1412,7 +1410,7 @@ zil_get_commit_list(zilog_t *zilog) /* * Move the async itxs for a specified object to commit into sync lists. */ -static void +void zil_async_to_sync(zilog_t *zilog, uint64_t foid) { uint64_t otxg, txg; Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Sat Nov 12 23:52:39 2016 (r308594) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Sat Nov 12 23:53:37 2016 (r308595) @@ -169,6 +169,7 @@ typedef struct zvol_state { uint32_t zv_open_count[OTYPCNT]; /* open counts */ #endif uint32_t zv_total_opens; /* total open count */ + uint32_t zv_sync_cnt; /* synchronous open count */ zilog_t *zv_zilog; /* ZIL handle */ list_t zv_extents; /* List of extents for dump */ znode_t zv_znode; /* for range locking */ @@ -1437,7 +1438,9 @@ zvol_log_write(zvol_state_t *zv, dmu_tx_ BP_ZERO(&lr->lr_blkptr); itx->itx_private = zv; - itx->itx_sync = sync; + + if (!sync && (zv->zv_sync_cnt == 0)) + itx->itx_sync = B_FALSE; zil_itx_assign(zilog, itx, tx); @@ -2079,7 +2082,7 @@ zvol_log_truncate(zvol_state_t *zv, dmu_ lr->lr_offset = off; lr->lr_length = len; - itx->itx_sync = sync; + itx->itx_sync = (sync || zv->zv_sync_cnt != 0); zil_itx_assign(zilog, itx, tx); } @@ -3071,6 +3074,11 @@ zvol_d_open(struct cdev *dev, int flags, #endif zv->zv_total_opens++; + if (flags & (FSYNC | FDSYNC)) { + zv->zv_sync_cnt++; + if (zv->zv_sync_cnt == 1) + zil_async_to_sync(zv->zv_zilog, ZVOL_OBJ); + } mutex_exit(&zfsdev_state_lock); return (err); out: @@ -3101,6 +3109,8 @@ zvol_d_close(struct cdev *dev, int flags * You may get multiple opens, but only one close. */ zv->zv_total_opens--; + if (flags & (FSYNC | FDSYNC)) + zv->zv_sync_cnt--; if (zv->zv_total_opens == 0) zvol_last_close(zv);