- 論壇徽章:
- 0
|
本人菜鳥,最近在看內(nèi)核sendfile的實現(xiàn),好奇有沒有“recvfile”實現(xiàn),
查資料發(fā)現(xiàn)可以通過pipe中轉(zhuǎn),用兩次splice實現(xiàn),
后來無意間發(fā)現(xiàn)這個帖子,給出了個實現(xiàn)recvfile的部分核心代碼,
不過三樓回帖說有這個實現(xiàn)很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頁面,中途出錯會造成什么問題,況且這個實現(xiàn)有去做kunmap和write_end
|
|