]> git.hungrycats.org Git - linux/commitdiff
- make i_mmap and i_mmap_shared a list.h list
authorIngo Molnar <mingo@elte.hu>
Thu, 21 Feb 2002 19:32:48 +0000 (20:32 +0100)
committerIngo Molnar <mingo@elte.hu>
Thu, 21 Feb 2002 19:32:48 +0000 (20:32 +0100)
-
 make vma->vm_next_share and vma->vm_pprev_share
  a proper list.h list as well.

drivers/mtd/devices/blkmtd.c
fs/inode.c
fs/locks.c
include/linux/fs.h
include/linux/mm.h
kernel/fork.c
mm/filemap.c
mm/memory.c
mm/mmap.c
mm/shmem.c

index c681ca82c08b82cf76120506ef73660bf5b33ed9..bca24bfea3c1f0468f8af5d12be9228244ffbeb4 100644 (file)
@@ -989,8 +989,8 @@ static int __init init_blkmtd(void)
   rawdevice->as.nrpages = 0;
   rawdevice->as.a_ops = &blkmtd_aops;
   rawdevice->as.host = inode;
-  rawdevice->as.i_mmap = NULL;
-  rawdevice->as.i_mmap_shared = NULL;
+  INIT_LIST_HEAD(&rawdevice->as.i_mmap);
+  INIT_LIST_HEAD(&rawdevice->as.i_mmap_shared);
   spin_lock_init(&rawdevice->as.i_shared_lock);
   rawdevice->as.gfp_mask = GFP_KERNEL;
   rawdevice->file = file;
index 4b7a35f9cd4ffdd0458c3b46be5e7538fb738556..2c0852cbeaf6d35f92c87cee8f2f62e48685c191 100644 (file)
@@ -144,6 +144,8 @@ void inode_init_once(struct inode *inode)
        INIT_LIST_HEAD(&inode->i_devices);
        sema_init(&inode->i_sem, 1);
        spin_lock_init(&inode->i_data.i_shared_lock);
+       INIT_LIST_HEAD(&inode->i_data.i_mmap);
+       INIT_LIST_HEAD(&inode->i_data.i_mmap_shared);
 }
 
 static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
