aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/Makefile3
-rw-r--r--mm/backing-dev.c69
-rw-r--r--mm/filemap.c85
-rw-r--r--mm/memory.c1
-rw-r--r--mm/oom_kill.c1
-rw-r--r--mm/page-writeback.c17
-rw-r--r--mm/page_alloc.c21
-rw-r--r--mm/rmap.c36
-rw-r--r--mm/shmem.c84
-rw-r--r--mm/truncate.c1
-rw-r--r--mm/vmalloc.c7
-rw-r--r--mm/vmscan.c12
12 files changed, 277 insertions, 60 deletions
diff --git a/mm/Makefile b/mm/Makefile
index 12b3a4eee88d..f3c077eb0b8e 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -10,7 +10,8 @@ mmu-$(CONFIG_MMU) := fremap.o highmem.o madvise.o memory.o mincore.o \
10obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \ 10obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
11 page_alloc.o page-writeback.o pdflush.o \ 11 page_alloc.o page-writeback.o pdflush.o \
12 readahead.o swap.o truncate.o vmscan.o \ 12 readahead.o swap.o truncate.o vmscan.o \
13 prio_tree.o util.o mmzone.o vmstat.o $(mmu-y) 13 prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
14 $(mmu-y)
14 15
15ifeq ($(CONFIG_MMU)$(CONFIG_BLOCK),yy) 16ifeq ($(CONFIG_MMU)$(CONFIG_BLOCK),yy)
16obj-y += bounce.o 17obj-y += bounce.o
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
new file mode 100644
index 000000000000..f50a2811f9dc
--- /dev/null
+++ b/mm/backing-dev.c
@@ -0,0 +1,69 @@
1
2#include <linux/wait.h>
3#include <linux/backing-dev.h>
4#include <linux/fs.h>
5#include <linux/sched.h>
6#include <linux/module.h>
7
8static wait_queue_head_t congestion_wqh[2] = {
9 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
10 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
11 };
12
13
14void clear_bdi_congested(struct backing_dev_info *bdi, int rw)
15{
16 enum bdi_state bit;
17 wait_queue_head_t *wqh = &congestion_wqh[rw];
18
19 bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
20 clear_bit(bit, &bdi->state);
21 smp_mb__after_clear_bit();
22 if (waitqueue_active(wqh))
23 wake_up(wqh);
24}
25EXPORT_SYMBOL(clear_bdi_congested);
26
27void set_bdi_congested(struct backing_dev_info *bdi, int rw)
28{
29 enum bdi_state bit;
30
31 bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
32 set_bit(bit, &bdi->state);
33}
34EXPORT_SYMBOL(set_bdi_congested);
35
36/**
37 * congestion_wait - wait for a backing_dev to become uncongested
38 * @rw: READ or WRITE
39 * @timeout: timeout in jiffies
40 *
41 * Waits for up to @timeout jiffies for a backing_dev (any backing_dev) to exit
42 * write congestion. If no backing_devs are congested then just wait for the
43 * next write to be completed.
44 */
45long congestion_wait(int rw, long timeout)
46{
47 long ret;
48 DEFINE_WAIT(wait);
49 wait_queue_head_t *wqh = &congestion_wqh[rw];
50
51 prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
52 ret = io_schedule_timeout(timeout);
53 finish_wait(wqh, &wait);
54 return ret;
55}
56EXPORT_SYMBOL(congestion_wait);
57
58/**
59 * congestion_end - wake up sleepers on a congested backing_dev_info
60 * @rw: READ or WRITE
61 */
62void congestion_end(int rw)
63{
64 wait_queue_head_t *wqh = &congestion_wqh[rw];
65
66 if (waitqueue_active(wqh))
67 wake_up(wqh);
68}
69EXPORT_SYMBOL(congestion_end);
diff --git a/mm/filemap.c b/mm/filemap.c
index 3464b681f844..cb26e33fd0ff 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -75,8 +75,8 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
75 * ->mmap_sem 75 * ->mmap_sem
76 * ->lock_page (access_process_vm) 76 * ->lock_page (access_process_vm)
77 * 77 *
78 * ->mmap_sem 78 * ->i_mutex (generic_file_buffered_write)
79 * ->i_mutex (msync) 79 * ->mmap_sem (fault_in_pages_readable->do_page_fault)
80 * 80 *
81 * ->i_mutex 81 * ->i_mutex
82 * ->i_alloc_sem (various) 82 * ->i_alloc_sem (various)
@@ -1884,11 +1884,10 @@ repeat:
1884 * if suid or (sgid and xgrp) 1884 * if suid or (sgid and xgrp)
1885 * remove privs 1885 * remove privs
1886 */ 1886 */
1887int remove_suid(struct dentry *dentry) 1887int should_remove_suid(struct dentry *dentry)
1888{ 1888{
1889 mode_t mode = dentry->d_inode->i_mode; 1889 mode_t mode = dentry->d_inode->i_mode;
1890 int kill = 0; 1890 int kill = 0;
1891 int result = 0;
1892 1891
1893 /* suid always must be killed */ 1892 /* suid always must be killed */
1894 if (unlikely(mode & S_ISUID)) 1893 if (unlikely(mode & S_ISUID))
@@ -1901,13 +1900,28 @@ int remove_suid(struct dentry *dentry)
1901 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) 1900 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
1902 kill |= ATTR_KILL_SGID; 1901 kill |= ATTR_KILL_SGID;
1903 1902
1904 if (unlikely(kill && !capable(CAP_FSETID))) { 1903 if (unlikely(kill && !capable(CAP_FSETID)))
1905 struct iattr newattrs; 1904 return kill;
1906 1905
1907 newattrs.ia_valid = ATTR_FORCE | kill; 1906 return 0;
1908 result = notify_change(dentry, &newattrs); 1907}
1909 } 1908
1910 return result; 1909int __remove_suid(struct dentry *dentry, int kill)
1910{
1911 struct iattr newattrs;
1912
1913 newattrs.ia_valid = ATTR_FORCE | kill;
1914 return notify_change(dentry, &newattrs);
1915}
1916
1917int remove_suid(struct dentry *dentry)
1918{
1919 int kill = should_remove_suid(dentry);
1920
1921 if (unlikely(kill))
1922 return __remove_suid(dentry, kill);
1923
1924 return 0;
1911} 1925}
1912EXPORT_SYMBOL(remove_suid); 1926EXPORT_SYMBOL(remove_suid);
1913 1927
@@ -2222,7 +2236,7 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2222 unsigned long nr_segs, loff_t *ppos) 2236 unsigned long nr_segs, loff_t *ppos)
2223{ 2237{
2224 struct file *file = iocb->ki_filp; 2238 struct file *file = iocb->ki_filp;
2225 const struct address_space * mapping = file->f_mapping; 2239 struct address_space * mapping = file->f_mapping;
2226 size_t ocount; /* original count */ 2240 size_t ocount; /* original count */
2227 size_t count; /* after file limit checks */ 2241 size_t count; /* after file limit checks */
2228 struct inode *inode = mapping->host; 2242 struct inode *inode = mapping->host;
@@ -2275,8 +2289,11 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2275 2289
2276 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ 2290 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
2277 if (unlikely(file->f_flags & O_DIRECT)) { 2291 if (unlikely(file->f_flags & O_DIRECT)) {
2278 written = generic_file_direct_write(iocb, iov, 2292 loff_t endbyte;
2279 &nr_segs, pos, ppos, count, ocount); 2293 ssize_t written_buffered;
2294
2295 written = generic_file_direct_write(iocb, iov, &nr_segs, pos,
2296 ppos, count, ocount);
2280 if (written < 0 || written == count) 2297 if (written < 0 || written == count)
2281 goto out; 2298 goto out;
2282 /* 2299 /*
@@ -2285,10 +2302,46 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2285 */ 2302 */
2286 pos += written; 2303 pos += written;
2287 count -= written; 2304 count -= written;
2288 } 2305 written_buffered = generic_file_buffered_write(iocb, iov,
2306 nr_segs, pos, ppos, count,
2307 written);
2308 /*
2309 * If generic_file_buffered_write() retuned a synchronous error
2310 * then we want to return the number of bytes which were
2311 * direct-written, or the error code if that was zero. Note
2312 * that this differs from normal direct-io semantics, which
2313 * will return -EFOO even if some bytes were written.
2314 */
2315 if (written_buffered < 0) {
2316 err = written_buffered;
2317 goto out;
2318 }
2289 2319
2290 written = generic_file_buffered_write(iocb, iov, nr_segs, 2320 /*
2291 pos, ppos, count, written); 2321 * We need to ensure that the page cache pages are written to
2322 * disk and invalidated to preserve the expected O_DIRECT
2323 * semantics.
2324 */
2325 endbyte = pos + written_buffered - written - 1;
2326 err = do_sync_file_range(file, pos, endbyte,
2327 SYNC_FILE_RANGE_WAIT_BEFORE|
2328 SYNC_FILE_RANGE_WRITE|
2329 SYNC_FILE_RANGE_WAIT_AFTER);
2330 if (err == 0) {
2331 written = written_buffered;
2332 invalidate_mapping_pages(mapping,
2333 pos >> PAGE_CACHE_SHIFT,
2334 endbyte >> PAGE_CACHE_SHIFT);
2335 } else {
2336 /*
2337 * We don't know how much we wrote, so just return
2338 * the number of bytes which were direct-written
2339 */
2340 }
2341 } else {
2342 written = generic_file_buffered_write(iocb, iov, nr_segs,
2343 pos, ppos, count, written);
2344 }
2292out: 2345out:
2293 current->backing_dev_info = NULL; 2346 current->backing_dev_info = NULL;
2294 return written ? written : err; 2347 return written ? written : err;
diff --git a/mm/memory.c b/mm/memory.c
index b5a4aadd961a..156861fcac43 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1452,6 +1452,7 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
1452 if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE)) 1452 if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE))
1453 memset(kaddr, 0, PAGE_SIZE); 1453 memset(kaddr, 0, PAGE_SIZE);
1454 kunmap_atomic(kaddr, KM_USER0); 1454 kunmap_atomic(kaddr, KM_USER0);
1455 flush_dcache_page(dst);
1455 return; 1456 return;
1456 1457
1457 } 1458 }
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 20f41b082e16..2e3ce3a928b9 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -15,6 +15,7 @@
15 * kernel subsystems and hints as to where to find out what things do. 15 * kernel subsystems and hints as to where to find out what things do.
16 */ 16 */
17 17
18#include <linux/oom.h>
18#include <linux/mm.h> 19#include <linux/mm.h>
19#include <linux/sched.h> 20#include <linux/sched.h>
20#include <linux/swap.h> 21#include <linux/swap.h>
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index a0f339057449..8d9b19f239c3 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -222,7 +222,7 @@ static void balance_dirty_pages(struct address_space *mapping)
222 if (pages_written >= write_chunk) 222 if (pages_written >= write_chunk)
223 break; /* We've done our duty */ 223 break; /* We've done our duty */
224 } 224 }
225 blk_congestion_wait(WRITE, HZ/10); 225 congestion_wait(WRITE, HZ/10);
226 } 226 }
227 227
228 if (nr_reclaimable + global_page_state(NR_WRITEBACK) 228 if (nr_reclaimable + global_page_state(NR_WRITEBACK)
@@ -314,7 +314,7 @@ void throttle_vm_writeout(void)
314 if (global_page_state(NR_UNSTABLE_NFS) + 314 if (global_page_state(NR_UNSTABLE_NFS) +
315 global_page_state(NR_WRITEBACK) <= dirty_thresh) 315 global_page_state(NR_WRITEBACK) <= dirty_thresh)
316 break; 316 break;
317 blk_congestion_wait(WRITE, HZ/10); 317 congestion_wait(WRITE, HZ/10);
318 } 318 }
319} 319}
320 320
@@ -351,7 +351,7 @@ static void background_writeout(unsigned long _min_pages)
351 min_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write; 351 min_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write;
352 if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) { 352 if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) {
353 /* Wrote less than expected */ 353 /* Wrote less than expected */
354 blk_congestion_wait(WRITE, HZ/10); 354 congestion_wait(WRITE, HZ/10);
355 if (!wbc.encountered_congestion) 355 if (!wbc.encountered_congestion)
356 break; 356 break;
357 } 357 }
@@ -422,7 +422,7 @@ static void wb_kupdate(unsigned long arg)
422 writeback_inodes(&wbc); 422 writeback_inodes(&wbc);
423 if (wbc.nr_to_write > 0) { 423 if (wbc.nr_to_write > 0) {
424 if (wbc.encountered_congestion) 424 if (wbc.encountered_congestion)
425 blk_congestion_wait(WRITE, HZ/10); 425 congestion_wait(WRITE, HZ/10);
426 else 426 else
427 break; /* All the old data is written */ 427 break; /* All the old data is written */
428 } 428 }
@@ -956,15 +956,6 @@ int test_set_page_writeback(struct page *page)
956EXPORT_SYMBOL(test_set_page_writeback); 956EXPORT_SYMBOL(test_set_page_writeback);
957 957
958/* 958/*
959 * Wakes up tasks that are being throttled due to writeback congestion
960 */
961void writeback_congestion_end(void)
962{
963 blk_congestion_end(WRITE);
964}
965EXPORT_SYMBOL(writeback_congestion_end);
966
967/*
968 * Return true if any of the pages in the mapping are marged with the 959 * Return true if any of the pages in the mapping are marged with the
969 * passed tag. 960 * passed tag.
970 */ 961 */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 40db96a655d0..ebd425c2e2a7 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -39,6 +39,7 @@
39#include <linux/stop_machine.h> 39#include <linux/stop_machine.h>
40#include <linux/sort.h> 40#include <linux/sort.h>
41#include <linux/pfn.h> 41#include <linux/pfn.h>
42#include <linux/backing-dev.h>
42 43
43#include <asm/tlbflush.h> 44#include <asm/tlbflush.h>
44#include <asm/div64.h> 45#include <asm/div64.h>
@@ -1050,7 +1051,7 @@ nofail_alloc:
1050 if (page) 1051 if (page)
1051 goto got_pg; 1052 goto got_pg;
1052 if (gfp_mask & __GFP_NOFAIL) { 1053 if (gfp_mask & __GFP_NOFAIL) {
1053 blk_congestion_wait(WRITE, HZ/50); 1054 congestion_wait(WRITE, HZ/50);
1054 goto nofail_alloc; 1055 goto nofail_alloc;
1055 } 1056 }
1056 } 1057 }
@@ -1113,7 +1114,7 @@ rebalance:
1113 do_retry = 1; 1114 do_retry = 1;
1114 } 1115 }
1115 if (do_retry) { 1116 if (do_retry) {
1116 blk_congestion_wait(WRITE, HZ/50); 1117 congestion_wait(WRITE, HZ/50);
1117 goto rebalance; 1118 goto rebalance;
1118 } 1119 }
1119 1120
@@ -3119,3 +3120,19 @@ unsigned long page_to_pfn(struct page *page)
3119EXPORT_SYMBOL(pfn_to_page); 3120EXPORT_SYMBOL(pfn_to_page);
3120EXPORT_SYMBOL(page_to_pfn); 3121EXPORT_SYMBOL(page_to_pfn);
3121#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */ 3122#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */
3123
3124#if MAX_NUMNODES > 1
3125/*
3126 * Find the highest possible node id.
3127 */
3128int highest_possible_node_id(void)
3129{
3130 unsigned int node;
3131 unsigned int highest = 0;
3132
3133 for_each_node_mask(node, node_possible_map)
3134 highest = node;
3135 return highest;
3136}
3137EXPORT_SYMBOL(highest_possible_node_id);
3138#endif
diff --git a/mm/rmap.c b/mm/rmap.c
index a9136d8b7577..d8a842a586db 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -21,27 +21,21 @@
21 * Lock ordering in mm: 21 * Lock ordering in mm:
22 * 22 *
23 * inode->i_mutex (while writing or truncating, not reading or faulting) 23 * inode->i_mutex (while writing or truncating, not reading or faulting)
24 * inode->i_alloc_sem 24 * inode->i_alloc_sem (vmtruncate_range)
25 * 25 * mm->mmap_sem
26 * When a page fault occurs in writing from user to file, down_read 26 * page->flags PG_locked (lock_page)
27 * of mmap_sem nests within i_mutex; in sys_msync, i_mutex nests within 27 * mapping->i_mmap_lock
28 * down_read of mmap_sem; i_mutex and down_write of mmap_sem are never 28 * anon_vma->lock
29 * taken together; in truncation, i_mutex is taken outermost. 29 * mm->page_table_lock or pte_lock
30 * 30 * zone->lru_lock (in mark_page_accessed, isolate_lru_page)
31 * mm->mmap_sem 31 * swap_lock (in swap_duplicate, swap_info_get)
32 * page->flags PG_locked (lock_page) 32 * mmlist_lock (in mmput, drain_mmlist and others)
33 * mapping->i_mmap_lock 33 * mapping->private_lock (in __set_page_dirty_buffers)
34 * anon_vma->lock 34 * inode_lock (in set_page_dirty's __mark_inode_dirty)
35 * mm->page_table_lock or pte_lock 35 * sb_lock (within inode_lock in fs/fs-writeback.c)
36 * zone->lru_lock (in mark_page_accessed, isolate_lru_page) 36 * mapping->tree_lock (widely used, in set_page_dirty,
37 * swap_lock (in swap_duplicate, swap_info_get) 37 * in arch-dependent flush_dcache_mmap_lock,
38 * mmlist_lock (in mmput, drain_mmlist and others) 38 * within inode_lock in __sync_single_inode)
39 * mapping->private_lock (in __set_page_dirty_buffers)
40 * inode_lock (in set_page_dirty's __mark_inode_dirty)
41 * sb_lock (within inode_lock in fs/fs-writeback.c)
42 * mapping->tree_lock (widely used, in set_page_dirty,
43 * in arch-dependent flush_dcache_mmap_lock,
44 * within inode_lock in __sync_single_inode)
45 */ 39 */
46 40
47#include <linux/mm.h> 41#include <linux/mm.h>
diff --git a/mm/shmem.c b/mm/shmem.c
index bb8ca7ef7094..4959535fc14c 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -48,6 +48,7 @@
48#include <linux/ctype.h> 48#include <linux/ctype.h>
49#include <linux/migrate.h> 49#include <linux/migrate.h>
50#include <linux/highmem.h> 50#include <linux/highmem.h>
51#include <linux/backing-dev.h>
51 52
52#include <asm/uaccess.h> 53#include <asm/uaccess.h>
53#include <asm/div64.h> 54#include <asm/div64.h>
@@ -1131,7 +1132,7 @@ repeat:
1131 page_cache_release(swappage); 1132 page_cache_release(swappage);
1132 if (error == -ENOMEM) { 1133 if (error == -ENOMEM) {
1133 /* let kswapd refresh zone for GFP_ATOMICs */ 1134 /* let kswapd refresh zone for GFP_ATOMICs */
1134 blk_congestion_wait(WRITE, HZ/50); 1135 congestion_wait(WRITE, HZ/50);
1135 } 1136 }
1136 goto repeat; 1137 goto repeat;
1137 } 1138 }
@@ -1362,6 +1363,7 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1362 inode->i_mapping->a_ops = &shmem_aops; 1363 inode->i_mapping->a_ops = &shmem_aops;
1363 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info; 1364 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
1364 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1365 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
1366 inode->i_generation = get_seconds();
1365 info = SHMEM_I(inode); 1367 info = SHMEM_I(inode);
1366 memset(info, 0, (char *)inode - (char *)info); 1368 memset(info, 0, (char *)inode - (char *)info);
1367 spin_lock_init(&info->lock); 1369 spin_lock_init(&info->lock);
@@ -1956,6 +1958,85 @@ static struct xattr_handler *shmem_xattr_handlers[] = {
1956}; 1958};
1957#endif 1959#endif
1958 1960
1961static struct dentry *shmem_get_parent(struct dentry *child)
1962{
1963 return ERR_PTR(-ESTALE);
1964}
1965
1966static int shmem_match(struct inode *ino, void *vfh)
1967{
1968 __u32 *fh = vfh;
1969 __u64 inum = fh[2];
1970 inum = (inum << 32) | fh[1];
1971 return ino->i_ino == inum && fh[0] == ino->i_generation;
1972}
1973
1974static struct dentry *shmem_get_dentry(struct super_block *sb, void *vfh)
1975{
1976 struct dentry *de = NULL;
1977 struct inode *inode;
1978 __u32 *fh = vfh;
1979 __u64 inum = fh[2];
1980 inum = (inum << 32) | fh[1];
1981
1982 inode = ilookup5(sb, (unsigned long)(inum+fh[0]), shmem_match, vfh);
1983 if (inode) {
1984 de = d_find_alias(inode);
1985 iput(inode);
1986 }
1987
1988 return de? de: ERR_PTR(-ESTALE);
1989}
1990
1991static struct dentry *shmem_decode_fh(struct super_block *sb, __u32 *fh,
1992 int len, int type,
1993 int (*acceptable)(void *context, struct dentry *de),
1994 void *context)
1995{
1996 if (len < 3)
1997 return ERR_PTR(-ESTALE);
1998
1999 return sb->s_export_op->find_exported_dentry(sb, fh, NULL, acceptable,
2000 context);
2001}
2002
2003static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
2004 int connectable)
2005{
2006 struct inode *inode = dentry->d_inode;
2007
2008 if (*len < 3)
2009 return 255;
2010
2011 if (hlist_unhashed(&inode->i_hash)) {
2012 /* Unfortunately insert_inode_hash is not idempotent,
2013 * so as we hash inodes here rather than at creation
2014 * time, we need a lock to ensure we only try
2015 * to do it once
2016 */
2017 static DEFINE_SPINLOCK(lock);
2018 spin_lock(&lock);
2019 if (hlist_unhashed(&inode->i_hash))
2020 __insert_inode_hash(inode,
2021 inode->i_ino + inode->i_generation);
2022 spin_unlock(&lock);
2023 }
2024
2025 fh[0] = inode->i_generation;
2026 fh[1] = inode->i_ino;
2027 fh[2] = ((__u64)inode->i_ino) >> 32;
2028
2029 *len = 3;
2030 return 1;
2031}
2032
2033static struct export_operations shmem_export_ops = {
2034 .get_parent = shmem_get_parent,
2035 .get_dentry = shmem_get_dentry,
2036 .encode_fh = shmem_encode_fh,
2037 .decode_fh = shmem_decode_fh,
2038};
2039
1959static int shmem_parse_options(char *options, int *mode, uid_t *uid, 2040static int shmem_parse_options(char *options, int *mode, uid_t *uid,
1960 gid_t *gid, unsigned long *blocks, unsigned long *inodes, 2041 gid_t *gid, unsigned long *blocks, unsigned long *inodes,
1961 int *policy, nodemask_t *policy_nodes) 2042 int *policy, nodemask_t *policy_nodes)
@@ -2128,6 +2209,7 @@ static int shmem_fill_super(struct super_block *sb,
2128 &inodes, &policy, &policy_nodes)) 2209 &inodes, &policy, &policy_nodes))
2129 return -EINVAL; 2210 return -EINVAL;
2130 } 2211 }
2212 sb->s_export_op = &shmem_export_ops;
2131#else 2213#else
2132 sb->s_flags |= MS_NOUSER; 2214 sb->s_flags |= MS_NOUSER;
2133#endif 2215#endif
diff --git a/mm/truncate.c b/mm/truncate.c
index 11ca480701dd..e07b1e682c38 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -96,7 +96,6 @@ invalidate_complete_page(struct address_space *mapping, struct page *page)
96 return 0; 96 return 0;
97 97
98 ret = remove_mapping(mapping, page); 98 ret = remove_mapping(mapping, page);
99 ClearPageUptodate(page);
100 99
101 return ret; 100 return ret;
102} 101}
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 750ab6ed13fc..1133dd3aafcf 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -428,8 +428,11 @@ void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
428 if (array_size > PAGE_SIZE) { 428 if (array_size > PAGE_SIZE) {
429 pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node); 429 pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node);
430 area->flags |= VM_VPAGES; 430 area->flags |= VM_VPAGES;
431 } else 431 } else {
432 pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node); 432 pages = kmalloc_node(array_size,
433 (gfp_mask & ~(__GFP_HIGHMEM | __GFP_ZERO)),
434 node);
435 }
433 area->pages = pages; 436 area->pages = pages;
434 if (!area->pages) { 437 if (!area->pages) {
435 remove_vm_area(area->addr); 438 remove_vm_area(area->addr);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index eca70310adb2..f05527bf792b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -378,6 +378,12 @@ static pageout_t pageout(struct page *page, struct address_space *mapping)
378 return PAGE_CLEAN; 378 return PAGE_CLEAN;
379} 379}
380 380
381/*
382 * Attempt to detach a locked page from its ->mapping. If it is dirty or if
383 * someone else has a ref on the page, abort and return 0. If it was
384 * successfully detached, return 1. Assumes the caller has a single ref on
385 * this page.
386 */
381int remove_mapping(struct address_space *mapping, struct page *page) 387int remove_mapping(struct address_space *mapping, struct page *page)
382{ 388{
383 BUG_ON(!PageLocked(page)); 389 BUG_ON(!PageLocked(page));
@@ -1053,7 +1059,7 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
1053 1059
1054 /* Take a nap, wait for some writeback to complete */ 1060 /* Take a nap, wait for some writeback to complete */
1055 if (sc.nr_scanned && priority < DEF_PRIORITY - 2) 1061 if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
1056 blk_congestion_wait(WRITE, HZ/10); 1062 congestion_wait(WRITE, HZ/10);
1057 } 1063 }
1058 /* top priority shrink_caches still had more to do? don't OOM, then */ 1064 /* top priority shrink_caches still had more to do? don't OOM, then */
1059 if (!sc.all_unreclaimable) 1065 if (!sc.all_unreclaimable)
@@ -1208,7 +1214,7 @@ scan:
1208 * another pass across the zones. 1214 * another pass across the zones.
1209 */ 1215 */
1210 if (total_scanned && priority < DEF_PRIORITY - 2) 1216 if (total_scanned && priority < DEF_PRIORITY - 2)
1211 blk_congestion_wait(WRITE, HZ/10); 1217 congestion_wait(WRITE, HZ/10);
1212 1218
1213 /* 1219 /*
1214 * We do this so kswapd doesn't build up large priorities for 1220 * We do this so kswapd doesn't build up large priorities for
@@ -1452,7 +1458,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
1452 goto out; 1458 goto out;
1453 1459
1454 if (sc.nr_scanned && prio < DEF_PRIORITY - 2) 1460 if (sc.nr_scanned && prio < DEF_PRIORITY - 2)
1455 blk_congestion_wait(WRITE, HZ / 10); 1461 congestion_wait(WRITE, HZ / 10);
1456 } 1462 }
1457 1463
1458 lru_pages = 0; 1464 lru_pages = 0;