免费注册 查看新帖 |

Chinaunix

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

[内存管理] file access [复制链接]

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-28 10:36 |只看该作者 |倒序浏览
本帖最后由 embeddedlwp 于 2012-04-28 16:07 编辑

在do_generic_mapping_read函数中:
800readpage:
801                /* Start the actual read. The read will unlock the page. */
802                error = mapping->a_ops->readpage(filp, page);
803
804                if (unlikely(error))
805                        goto readpage_error;
806
807                if (!PageUptodate(page)) {
808                        lock_page(page);
809                        if (!PageUptodate(page)) {
810                                if (page->mapping == NULL) {
811                                        /*
812                                         * invalidate_inode_pages got it
813                                         */
814                                        unlock_page(page);
815                                        page_cache_release(page);
816                                        goto find_page;
817                                }
818                                unlock_page(page);
819                                error = -EIO;
820                                goto readpage_error;
821                        }
822                        unlock_page(page);
823                }
824
825                /*
826                 * i_size must be checked after we have done ->readpage.
827                 *
828                 * Checking i_size after the readpage allows us to calculate
829                 * the correct value for "nr", which means the zero-filled
830                 * part of the page is not copied back to userspace (unless
831                 * another truncate extends the file - this is desired though).
832                 */
833                isize = i_size_read(inode);
834                end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
835                if (unlikely(!isize || index > end_index)) {
836                        page_cache_release(page);
837                        goto out;
838                }
839
840                /* nr is the maximum number of bytes to copy from this page */
841                nr = PAGE_CACHE_SIZE;
842                if (index == end_index) {
843                        nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1;
844                        if (nr <= offset) {
845                                page_cache_release(page);
846                                goto out;
847                        }
848                }
849                nr = nr - offset;
850                goto page_ok;


红色部分为什么要再次进行检查,没看懂哦!

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
2 [报告]
发表于 2012-04-28 16:06 |只看该作者
哦,应该是文件洞的问题!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP