免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1401 | 回复: 1
打印 上一主题 下一主题

[内核入门] 请教零拷贝recvfile patch [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-09-05 14:41 |只看该作者 |倒序浏览
本人菜鸟,最近在看内核sendfile的实现,好奇有没有“recvfile”实现,
查资料发现可以通过pipe中转,用两次splice实现,
后来无意间发现这个帖子,给出了个实现recvfile的部分核心代码,
不过三楼回帖说有这个实现很nasty(请忽略Camel case...)并且有风险

http://www.gossamer-threads.com/lists/linux/kernel/1751496

他说的问题主要是:

So, we are nesting up to 32 page locks here. That's bad. And we are
nesting kmap() calls for all the pages individually - is that even
safe to do?
   
So, what happens when we've got 16 pages in, and the filesystem has
allocated space for those 16 blocks, and we get ENOSPC on the 17th?
Sure, you undo the state here, but what about the 16 blocks that the
filesystem has allocated to this file? There's no notification to
the filesystem that they need to be truncated away because the write
failed....

想请教高手:
1,kmap多次使用会有什么问题?
2,同时写多个page cache页面,中途出错会造成什么问题,况且这个实现有去做kunmap和write_end


论坛徽章:
0
2 [报告]
发表于 2014-09-06 14:18 |只看该作者
关于第二点个人猜测:
可能是基于这样一个考虑,当文件传输接受方突然检测到错误(例如connection fail)它可以确认自己到底flush多少offset到disk并返回,这样就可以支持断点续传应用。
欢迎拍砖啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP