aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 8558732e85c1..7b84dc814347 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -467,25 +467,15 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
467} 467}
468 468
469#ifdef CONFIG_NUMA 469#ifdef CONFIG_NUMA
470struct page *page_cache_alloc(struct address_space *x) 470struct page *__page_cache_alloc(gfp_t gfp)
471{ 471{
472 if (cpuset_do_page_mem_spread()) { 472 if (cpuset_do_page_mem_spread()) {
473 int n = cpuset_mem_spread_node(); 473 int n = cpuset_mem_spread_node();
474 return alloc_pages_node(n, mapping_gfp_mask(x), 0); 474 return alloc_pages_node(n, gfp, 0);
475 } 475 }
476 return alloc_pages(mapping_gfp_mask(x), 0); 476 return alloc_pages(gfp, 0);
477} 477}
478EXPORT_SYMBOL(page_cache_alloc); 478EXPORT_SYMBOL(__page_cache_alloc);
479
480struct page *page_cache_alloc_cold(struct address_space *x)
481{
482 if (cpuset_do_page_mem_spread()) {
483 int n = cpuset_mem_spread_node();
484 return alloc_pages_node(n, mapping_gfp_mask(x)|__GFP_COLD, 0);
485 }
486 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
487}
488EXPORT_SYMBOL(page_cache_alloc_cold);
489#endif 479#endif
490 480
491static int __sleep_on_page_lock(void *word) 481static int __sleep_on_page_lock(void *word)
@@ -826,7 +816,6 @@ struct page *
826grab_cache_page_nowait(struct address_space *mapping, unsigned long index) 816grab_cache_page_nowait(struct address_space *mapping, unsigned long index)
827{ 817{
828 struct page *page = find_get_page(mapping, index); 818 struct page *page = find_get_page(mapping, index);
829 gfp_t gfp_mask;
830 819
831 if (page) { 820 if (page) {
832 if (!TestSetPageLocked(page)) 821 if (!TestSetPageLocked(page))
@@ -834,9 +823,8 @@ grab_cache_page_nowait(struct address_space *mapping, unsigned long index)
834 page_cache_release(page); 823 page_cache_release(page);
835 return NULL; 824 return NULL;
836 } 825 }
837 gfp_mask = mapping_gfp_mask(mapping) & ~__GFP_FS; 826 page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~__GFP_FS);
838 page = alloc_pages(gfp_mask, 0); 827 if (page && add_to_page_cache_lru(page, mapping, index, GFP_KERNEL)) {
839 if (page && add_to_page_cache_lru(page, mapping, index, gfp_mask)) {
840 page_cache_release(page); 828 page_cache_release(page);
841 page = NULL; 829 page = NULL;
842 } 830 }
@@ -1884,11 +1872,10 @@ repeat:
1884 * if suid or (sgid and xgrp) 1872 * if suid or (sgid and xgrp)
1885 * remove privs 1873 * remove privs
1886 */ 1874 */
1887int remove_suid(struct dentry *dentry) 1875int should_remove_suid(struct dentry *dentry)
1888{ 1876{
1889 mode_t mode = dentry->d_inode->i_mode; 1877 mode_t mode = dentry->d_inode->i_mode;
1890 int kill = 0; 1878 int kill = 0;
1891 int result = 0;
1892 1879
1893 /* suid always must be killed */ 1880 /* suid always must be killed */
1894 if (unlikely(mode & S_ISUID)) 1881 if (unlikely(mode & S_ISUID))
@@ -1901,13 +1888,28 @@ int remove_suid(struct dentry *dentry)
1901 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) 1888 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
1902 kill |= ATTR_KILL_SGID; 1889 kill |= ATTR_KILL_SGID;
1903 1890
1904 if (unlikely(kill && !capable(CAP_FSETID))) { 1891 if (unlikely(kill && !capable(CAP_FSETID)))
1905 struct iattr newattrs; 1892 return kill;
1906 1893
1907 newattrs.ia_valid = ATTR_FORCE | kill; 1894 return 0;
1908 result = notify_change(dentry, &newattrs); 1895}
1909 } 1896
1910 return result; 1897int __remove_suid(struct dentry *dentry, int kill)
1898{
1899 struct iattr newattrs;
1900
1901 newattrs.ia_valid = ATTR_FORCE | kill;
1902 return notify_change(dentry, &newattrs);
1903}
1904
1905int remove_suid(struct dentry *dentry)
1906{
1907 int kill = should_remove_suid(dentry);
1908
1909 if (unlikely(kill))
1910 return __remove_suid(dentry, kill);
1911
1912 return 0;
1911} 1913}
1912EXPORT_SYMBOL(remove_suid); 1914EXPORT_SYMBOL(remove_suid);
1913 1915