- 论坛徽章:
- 16
|
本帖最后由 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;
红色部分为什么要再次进行检查,没看懂哦! |
|