Comments (3)
Well, who knew you can make files with both lseek()+write() holey, and using ftruncate(+offset) to "extend".
Simple test code;
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd;
char buffer[64*1024];
int i;
unlink("/BOOM/test");
fd = open("/BOOM/test", O_RDWR|O_TRUNC|O_CREAT, 0600);
if (fd < 0) exit(0);
strcpy(buffer, "Hello world\n");
for (i = 1; i < 10; i++) {
ftruncate(fd, (off_t)i*(rand()%10000));
if (write(fd, buffer, sizeof(buffer)) != sizeof(buffer))
perror("write");
}
close(fd);
exit(0);
}
Will generally panic. Note the unlink()
before open()
appears to be required, if open truncates the file (O_TRUNC) the bug does not appear to happen. So it requires the creation of the file to trigger.
from zfs.
Ok, buffer growth on OSX is like
512 10240 20480 30208 ...
and because that is not a power-of-two size, the dn_datablkshift
variable is set to 0, and the code containing the panic is triggered.
Compared to Linux ZOL, the buffer grows
512 10240 65536 131072
You can see only the first growth is a non-power-of-two.
This boils down to that OSX has all calls to zfs_grow_blocksize()
from zfs_extend()
. This blocksize grower algorithm is poor indeed.
But on Linux, only the first growth (10240) is triggered from zfs_extend()
. All other come from
zfs_write()
's
if (rl->r_len == UINT64_MAX) {
uint64_t new_blksz;
if (zp->z_blksz > max_blksz) {
ASSERT(!ISP2(zp->z_blksz));
new_blksz = MIN(end_size, SPA_MAXBLOCKSIZE);
} else {
new_blksz = MIN(end_size, max_blksz);
}
}
For some reason, Linux's first call will have rl->r_len == UINT64_MAX
but on OSX this never triggers, as rl->r_len == 65536
Now, once the OSX problem has been tracked down, I would guess that with a carefully crafted recordsize (avoiding power of 2) and using extend, all ZFS versions can be made to panic, due to zfs_extend
's poor blocksize growth logic.
from zfs.
In the end, zfs_rlock_write will signal that a blocksize growth is required by setting r_len
to UINT64_MAX
, this was missing on OSX due to ZOL/ZSB usage. Once ported over, the problem goes away.
It is interesting to note that zfs_extend
growth, which is not in power of 2, is undesirable and can possibly still trigger the soft panic. Perhaps zfs_extend
blocksize growing should be encouraged to be in power of 2.
fsx
and fstorture
now work without panic. (although, mmap is still at times, incorrect)
from zfs.
Related Issues (20)
- diskutil erase ZFS shows -69832: file system formatter failed HOT 1
- Error "no pools available to import" in Big Sur x86_64
- Unexpectedly low performance of VMs with openzfsonosx backing store HOT 2
- Xcode not happy with ZFS HOT 14
- Photos cannot import photos to library on zfs HOT 5
- _zfs_findernotify_callback panic HOT 1
- Kernel Panic - OpenZFS 2.1.0 on Apple Silicon HOT 11
- Kernel Panic (Time Out) - OpenZFS 2.1.0 on Apple Silicon HOT 20
- Kernal Panic - 2.1.x arm64 HOT 16
- Kernel Panic: Kernel Data Abort (OpenZFS 2.1.0, M1 Ultra) HOT 15
- how can i create block dev as on linux HOT 1
- 2.1.99: `zsysctl` sets tunable incorrectly HOT 2
- Launchd: no pools available to import HOT 3
- Kernel Panic: OpenZFS 2.1.0 Catalina HOT 1
- System freezes with command: zpool offline
- System restarts with command: zpool export
- System freezes or reboots importing a degraded mirror image HOT 52
- System freezes on import HOT 1
- Mac ZFS triggers duplicating finding programs to fail randomly HOT 9
- `cargo build` breaks with "resource temporarily unavailable (error 35)" (I'm assuming EAGAIN) on v2.2.0 and v2.2.2 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zfs.