summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Perrin <Neil.Perrin@Sun.COM>2010-07-06 11:05:17 -0600
committerNeil Perrin <Neil.Perrin@Sun.COM>2010-07-06 11:05:17 -0600
commit91de656b0815c0aeab4e6fc638e9bb4577aa9513 (patch)
tree12eda0ab118dc5a2e1982a74c9fe2181ab14f1e9
parent2b70f49a2b929bd5fe23f7a0db9be5dedce114a4 (diff)
downloadillumos-gate-91de656b0815c0aeab4e6fc638e9bb4577aa9513.tar.gz
6834694 zfs renames can potentially be committed without the data
6906236 assertion failed in the file zfs_replay.c line 686 6965567 zil.c minor tidy up 6732237 lzjb_compress
-rw-r--r--usr/src/uts/common/fs/zfs/lzjb.c9
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zfs_znode.h2
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_log.c3
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_replay.c7
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_vnops.c4
-rw-r--r--usr/src/uts/common/fs/zfs/zil.c18
6 files changed, 23 insertions, 20 deletions
diff --git a/usr/src/uts/common/fs/zfs/lzjb.c b/usr/src/uts/common/fs/zfs/lzjb.c
index 10952f472b..ab3de51b72 100644
--- a/usr/src/uts/common/fs/zfs/lzjb.c
+++ b/usr/src/uts/common/fs/zfs/lzjb.c
@@ -20,12 +20,11 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * We keep our own copy of this algorithm for 2 main reasons:
+ * We keep our own copy of this algorithm for 3 main reasons:
* 1. If we didn't, anyone modifying common/os/compress.c would
* directly break our on disk format
* 2. Our version of lzjb does not have a number of checks that the
@@ -33,8 +32,8 @@
* 3. We initialize the lempel to ensure deterministic results,
* so that identical blocks can always be deduplicated.
* In particular, we are adding the "feature" that compress() can
- * take a destination buffer size and return -1 if the data will not
- * compress to d_len or less.
+ * take a destination buffer size and returns the compressed length, or the
+ * source length if compression would overflow the destination buffer.
*/
#include <sys/types.h>
diff --git a/usr/src/uts/common/fs/zfs/sys/zfs_znode.h b/usr/src/uts/common/fs/zfs/sys/zfs_znode.h
index 379b9ecd7e..5e281a2c62 100644
--- a/usr/src/uts/common/fs/zfs/sys/zfs_znode.h
+++ b/usr/src/uts/common/fs/zfs/sys/zfs_znode.h
@@ -327,7 +327,7 @@ extern void zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
extern void zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
znode_t *dzp, znode_t *zp, char *name, char *link);
extern void zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *sdzp, char *sname, znode_t *tdzp, char *dname);
+ znode_t *sdzp, char *sname, znode_t *tdzp, char *dname, znode_t *szp);
extern void zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
znode_t *zp, offset_t off, ssize_t len, int ioflag);
extern void zfs_log_truncate(zilog_t *zilog, dmu_tx_t *tx, int txtype,
diff --git a/usr/src/uts/common/fs/zfs/zfs_log.c b/usr/src/uts/common/fs/zfs/zfs_log.c
index 451f2bf344..70368481cc 100644
--- a/usr/src/uts/common/fs/zfs/zfs_log.c
+++ b/usr/src/uts/common/fs/zfs/zfs_log.c
@@ -418,7 +418,7 @@ zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
*/
void
zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *sdzp, char *sname, znode_t *tdzp, char *dname)
+ znode_t *sdzp, char *sname, znode_t *tdzp, char *dname, znode_t *szp)
{
itx_t *itx;
lr_rename_t *lr;
@@ -434,6 +434,7 @@ zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
lr->lr_tdoid = tdzp->z_id;
bcopy(sname, (char *)(lr + 1), snamesize);
bcopy(dname, (char *)(lr + 1) + snamesize, dnamesize);
+ itx->itx_oid = szp->z_id;
zil_itx_assign(zilog, itx, tx);
}
diff --git a/usr/src/uts/common/fs/zfs/zfs_replay.c b/usr/src/uts/common/fs/zfs/zfs_replay.c
index f26009b02c..8a6d173362 100644
--- a/usr/src/uts/common/fs/zfs/zfs_replay.c
+++ b/usr/src/uts/common/fs/zfs/zfs_replay.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
@@ -695,10 +694,8 @@ zfs_replay_write2(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap)
return (error);
end = lr->lr_offset + lr->lr_length;
- if (end > zp->z_size) {
- ASSERT3U(end - zp->z_size, <, zp->z_blksz);
+ if (end > zp->z_size)
zp->z_size = end;
- }
VN_RELE(ZTOV(zp));
diff --git a/usr/src/uts/common/fs/zfs/zfs_vnops.c b/usr/src/uts/common/fs/zfs/zfs_vnops.c
index 774c8f15e4..d431c7093c 100644
--- a/usr/src/uts/common/fs/zfs/zfs_vnops.c
+++ b/usr/src/uts/common/fs/zfs/zfs_vnops.c
@@ -3574,8 +3574,8 @@ top:
error = zfs_link_destroy(sdl, szp, tx, ZRENAMING, NULL);
if (error == 0) {
zfs_log_rename(zilog, tx, TX_RENAME |
- (flags & FIGNORECASE ? TX_CI : 0),
- sdzp, sdl->dl_name, tdzp, tdl->dl_name);
+ (flags & FIGNORECASE ? TX_CI : 0), sdzp,
+ sdl->dl_name, tdzp, tdl->dl_name, szp);
/*
* Update path information for the target vnode
diff --git a/usr/src/uts/common/fs/zfs/zil.c b/usr/src/uts/common/fs/zfs/zil.c
index f491be90c8..acf0b28c7e 100644
--- a/usr/src/uts/common/fs/zfs/zil.c
+++ b/usr/src/uts/common/fs/zfs/zil.c
@@ -78,7 +78,7 @@ boolean_t zfs_nocacheflush = B_FALSE;
static kmem_cache_t *zil_lwb_cache;
-static boolean_t zil_empty(zilog_t *zilog);
+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))
@@ -712,7 +712,7 @@ zil_add_block(zilog_t *zilog, const blkptr_t *bp)
mutex_exit(&zilog->zl_vdev_lock);
}
-void
+static void
zil_flush_vdevs(zilog_t *zilog)
{
spa_t *spa = zilog->zl_spa;
@@ -1119,7 +1119,7 @@ zil_aitx_compare(const void *x1, const void *x2)
/*
* Remove all async itx with the given oid.
*/
-void
+static void
zil_remove_async(zilog_t *zilog, uint64_t oid)
{
uint64_t otxg, txg;
@@ -1171,7 +1171,7 @@ zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx)
itxs_t *itxs, *clean = NULL;
/*
- * Object ids can be re-instantiated in the same or next txg so
+ * Object ids can be re-instantiated in the next txg so
* remove any async transactions to avoid future leaks.
* This can happen if a fsync occurs on the re-instantiated
* object for a WR_INDIRECT or WR_NEED_COPY write, which gets
@@ -1180,6 +1180,12 @@ zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx)
if ((itx->itx_lr.lrc_txtype & ~TX_CI) == TX_REMOVE)
zil_remove_async(zilog, itx->itx_oid);
+ /*
+ * Ensure the data of a renamed file is committed before the rename.
+ */
+ if ((itx->itx_lr.lrc_txtype & ~TX_CI) == TX_RENAME)
+ zil_async_to_sync(zilog, itx->itx_oid);
+
if (spa_freeze_txg(zilog->zl_spa) != UINT64_MAX)
txg = ZILTEST_TXG;
else
@@ -1276,7 +1282,7 @@ zil_clean(zilog_t *zilog, uint64_t synced_txg)
/*
* Get the list of itxs to commit into zl_itx_commit_list.
*/
-void
+static void
zil_get_commit_list(zilog_t *zilog)
{
uint64_t otxg, txg;
@@ -1309,7 +1315,7 @@ zil_get_commit_list(zilog_t *zilog)
/*
* Move the async itxs for a specified object to commit into sync lists.
*/
-void
+static void
zil_async_to_sync(zilog_t *zilog, uint64_t foid)
{
uint64_t otxg, txg;