summaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-03-09 13:20:28 -0800
committerBrian Behlendorf <[email protected]>2011-03-09 13:31:00 -0800
commitadf2e8778e66e6a749cec981da00463b342bd563 (patch)
treede4ae9c8123fb78ab09156def7a45153e05bd0c9 /module/zfs
parent17c37660a14cc5e26cc668fdb285933fee4b6cf4 (diff)
Fix O_APPEND Corruption
Due to an uninitialized variable files opened with O_APPEND may overwrite the start of the file rather than append to it. This was introduced accidentally when I removed the Solaris vnodes. The zfs_range_lock_writer() function used to key off zf->z_vnode to determine if a znode_t was for a zvol of zpl object. With the removal of vnodes this was replaced by the flag zp->z_is_zvol. This flag was used to control the append behavior for range locks. Unfortunately, this value was never properly initialized after the vnode removal. However, because most of memory is usually zeros it happened to be set correctly most of the time making the bug appear racy. Properly initializing zp->z_is_zvol to zero completely resolves the problem with O_APPEND. Closes #126
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/zfs_znode.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
index 0bb9c09e5..87e3a367c 100644
--- a/module/zfs/zfs_znode.c
+++ b/module/zfs/zfs_znode.c
@@ -347,6 +347,7 @@ zfs_znode_alloc(zfs_sb_t *zsb, dmu_buf_t *db, int blksz,
zp->z_blksz = blksz;
zp->z_seq = 0x7A4653;
zp->z_sync_cnt = 0;
+ zp->z_is_zvol = 0;
zfs_znode_sa_init(zsb, zp, db, obj_type, hdl);