- 论坛徽章:
- 0
|
本人菜鸟,最近在看内核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
|
|