1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
--- sys/contrib/openzfs/module/zfs/zfs_vnops.c.orig
+++ sys/contrib/openzfs/module/zfs/zfs_vnops.c
@@ -316,7 +316,7 @@
int
zfs_write(znode_t *zp, uio_t *uio, int ioflag, cred_t *cr)
{
- int error = 0;
+ int error = 0, error1;
ssize_t start_resid = uio->uio_resid;
/*
@@ -551,7 +551,11 @@
continue;
}
#endif
- if (error != 0) {
+ /*
+ * On FreeBSD, EFAULT should be propagated back to the
+ * VFS, which will handle faulting and will retry.
+ */
+ if (error != 0 && error != EFAULT) {
dmu_tx_commit(tx);
break;
}
@@ -635,7 +639,7 @@
while ((end_size = zp->z_size) < uio->uio_loffset) {
(void) atomic_cas_64(&zp->z_size, end_size,
uio->uio_loffset);
- ASSERT(error == 0);
+ ASSERT(error == 0 || error == EFAULT);
}
/*
* If we are replaying and eof is non zero then force
@@ -645,7 +649,10 @@
if (zfsvfs->z_replay && zfsvfs->z_replay_eof != 0)
zp->z_size = zfsvfs->z_replay_eof;
- error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
+ error1 = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
+ if (error1 != 0)
+ /* Avoid clobbering EFAULT. */
+ error = error1;
zfs_log_write(zilog, tx, TX_WRITE, zp, woff, tx_bytes, ioflag,
NULL, NULL);
|