index 2c6d2d30540c9a8f40fa40188bf18f034f2a251a..cf03f55e317cf0fac71f00cd3ccc3b3f655ad2c1 100644 (file)
@@ -1459,7 +1459,7 @@ int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l)
            (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) {
                struct address_space *mapping = inode->i_mapping;
 
-               if (mapping->i_mmap_shared != NULL) {
+               if (!list_empty(&mapping->i_mmap_shared)) {
                        error = -EAGAIN;
                        goto out_putf;
                }
@@ -1615,7 +1615,7 @@ int fcntl_setlk64(unsigned int fd, unsigned int cmd, struct flock64 *l)
            (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) {
                struct address_space *mapping = inode->i_mapping;
 
-               if (mapping->i_mmap_shared != NULL) {
+               if (!list_empty(&mapping->i_mmap_shared)) {
                        error = -EAGAIN;
                        goto out_putf;
                }
index 1411debc77dc8dd9e42c5288667efb1007ec1e2e..7bb0610ba3a68268ed1a26d22d19d175dc49a120 100644 (file)
@@ -377,8 +377,8 @@ struct address_space {
        unsigned long           nrpages;        /* number of total pages */
        struct address_space_operations *a_ops; /* methods */
        struct inode            *host;          /* owner: inode, block_device */
-       struct vm_area_struct   *i_mmap;        /* list of private mappings */
-       struct vm_area_struct   *i_mmap_shared; /* list of shared mappings */
+       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 */
        int                     gfp_mask;       /* how to allocate the pages */
 };
index 6599c710fd37eff6e7cd423bf714b3ccc9ea16d5..d823fe4a9e56cd1a3f8cfde03cb915ef38476ada 100644 (file)
@@ -61,8 +61,7 @@ struct vm_area_struct {
         * one of the address_space->i_mmap{,shared} lists,
         * for shm areas, the list of attaches, otherwise unused.
         */
-       struct vm_area_struct *vm_next_share;
-       struct vm_area_struct **vm_pprev_share;
+       list_t shared;
 
        /* Function pointers to deal with this struct. */
        struct vm_operations_struct * vm_ops;
index 2d13c18afe2513e1271ae388adf36deaed8e48d1..2f3f7301236f2f76490b507fe5a0ca67640d06b2 100644 (file)
@@ -219,11 +219,7 @@ static inline int dup_mmap(struct mm_struct * mm)
       
                        /* insert tmp into the share list, just after mpnt */
                        spin_lock(&inode->i_mapping->i_shared_lock);
-                       if((tmp->vm_next_share = mpnt->vm_next_share) != NULL)
-                               mpnt->vm_next_share->vm_pprev_share =
-                                       &tmp->vm_next_share;
-                       mpnt->vm_next_share = tmp;
-                       tmp->vm_pprev_share = &mpnt->vm_next_share;
+                       list_add_tail(&tmp->shared, &mpnt->shared);
                        spin_unlock(&inode->i_mapping->i_shared_lock);
                }
 
index 5475203736471a9b850aee2f2cd9702d5dd6e0c1..5cfcbc0e3b89b17235d835570a5cf3a3a28e6c11 100644 (file)
@@ -1399,7 +1399,7 @@ page_ok:
                 * virtual addresses, take care about potential aliasing
                 * before reading the page on the kernel side.
                 */
-               if (mapping->i_mmap_shared != NULL)
+               if (!list_empty(&mapping->i_mmap_shared))
                        flush_dcache_page(page);
 
                /*
index a7ecc422dd1a835467680f3e7caa61b15fc1c6fd..3a7a1a7a72e53b1fe6f42ffc6c12dfc9d056268f 100644 (file)
@@ -1032,31 +1032,35 @@ no_mem:
        return -1;
 }
 
-static void vmtruncate_list(struct vm_area_struct *mpnt, unsigned long pgoff)
+static void vmtruncate_list(list_t *head, unsigned long pgoff)
 {
-       do {
-               unsigned long start = mpnt->vm_start;
-               unsigned long end = mpnt->vm_end;
-               unsigned long len = end - start;
-               unsigned long diff;
+       unsigned long start, end, len, diff;
+       struct vm_area_struct *vma;
+       list_t *curr;
+
+       list_for_each(curr, head) {
+               vma = list_entry(curr, struct vm_area_struct, shared);
+               start = vma->vm_start;
+               end = vma->vm_end;
+               len = end - start;
 
                /* mapping wholly truncated? */
-               if (mpnt->vm_pgoff >= pgoff) {
-                       zap_page_range(mpnt, start, len);
+               if (vma->vm_pgoff >= pgoff) {
+                       zap_page_range(vma, start, len);
                        continue;
                }
 
                /* mapping wholly unaffected? */
                len = len >> PAGE_SHIFT;
-               diff = pgoff - mpnt->vm_pgoff;
+               diff = pgoff - vma->vm_pgoff;
                if (diff >= len)
                        continue;
 
                /* Ok, partially affected.. */
                start += diff << PAGE_SHIFT;
                len = (len - diff) << PAGE_SHIFT;
-               zap_page_range(mpnt, start, len);
-       } while ((mpnt = mpnt->vm_next_share) != NULL);
+               zap_page_range(vma, start, len);
+       }
 }
 
 /*
@@ -1077,14 +1081,14 @@ int vmtruncate(struct inode * inode, loff_t offset)
                goto do_expand;
        inode->i_size = offset;
        spin_lock(&mapping->i_shared_lock);
-       if (!mapping->i_mmap && !mapping->i_mmap_shared)
+       if (list_empty(&mapping->i_mmap) && list_empty(&mapping->i_mmap_shared))
                goto out_unlock;
 
        pgoff = (offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
-       if (mapping->i_mmap != NULL)
-               vmtruncate_list(mapping->i_mmap, pgoff);
-       if (mapping->i_mmap_shared != NULL)
-               vmtruncate_list(mapping->i_mmap_shared, pgoff);
+       if (!list_empty(&mapping->i_mmap))
+               vmtruncate_list(&mapping->i_mmap, pgoff);
+       if (!list_empty(&mapping->i_mmap_shared))
+               vmtruncate_list(&mapping->i_mmap_shared, pgoff);
 
 out_unlock:
        spin_unlock(&mapping->i_shared_lock);
index 32ef6f6c95cd124291e7a4cf231981cd2b12f99b..e39aff25951dec1b41c92d3c4f1ff267e7110f42 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -101,9 +101,7 @@ static inline void __remove_shared_vm_struct(struct vm_area_struct *vma)
                struct inode *inode = file->f_dentry->d_inode;
                if (vma->vm_flags & VM_DENYWRITE)
                        atomic_inc(&inode->i_writecount);
-               if(vma->vm_next_share)
-                       vma->vm_next_share->vm_pprev_share = vma->vm_pprev_share;
-               *vma->vm_pprev_share = vma->vm_next_share;
+               list_del_init(&vma->shared);
        }
 }
 
@@ -308,20 +306,14 @@ static inline void __vma_link_file(struct vm_area_struct * vma)
        if (file) {
                struct inode * inode = file->f_dentry->d_inode;
                struct address_space *mapping = inode->i_mapping;
-               struct vm_area_struct **head;
 
                if (vma->vm_flags & VM_DENYWRITE)
                        atomic_dec(&inode->i_writecount);
 
-               head = &mapping->i_mmap;
                if (vma->vm_flags & VM_SHARED)
-                       head = &mapping->i_mmap_shared;
-      
-               /* insert vma into inode's share list */
-               if((vma->vm_next_share = *head) != NULL)
-                       (*head)->vm_pprev_share = &vma->vm_next_share;
-               *head = vma;
-               vma->vm_pprev_share = head;
+                       list_add_tail(&vma->shared, &mapping->i_mmap_shared);
+               else
+                       list_add_tail(&vma->shared, &mapping->i_mmap);
        }
 }
 
index 6df8566f9dbb4e6fc9cc3a8a8687f2409a7a5c54..a1a2bdbc0401fd1c947fdbf7659b80a846d8e02b 100644 (file)
@@ -904,7 +904,7 @@ static void do_shmem_file_read(struct file * filp, loff_t *ppos, read_descriptor
                if ((desc->error = shmem_getpage(inode, index, &page)))
                        break;
 
-               if (mapping->i_mmap_shared != NULL)
+               if (!list_empty(&mapping->i_mmap_shared))
                        flush_dcache_page(page);
 
                /*