Re: page->mapping and page->buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Haijin Yan wrote:
> 
> Hi,
>   when I was reading linux MM, I noticed the concept of page cache, buffer
> cache, and swap cache. I am confused about the followings:
> 
>   page->mapping points to the inode's address space(i_mapping), or NULL if
> it is anonymous page. so is this the concept of page cache? No global page
> cache but each inode has a page cache?
> 
>  what is the meaning of page->buffers?

IIRC, it points to the list of buffer heads describing the disk
location of the data resident in the page. Buffer heads are the
structs used to schedule traditional (read()/write()) disk
I/O, whereas page->mapping is used for mmap() I/O. So a
"buffer" is just a logical block of data within a page
that correponds to a physical disk block somewhere; and
the buffer head is a description of that relationship. In the
older 2.4 kernels, they were complimentary: when a mmap()ed page
had to be written out, the VM created buffers describing the page
and then handed those buffers off to the disk I/O subsystem. I'm
not sure if things work the same now. (Probably so.)

> In page_launder() it was checked to
> under different context for different purpose, can someone kindly points
> how many cases are there and what they stand for?

I don't know which version of the code you're looking at, but
basically what's going on is that if the page has buffers and
needs to be written out, page_launder() can hand it to disk I/O
immediately; if no buffers, it must create them before the
page can be written out. If the page is clean and has buffers,
we need to destroy them before reclaiming the page (which is
done either in page_launder or in reclaim_page in 2.4.<=5).
 
>  In linux 2.4, document said buffer cache and page cache are unified,
> where can I find evident in src code?

I think that's what I was referring to above - all I/O is
handled by the disk buffer mechanism; there's no special-case
code for doing I/O on pagecache pages.
 
Cheers,

-- Joe
  "I'd rather chew my leg off than maintain Java code, which
   sucks, 'cause I have a lot of Java code to maintain and
   the leg surgery is starting to get expensive." - Me
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux