Re: page->mapping and page->buffers

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

 



On Mon, Sep 09, 2002 at 02:04:28PM -0600, Joseph A. Knapka wrote:
> 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.)

Each page in page cache belongs to an inode or is anonymous. But
page_launder() writes the pages out independently of what they belong
to. So it one cache. Mappings are there so page_launder knows where to
write the page (it calls down to writepage method in mapping).

With buffers, IIRC it's still the same way. When a page has to be
written to disk, it's turned into buffers and these are queued for disk
write.

> > 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.

Each mapping that can ever have a dirty page has a writepage method.
This method is called from page_launder and it must either create and
schedule buffers for the page, or clean it up by other means (network
filesystems send a network request and no buffers are ever created).

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
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