Skip to content

Instantly share code, notes, and snippets.

diff --git a/module/zfs/zio.c b/module/zfs/zio.c
index 8f8d86f..be3f97b 100644
--- a/module/zfs/zio.c
+++ b/module/zfs/zio.c
@@ -263,7 +263,10 @@ zio_buf_alloc(size_t size)
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT;
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
-
+#ifdef _KERNEL
diff --git a/module/zfs/zio.c b/module/zfs/zio.c
index 97f2549..05a8749 100644
--- a/module/zfs/zio.c
+++ b/module/zfs/zio.c
@@ -263,7 +263,17 @@ zio_buf_alloc(size_t size)
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT;
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
-
+#ifdef _KERNEL
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#define FIELD_SIZE (1024*1024)
(gdb) bt
#0 0x000000000047cb6b in refcount_is_zero (rc=rc@entry=0xcb3bc8) at ../../module/zfs/refcount.c:107
#1 0x00000000004911d0 in spa_config_held (spa=spa@entry=0xcb2b70, locks=locks@entry=22, rw=rw@entry=0) at ../../module/zfs/spa_misc.c:397
#2 0x00000000004c1f8c in zio_create (pio=pio@entry=0x7f3e2f41c020, spa=0xcb2b70, txg=944, bp=bp@entry=0x0, data=0x7f3e2f41c600, size=512, done=done@entry=0x4a6950 <vdev_raidz_child_done>,
private=private@entry=0x7f3e2f41c440, type=type@entry=ZIO_TYPE_WRITE, priority=priority@entry=ZIO_PRIORITY_ASYNC_WRITE,
flags=(ZIO_FLAG_IO_REPAIR | ZIO_FLAG_RESILVER | ZIO_FLAG_SCAN_THREAD | ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_PROPAGATE), vd=vd@entry=0xcf2130, offset=2546176,
zb=zb@entry=0x7f3e2f41c020, stage=stage@entry=ZIO_STAGE_READY, pipeline=(ZIO_STAGE_VDEV_IO_START | ZIO_STAGE_VDEV_IO_DONE | ZIO_STAGE_VDEV_IO_ASSESS | ZIO_STAGE_DONE))
at ../../module/zfs/zio.c:576
#3 0x00000000004c38e2 in zio_vdev_child_io (pio=pio@entry=0x7f3e2f41c020
diff --git a/include/sys/zio.h b/include/sys/zio.h
index e10e965..0ba6b65 100644
--- a/include/sys/zio.h
+++ b/include/sys/zio.h
@@ -383,6 +383,7 @@ typedef struct zio_link {
} zio_link_t;
struct zio {
+ int io_hold;
/* Core information about this I/O */
diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c
index 9be69b5..1238fcd 100644
--- a/module/zfs/dbuf.c
+++ b/module/zfs/dbuf.c
@@ -1763,8 +1763,13 @@ dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid,
ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock));
ASSERT(dn->dn_type != DMU_OT_NONE);
-
+#ifdef _KERNEL
diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
index 0c0091f..1655c7e 100644
--- a/module/zfs/zfs_znode.c
+++ b/module/zfs/zfs_znode.c
@@ -950,6 +950,7 @@ again:
mutex_exit(&zp->z_lock);
sa_buf_rele(db, NULL);
ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
+ cond_resched();
goto again;
diff --git a/module/zfs/vdev_raidz.c b/module/zfs/vdev_raidz.c
index fcb2e2f..4604cf7 100644
--- a/module/zfs/vdev_raidz.c
+++ b/module/zfs/vdev_raidz.c
@@ -618,12 +618,14 @@ vdev_raidz_p_func(const void *buf, uint64_t size, void *private)
{
struct pqr_struct *pqr = private;
const uint64_t *src = buf;
+ uint64_t *p = pqr->p;
int i, cnt = size / sizeof (src[0]);
diff --git a/include/sys/taskq.h b/include/sys/taskq.h
index a43a86d..6d3e6d6 100644
--- a/include/sys/taskq.h
+++ b/include/sys/taskq.h
@@ -124,7 +124,7 @@ extern void taskq_wait_id(taskq_t *, taskqid_t);
extern void taskq_wait_outstanding(taskq_t *, taskqid_t);
extern void taskq_wait(taskq_t *);
extern int taskq_cancel_id(taskq_t *, taskqid_t);
-extern int taskq_member(taskq_t *, void *);
+extern int taskq_member(taskq_t *, kthread_t *);
From f3ac39e16ff20b635e7d8773a4a32a357893aa7f Mon Sep 17 00:00:00 2001
From: Chunwei Chen <david.chen@osnexus.com>
Date: Fri, 11 Dec 2015 15:24:34 -0800
Subject: [PATCH] Fix snapshot automount race cause EREMOTE
When a concorrent mount finishes just before calling to
zfsctl_snapshot_ismounted, if we return EISDIR, the VFS will return with
EREMOTE. We should instead just return 0, so VFS may retry and would likely
notice the dentry is alreadly mounted. This will be inline with when usermode
helper return EBUSY.