Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2002-02-21 20:32:48 +0100
committerIngo Molnar <mingo@elte.hu>2002-02-21 20:32:48 +0100
commitb585ca3ef9bff4621ee9371d5fd9ed833666d359 (patch)
treed73c013ee29a4719d187e055e6b5ec16ad64ae35
parent6d22c10f784087b9c980448d6e8af0b175bad2e4 (diff)
- make i_mmap and i_mmap_shared a list.h list
- make vma->vm_next_share and vma->vm_pprev_share a proper list.h list as well.
-rw-r--r--drivers/mtd/devices/blkmtd.c4
-rw-r--r--fs/inode.c2
-rw-r--r--fs/locks.c4
-rw-r--r--include/linux/fs.h4
-rw-r--r--include/linux/mm.h3
-rw-r--r--kernel/fork.c6
-rw-r--r--mm/filemap.c2
-rw-r--r--mm/memory.c36
-rw-r--r--mm/mmap.c16
-rw-r--r--mm/shmem.c2
10 files changed, 36 insertions, 43 deletions
diff --git a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c
index c681ca82c08b..bca24bfea3c1 100644
--- a/drivers/mtd/devices/blkmtd.c
+++ b/drivers/mtd/devices/blkmtd.c
@@ -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;
diff --git a/fs/inode.c b/fs/inode.c
index 4b7a35f9cd4f..2c0852cbeaf6 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -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)
diff --git a/fs/locks.c b/fs/locks.c
index 2c6d2d30540c..cf03f55e317c 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -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;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1411debc77dc..7bb0610ba3a6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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 */
};
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6599c710fd37..d823fe4a9e56 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -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;
diff --git a/kernel/fork.c b/kernel/fork.c
index 2d13c18afe25..2f3f7301236f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -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);
}
diff --git a/mm/filemap.c b/mm/filemap.c
index 547520373647..5cfcbc0e3b89 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -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);
/*
diff --git a/mm/memory.c b/mm/memory.c
index a7ecc422dd1a..3a7a1a7a72e5 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -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);
diff --git a/mm/mmap.c b/mm/mmap.c
index 32ef6f6c95cd..e39aff25951d 100644
--- 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);
}
}
diff --git a/mm/shmem.c b/mm/shmem.c
index 6df8566f9dbb..a1a2bdbc0401 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -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);
/*