Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 当ZFS能够';不提供未损坏的数据?_Unix_Error Handling_Solaris_Zfs - Fatal编程技术网

Unix 当ZFS能够';不提供未损坏的数据?

Unix 当ZFS能够';不提供未损坏的数据?,unix,error-handling,solaris,zfs,Unix,Error Handling,Solaris,Zfs,假设我的程序尝试读取ZFS文件系统上文件中的一个字节。ZFS可以找到所需数据块的副本,但无法找到任何具有有效校验和的副本(它们都已损坏,或者只有存在的磁盘具有损坏的副本)。从读取的返回值和试图读取的字节来看,我的程序看到了什么?有没有一种方法可以影响行为(在Solaris或任何其他ZFS实现操作系统的情况下),即强制失败或强制成功,以及潜在的损坏数据?在特定于文件系统的低级数据救援实用程序之外,从read()返回除EIO错误以外的任何内容有何意义 低级数据救援实用程序需要使用特定于OS和FS的A

假设我的程序尝试读取ZFS文件系统上文件中的一个字节。ZFS可以找到所需数据块的副本,但无法找到任何具有有效校验和的副本(它们都已损坏,或者只有存在的磁盘具有损坏的副本)。从读取的返回值和试图读取的字节来看,我的程序看到了什么?有没有一种方法可以影响行为(在Solaris或任何其他ZFS实现操作系统的情况下),即强制失败或强制成功,以及潜在的损坏数据?

在特定于文件系统的低级数据救援实用程序之外,从
read()
返回除
EIO
错误以外的任何内容有何意义


低级数据救援实用程序需要使用特定于OS和FS的API而不是open/read/write/close to来访问文件。它所需要的语义与读取普通文件有根本的不同,因此它需要一个专门的API。

EIO确实是当前ZFS实现的唯一答案

打开的ZFS“错误”要求以某种方式读取损坏的数据:

我相信这已经可以使用无文档但开源的zdb实用程序实现。
查看有关如何使用zdb-R选项和“R”标志转储文件内容的说明。

Solaris 10:

# Create a test pool
[root@tesalia z]# cd /tmp
[root@tesalia tmp]# mkfile 100M zz
[root@tesalia tmp]# zpool create prueba /tmp/zz

# Fill the pool
[root@tesalia /]# dd if=/dev/zero of=/prueba/dummy_file
dd: writing to `/prueba/dummy_file': No space left on device
129537+0 records in
129536+0 records out
66322432 bytes (66 MB) copied, 1.6093 s, 41.2 MB/s

# Umount the pool
[root@tesalia /]# zpool export prueba

# Corrupt the pool on purpose
[root@tesalia /]# dd if=/dev/urandom of=/tmp/zz seek=100000 count=1 conv=notrunc
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0715209 s, 7.2 kB/s

# Mount the pool again
zpool import -d /tmp prueba

# Try to read the corrupted data
[root@tesalia tmp]# md5sum /prueba/dummy_file 
md5sum: /prueba/dummy_file: I/O error

# Read the manual
[root@tesalia tmp]# man -s2 read
[...]
RETURN VALUES
     Upon successful completion,  read()  and  readv()  return  a
     non-negative integer indicating the number of bytes actually
     read. Otherwise, the functions return -1 and  set  errno  to
     indicate the error.

ERRORS
     The read(), readv(), and pread() functions will fail if:
[...]
     EIO        A physical I/O error has occurred, [...]
您必须导出/导入测试池,因为如果不导出,直接覆盖(池损坏)将丢失,因为文件仍将缓存在操作系统内存中


不,目前ZFS将拒绝向您提供损坏的数据。应该如此。

任何提供自身纠错功能的设备都可能需要在剩下的任何地方出现裂缝(第2部分),而某些形式的数据(如MPEG)可以从有限的错误中恢复,而不会对最终用户体验造成重大影响。(一个1位的错误可能不会被注意到,但如果电影播放结束,你肯定会注意到。)+1对于ndim的回答,它不能是任何东西,除了
EIO
。因此,您的问题可能是:如何获取已读取但未写入
read()
)的原始、未更正和损坏的数据?此块甚至可能有多个版本,所有版本都以不同方式出错。我希望您必须深入挖掘文件系统代码才能将这些代码挖掘出来。。。