aliyun / ossfs

Export s3fs for aliyun oss.
GNU General Public License v2.0
738 stars 152 forks source link

使用rsync/scp在拷贝大文件(200MB)时会报错 #26

Closed rockuw closed 8 years ago

rockuw commented 8 years ago
root@iZ23qc6ioeeZ:/tmp# rsync -avSH /root/file.200m /tmp/ossfs/
sending incremental file list
file.200m
rsync: write failed on "/tmp/ossfs/file.200m": Operation not permitted (1)
rsync error: error in file IO (code 11) at receiver.c(389) [receiver=3.1.0]
root@iZ23qc6ioeeZ:/tmp# dd if=/dev/zero of=/root/file.10m bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.0103612 s, 1.0 GB/s
root@iZ23qc6ioeeZ:/tmp# rsync -avSH /root/file.10m /tmp/ossfs/
sending incremental file list
file.10m

sent 10,488,407 bytes  received 35 bytes  20,976,884.00 bytes/sec
total size is 10,485,760  speedup is 1.00
  1. 使用cp就不会有问题
  2. rsync小一点的文件也不会有问题
rockuw commented 8 years ago

原因找到了,ossfs有一个bug,当truncate一个空文件为非空的长度时,会报错。

复现的步骤如下:

touch /tmp/ossfs/empty-file
truncate /tmp/ossfs/empty-file 1024 # will return -1 (Operation not permitted)

Fix见 #27

rockuw commented 8 years ago

另外建议使用rsync的时候用--inplace参数:http://www.baldnerd.com/preventing-rsync-from-doubling-or-even-tripling-your-s3-fees/

rockuw commented 8 years ago

上面的实验中对于10M的文件不报错是因为/tmp/ossfs/下面已经有这个文件了,实际上即使拷贝10MB的文件也是会报错的:

root@iZ23qc6ioeeZ:/tmp# rsync -avSH /root/file.10m /tmp/ossfs/
sending incremental file list
file.10m
rsync: write failed on "/tmp/ossfs/file.10m": Operation not permitted (1)
rsync error: error in file IO (code 11) at receiver.c(389) [receiver=3.1.0]
hryang commented 8 years ago

赞!反馈给s3fs吧。

rockuw commented 8 years ago

v1.79.8 https://github.com/aliyun/ossfs/releases/tag/v1.79.8