linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Buffer Head Doubts
@ 2002-09-03  9:11 Anil Kumar
  2002-09-03 18:17 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Anil Kumar @ 2002-09-03  9:11 UTC (permalink / raw)
  To: linux-mm

Hello All,

  I am going through the source code of linux kernel 2.5.32 and have some 
 simple doubts.
 
1:What is  the philosophy behind introducing Address Space concept 
  

struct address_space{

        struct inode            *host;          /* owner: inode,  
block_device */
        struct radix_tree_root  page_tree;      /* radix tree of all pages
*/   
        rwlock_t                page_lock;      /* and rwlock protecting
it */
        struct list_head        clean_pages;    /* list of clean pages */
        struct list_head        dirty_pages;    /* list of dirty pages */
        struct list_head        locked_pages;   /* list of locked pages */
        struct list_head        io_pages;       /* being prepared for I/O
*/
        unsigned long           nrpages;        /* number of total pages
*/
        struct address_space_operations *a_ops; /* methods */
        list_t                  i_mmap;         /* list of private
mappings */
        list_t                  i_mmap_shared;  /* list of private
mappings */
        spinlock_t              i_shared_lock;  /* and spinlock protecting
it */
        unsigned long           dirtied_when;   /* jiffies of first page
dirtying */
        int                     gfp_mask;       /* how to allocate the
pages */
        struct backing_dev_info *backing_dev_info; /* device readahead,
etc */
        spinlock_t               private_lock;   /* for use by the
address_space*/
        struct list_head        private_list;   /* ditto */
        struct address_space    *assoc_mapping; /* ditto */
};

   What is meaning of  field assoc_mapping,private_lock  ?
 
2: In buffer head structure

struct buffer_head {
        /* First cache line: */
        unsigned long b_state;          /* buffer state bitmap (see above)
*/
        atomic_t b_count;               /* users using this block */
        struct buffer_head *b_this_page;/* circular list of page's buffers
*/
        struct page *b_page;            /* the page this bh is mapped to
*/

        sector_t b_blocknr;             /* block number */
        u32 b_size;                     /* block size */
        char *b_data;                   /* pointer to data block */

        struct block_device *b_bdev;
        bh_end_io_t *b_end_io;          /* I/O completion */
        void *b_private;                /* reserved for b_end_io */
        struct list_head b_assoc_buffers; /* associated with another
mapping */
};

  What is this b_assoc_buffers and where used ?

3: In file buffer.c  before function definition  buffer_busy
comment is given about  try_to_free_buffers

/*
 * try_to_free_buffers() checks if all the buffers on this particular page
 * are unused, and releases them if so.
 *
 * Exclusion against try_to_free_buffers may be obtained by either
 * locking the page or by holding its mapping's private_lock.
 *
 * If the page is dirty but all the buffers are clean then we need to
 * be sure to mark the page clean as well.  This is because the page
 * may be against a block device, and a later reattachment of buffers
 * to a dirty page will set *all* buffers dirty.  Which would corrupt
 * filesystem data on the same device.
 *
 * The same applies to regular filesystem pages: if all the buffers are
 * clean then we set the page clean and proceed.  To do that, we require
 * total exclusion from __set_page_dirty_buffers().  That is obtained with
 * private_lock.
 *
 * try_to_free_buffers() is non-blocking.
 */

 I can not understand what exactly this comment  means ?

and also why  code segment (between Line  /*--------*/ is there)
in following code.

int try_to_free_buffers(struct page *page)
{
        struct address_space * const mapping = page->mapping;
        struct buffer_head *buffers_to_free = NULL;
        int ret = 0;

        BUG_ON(!PageLocked(page));
        if (PageWriteback(page))
                return 0;
/*----------------------------------------------------------------------*/
        if (mapping == NULL) {          /* swapped-in anon page */
                ret = drop_buffers(page, &buffers_to_free);
                goto out;
        }
/*------------------------------------------------------------------------*/

        spin_lock(&mapping->private_lock);
        ret = drop_buffers(page, &buffers_to_free);
        if (ret && !PageSwapCache(page)) {

...


  If mapping is NULL then why we need to drop_buffers in that case.How can
buffer head be associated with an anonymous page ?

Regards,
Anil


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-09-03 18:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-03  9:11 Buffer Head Doubts Anil Kumar
2002-09-03 18:17 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox