diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-02-27 15:46:16 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-02-27 15:46:16 -0500 |
commit | 691429e13dfaf5b0994b07cc166db41bd608ee3d (patch) | |
tree | bf52870108822c40d9a83d3c402c59d5f15cc6af | |
parent | 1c271479b56da4a8caf5f56a88432d4260e120fe (diff) | |
parent | 7f6d5b529b7dfe2fca30cbf4bc81e16575090025 (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge fixes from Andrew Morton:
"10 fixes"
* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
dax: move writeback calls into the filesystems
dax: give DAX clearing code correct bdev
ext4: online defrag not supported with DAX
ext2, ext4: only set S_DAX for regular inodes
block: disable block device DAX by default
ocfs2: unlock inode if deleting inode from orphan fails
mm: ASLR: use get_random_long()
drivers: char: random: add get_random_long()
mm: numa: quickly fail allocations for NUMA balancing on full nodes
mm: thp: fix SMP race condition between THP page fault and MADV_DONTNEED
-rw-r--r-- | arch/arm/mm/mmap.c | 2 | ||||
-rw-r--r-- | arch/arm64/mm/mmap.c | 4 | ||||
-rw-r--r-- | arch/mips/mm/mmap.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/process.c | 4 | ||||
-rw-r--r-- | arch/powerpc/mm/mmap.c | 4 | ||||
-rw-r--r-- | arch/sparc/kernel/sys_sparc_64.c | 2 | ||||
-rw-r--r-- | arch/x86/mm/mmap.c | 6 | ||||
-rw-r--r-- | block/Kconfig | 13 | ||||
-rw-r--r-- | drivers/char/random.c | 22 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 2 | ||||
-rw-r--r-- | fs/block_dev.c | 19 | ||||
-rw-r--r-- | fs/dax.c | 21 | ||||
-rw-r--r-- | fs/ext2/inode.c | 16 | ||||
-rw-r--r-- | fs/ext4/inode.c | 6 | ||||
-rw-r--r-- | fs/ext4/ioctl.c | 5 | ||||
-rw-r--r-- | fs/ocfs2/aops.c | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_aops.c | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_aops.h | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap_util.c | 3 | ||||
-rw-r--r-- | include/linux/dax.h | 8 | ||||
-rw-r--r-- | include/linux/random.h | 1 | ||||
-rw-r--r-- | mm/filemap.c | 12 | ||||
-rw-r--r-- | mm/memory.c | 14 | ||||
-rw-r--r-- | mm/migrate.c | 2 |
24 files changed, 132 insertions, 46 deletions
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index 4b4058db0781..66353caa35b9 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c | |||
@@ -173,7 +173,7 @@ unsigned long arch_mmap_rnd(void) | |||
173 | { | 173 | { |
174 | unsigned long rnd; | 174 | unsigned long rnd; |
175 | 175 | ||
176 | rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1); | 176 | rnd = get_random_long() & ((1UL << mmap_rnd_bits) - 1); |
177 | 177 | ||
178 | return rnd << PAGE_SHIFT; | 178 | return rnd << PAGE_SHIFT; |
179 | } | 179 | } |
diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c index 4c893b5189dd..232f787a088a 100644 --- a/arch/arm64/mm/mmap.c +++ b/arch/arm64/mm/mmap.c | |||
@@ -53,10 +53,10 @@ unsigned long arch_mmap_rnd(void) | |||
53 | 53 | ||
54 | #ifdef CONFIG_COMPAT | 54 | #ifdef CONFIG_COMPAT |
55 | if (test_thread_flag(TIF_32BIT)) | 55 | if (test_thread_flag(TIF_32BIT)) |
56 | rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_compat_bits) - 1); | 56 | rnd = get_random_long() & ((1UL << mmap_rnd_compat_bits) - 1); |
57 | else | 57 | else |
58 | #endif | 58 | #endif |
59 | rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1); | 59 | rnd = get_random_long() & ((1UL << mmap_rnd_bits) - 1); |
60 | return rnd << PAGE_SHIFT; | 60 | return rnd << PAGE_SHIFT; |
61 | } | 61 | } |
62 | 62 | ||
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c index 5c81fdd032c3..353037699512 100644 --- a/arch/mips/mm/mmap.c +++ b/arch/mips/mm/mmap.c | |||
@@ -146,7 +146,7 @@ unsigned long arch_mmap_rnd(void) | |||
146 | { | 146 | { |
147 | unsigned long rnd; | 147 | unsigned long rnd; |
148 | 148 | ||
149 | rnd = (unsigned long)get_random_int(); | 149 | rnd = get_random_long(); |
150 | rnd <<= PAGE_SHIFT; | 150 | rnd <<= PAGE_SHIFT; |
151 | if (TASK_IS_32BIT_ADDR) | 151 | if (TASK_IS_32BIT_ADDR) |
152 | rnd &= 0xfffffful; | 152 | rnd &= 0xfffffful; |
@@ -174,7 +174,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm) | |||
174 | 174 | ||
175 | static inline unsigned long brk_rnd(void) | 175 | static inline unsigned long brk_rnd(void) |
176 | { | 176 | { |
177 | unsigned long rnd = get_random_int(); | 177 | unsigned long rnd = get_random_long(); |
178 | 178 | ||
179 | rnd = rnd << PAGE_SHIFT; | 179 | rnd = rnd << PAGE_SHIFT; |
180 | /* 8MB for 32bit, 256MB for 64bit */ | 180 | /* 8MB for 32bit, 256MB for 64bit */ |
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index dccc87e8fee5..3c5736e52a14 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
@@ -1768,9 +1768,9 @@ static inline unsigned long brk_rnd(void) | |||
1768 | 1768 | ||
1769 | /* 8MB for 32bit, 1GB for 64bit */ | 1769 | /* 8MB for 32bit, 1GB for 64bit */ |
1770 | if (is_32bit_task()) | 1770 | if (is_32bit_task()) |
1771 | rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT))); | 1771 | rnd = (get_random_long() % (1UL<<(23-PAGE_SHIFT))); |
1772 | else | 1772 | else |
1773 | rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT))); | 1773 | rnd = (get_random_long() % (1UL<<(30-PAGE_SHIFT))); |
1774 | 1774 | ||
1775 | return rnd << PAGE_SHIFT; | 1775 | return rnd << PAGE_SHIFT; |
1776 | } | 1776 | } |
diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 0f0502e12f6c..4087705ba90f 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c | |||
@@ -59,9 +59,9 @@ unsigned long arch_mmap_rnd(void) | |||
59 | 59 | ||
60 | /* 8MB for 32bit, 1GB for 64bit */ | 60 | /* 8MB for 32bit, 1GB for 64bit */ |
61 | if (is_32bit_task()) | 61 | if (is_32bit_task()) |
62 | rnd = (unsigned long)get_random_int() % (1<<(23-PAGE_SHIFT)); | 62 | rnd = get_random_long() % (1<<(23-PAGE_SHIFT)); |
63 | else | 63 | else |
64 | rnd = (unsigned long)get_random_int() % (1<<(30-PAGE_SHIFT)); | 64 | rnd = get_random_long() % (1UL<<(30-PAGE_SHIFT)); |
65 | 65 | ||
66 | return rnd << PAGE_SHIFT; | 66 | return rnd << PAGE_SHIFT; |
67 | } | 67 | } |
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index c690c8e16a96..b489e9759518 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c | |||
@@ -264,7 +264,7 @@ static unsigned long mmap_rnd(void) | |||
264 | unsigned long rnd = 0UL; | 264 | unsigned long rnd = 0UL; |
265 | 265 | ||
266 | if (current->flags & PF_RANDOMIZE) { | 266 | if (current->flags & PF_RANDOMIZE) { |
267 | unsigned long val = get_random_int(); | 267 | unsigned long val = get_random_long(); |
268 | if (test_thread_flag(TIF_32BIT)) | 268 | if (test_thread_flag(TIF_32BIT)) |
269 | rnd = (val % (1UL << (23UL-PAGE_SHIFT))); | 269 | rnd = (val % (1UL << (23UL-PAGE_SHIFT))); |
270 | else | 270 | else |
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c index 96bd1e2bffaf..72bb52f93c3d 100644 --- a/arch/x86/mm/mmap.c +++ b/arch/x86/mm/mmap.c | |||
@@ -71,12 +71,12 @@ unsigned long arch_mmap_rnd(void) | |||
71 | 71 | ||
72 | if (mmap_is_ia32()) | 72 | if (mmap_is_ia32()) |
73 | #ifdef CONFIG_COMPAT | 73 | #ifdef CONFIG_COMPAT |
74 | rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_compat_bits) - 1); | 74 | rnd = get_random_long() & ((1UL << mmap_rnd_compat_bits) - 1); |
75 | #else | 75 | #else |
76 | rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1); | 76 | rnd = get_random_long() & ((1UL << mmap_rnd_bits) - 1); |
77 | #endif | 77 | #endif |
78 | else | 78 | else |
79 | rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1); | 79 | rnd = get_random_long() & ((1UL << mmap_rnd_bits) - 1); |
80 | 80 | ||
81 | return rnd << PAGE_SHIFT; | 81 | return rnd << PAGE_SHIFT; |
82 | } | 82 | } |
diff --git a/block/Kconfig b/block/Kconfig index 161491d0a879..0363cd731320 100644 --- a/block/Kconfig +++ b/block/Kconfig | |||
@@ -88,6 +88,19 @@ config BLK_DEV_INTEGRITY | |||
88 | T10/SCSI Data Integrity Field or the T13/ATA External Path | 88 | T10/SCSI Data Integrity Field or the T13/ATA External Path |
89 | Protection. If in doubt, say N. | 89 | Protection. If in doubt, say N. |
90 | 90 | ||
91 | config BLK_DEV_DAX | ||
92 | bool "Block device DAX support" | ||
93 | depends on FS_DAX | ||
94 | depends on BROKEN | ||
95 | help | ||
96 | When DAX support is available (CONFIG_FS_DAX) raw block | ||
97 | devices can also support direct userspace access to the | ||
98 | storage capacity via MMAP(2) similar to a file on a | ||
99 | DAX-enabled filesystem. However, the DAX I/O-path disables | ||
100 | some standard I/O-statistics, and the MMAP(2) path has some | ||
101 | operational differences due to bypassing the page | ||
102 | cache. If in doubt, say N. | ||
103 | |||
91 | config BLK_DEV_THROTTLING | 104 | config BLK_DEV_THROTTLING |
92 | bool "Block layer bio throttling support" | 105 | bool "Block layer bio throttling support" |
93 | depends on BLK_CGROUP=y | 106 | depends on BLK_CGROUP=y |
diff --git a/drivers/char/random.c b/drivers/char/random.c index d0da5d852d41..b583e5336630 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -1819,6 +1819,28 @@ unsigned int get_random_int(void) | |||
1819 | EXPORT_SYMBOL(get_random_int); | 1819 | EXPORT_SYMBOL(get_random_int); |
1820 | 1820 | ||
1821 | /* | 1821 | /* |
1822 | * Same as get_random_int(), but returns unsigned long. | ||
1823 | */ | ||
1824 | unsigned long get_random_long(void) | ||
1825 | { | ||
1826 | __u32 *hash; | ||
1827 | unsigned long ret; | ||
1828 | |||
1829 | if (arch_get_random_long(&ret)) | ||
1830 | return ret; | ||
1831 | |||
1832 | hash = get_cpu_var(get_random_int_hash); | ||
1833 | |||
1834 | hash[0] += current->pid + jiffies + random_get_entropy(); | ||
1835 | md5_transform(hash, random_int_secret); | ||
1836 | ret = *(unsigned long *)hash; | ||
1837 | put_cpu_var(get_random_int_hash); | ||
1838 | |||
1839 | return ret; | ||
1840 | } | ||
1841 | EXPORT_SYMBOL(get_random_long); | ||
1842 | |||
1843 | /* | ||
1822 | * randomize_range() returns a start address such that | 1844 | * randomize_range() returns a start address such that |
1823 | * | 1845 | * |
1824 | * [...... <range> .....] | 1846 | * [...... <range> .....] |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 051ea4809c14..7d914c67a9d0 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -653,7 +653,7 @@ static unsigned long randomize_stack_top(unsigned long stack_top) | |||
653 | 653 | ||
654 | if ((current->flags & PF_RANDOMIZE) && | 654 | if ((current->flags & PF_RANDOMIZE) && |
655 | !(current->personality & ADDR_NO_RANDOMIZE)) { | 655 | !(current->personality & ADDR_NO_RANDOMIZE)) { |
656 | random_variable = (unsigned long) get_random_int(); | 656 | random_variable = get_random_long(); |
657 | random_variable &= STACK_RND_MASK; | 657 | random_variable &= STACK_RND_MASK; |
658 | random_variable <<= PAGE_SHIFT; | 658 | random_variable <<= PAGE_SHIFT; |
659 | } | 659 | } |
diff --git a/fs/block_dev.c b/fs/block_dev.c index 39b3a174a425..826b164a4b5b 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1201,7 +1201,11 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1201 | bdev->bd_disk = disk; | 1201 | bdev->bd_disk = disk; |
1202 | bdev->bd_queue = disk->queue; | 1202 | bdev->bd_queue = disk->queue; |
1203 | bdev->bd_contains = bdev; | 1203 | bdev->bd_contains = bdev; |
1204 | bdev->bd_inode->i_flags = disk->fops->direct_access ? S_DAX : 0; | 1204 | if (IS_ENABLED(CONFIG_BLK_DEV_DAX) && disk->fops->direct_access) |
1205 | bdev->bd_inode->i_flags = S_DAX; | ||
1206 | else | ||
1207 | bdev->bd_inode->i_flags = 0; | ||
1208 | |||
1205 | if (!partno) { | 1209 | if (!partno) { |
1206 | ret = -ENXIO; | 1210 | ret = -ENXIO; |
1207 | bdev->bd_part = disk_get_part(disk, partno); | 1211 | bdev->bd_part = disk_get_part(disk, partno); |
@@ -1693,13 +1697,24 @@ static int blkdev_releasepage(struct page *page, gfp_t wait) | |||
1693 | return try_to_free_buffers(page); | 1697 | return try_to_free_buffers(page); |
1694 | } | 1698 | } |
1695 | 1699 | ||
1700 | static int blkdev_writepages(struct address_space *mapping, | ||
1701 | struct writeback_control *wbc) | ||
1702 | { | ||
1703 | if (dax_mapping(mapping)) { | ||
1704 | struct block_device *bdev = I_BDEV(mapping->host); | ||
1705 | |||
1706 | return dax_writeback_mapping_range(mapping, bdev, wbc); | ||
1707 | } | ||
1708 | return generic_writepages(mapping, wbc); | ||
1709 | } | ||
1710 | |||
1696 | static const struct address_space_operations def_blk_aops = { | 1711 | static const struct address_space_operations def_blk_aops = { |
1697 | .readpage = blkdev_readpage, | 1712 | .readpage = blkdev_readpage, |
1698 | .readpages = blkdev_readpages, | 1713 | .readpages = blkdev_readpages, |
1699 | .writepage = blkdev_writepage, | 1714 | .writepage = blkdev_writepage, |
1700 | .write_begin = blkdev_write_begin, | 1715 | .write_begin = blkdev_write_begin, |
1701 | .write_end = blkdev_write_end, | 1716 | .write_end = blkdev_write_end, |
1702 | .writepages = generic_writepages, | 1717 | .writepages = blkdev_writepages, |
1703 | .releasepage = blkdev_releasepage, | 1718 | .releasepage = blkdev_releasepage, |
1704 | .direct_IO = blkdev_direct_IO, | 1719 | .direct_IO = blkdev_direct_IO, |
1705 | .is_dirty_writeback = buffer_check_dirty_writeback, | 1720 | .is_dirty_writeback = buffer_check_dirty_writeback, |
@@ -79,15 +79,14 @@ struct page *read_dax_sector(struct block_device *bdev, sector_t n) | |||
79 | } | 79 | } |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * dax_clear_blocks() is called from within transaction context from XFS, | 82 | * dax_clear_sectors() is called from within transaction context from XFS, |
83 | * and hence this means the stack from this point must follow GFP_NOFS | 83 | * and hence this means the stack from this point must follow GFP_NOFS |
84 | * semantics for all operations. | 84 | * semantics for all operations. |
85 | */ | 85 | */ |
86 | int dax_clear_blocks(struct inode *inode, sector_t block, long _size) | 86 | int dax_clear_sectors(struct block_device *bdev, sector_t _sector, long _size) |
87 | { | 87 | { |
88 | struct block_device *bdev = inode->i_sb->s_bdev; | ||
89 | struct blk_dax_ctl dax = { | 88 | struct blk_dax_ctl dax = { |
90 | .sector = block << (inode->i_blkbits - 9), | 89 | .sector = _sector, |
91 | .size = _size, | 90 | .size = _size, |
92 | }; | 91 | }; |
93 | 92 | ||
@@ -109,7 +108,7 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long _size) | |||
109 | wmb_pmem(); | 108 | wmb_pmem(); |
110 | return 0; | 109 | return 0; |
111 | } | 110 | } |
112 | EXPORT_SYMBOL_GPL(dax_clear_blocks); | 111 | EXPORT_SYMBOL_GPL(dax_clear_sectors); |
113 | 112 | ||
114 | /* the clear_pmem() calls are ordered by a wmb_pmem() in the caller */ | 113 | /* the clear_pmem() calls are ordered by a wmb_pmem() in the caller */ |
115 | static void dax_new_buf(void __pmem *addr, unsigned size, unsigned first, | 114 | static void dax_new_buf(void __pmem *addr, unsigned size, unsigned first, |
@@ -485,11 +484,10 @@ static int dax_writeback_one(struct block_device *bdev, | |||
485 | * end]. This is required by data integrity operations to ensure file data is | 484 | * end]. This is required by data integrity operations to ensure file data is |
486 | * on persistent storage prior to completion of the operation. | 485 | * on persistent storage prior to completion of the operation. |
487 | */ | 486 | */ |
488 | int dax_writeback_mapping_range(struct address_space *mapping, loff_t start, | 487 | int dax_writeback_mapping_range(struct address_space *mapping, |
489 | loff_t end) | 488 | struct block_device *bdev, struct writeback_control *wbc) |
490 | { | 489 | { |
491 | struct inode *inode = mapping->host; | 490 | struct inode *inode = mapping->host; |
492 | struct block_device *bdev = inode->i_sb->s_bdev; | ||
493 | pgoff_t start_index, end_index, pmd_index; | 491 | pgoff_t start_index, end_index, pmd_index; |
494 | pgoff_t indices[PAGEVEC_SIZE]; | 492 | pgoff_t indices[PAGEVEC_SIZE]; |
495 | struct pagevec pvec; | 493 | struct pagevec pvec; |
@@ -500,8 +498,11 @@ int dax_writeback_mapping_range(struct address_space *mapping, loff_t start, | |||
500 | if (WARN_ON_ONCE(inode->i_blkbits != PAGE_SHIFT)) | 498 | if (WARN_ON_ONCE(inode->i_blkbits != PAGE_SHIFT)) |
501 | return -EIO; | 499 | return -EIO; |
502 | 500 | ||
503 | start_index = start >> PAGE_CACHE_SHIFT; | 501 | if (!mapping->nrexceptional || wbc->sync_mode != WB_SYNC_ALL) |
504 | end_index = end >> PAGE_CACHE_SHIFT; | 502 | return 0; |
503 | |||
504 | start_index = wbc->range_start >> PAGE_CACHE_SHIFT; | ||
505 | end_index = wbc->range_end >> PAGE_CACHE_SHIFT; | ||
505 | pmd_index = DAX_PMD_INDEX(start_index); | 506 | pmd_index = DAX_PMD_INDEX(start_index); |
506 | 507 | ||
507 | rcu_read_lock(); | 508 | rcu_read_lock(); |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 338eefda70c6..6bd58e6ff038 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -737,8 +737,10 @@ static int ext2_get_blocks(struct inode *inode, | |||
737 | * so that it's not found by another thread before it's | 737 | * so that it's not found by another thread before it's |
738 | * initialised | 738 | * initialised |
739 | */ | 739 | */ |
740 | err = dax_clear_blocks(inode, le32_to_cpu(chain[depth-1].key), | 740 | err = dax_clear_sectors(inode->i_sb->s_bdev, |
741 | 1 << inode->i_blkbits); | 741 | le32_to_cpu(chain[depth-1].key) << |
742 | (inode->i_blkbits - 9), | ||
743 | 1 << inode->i_blkbits); | ||
742 | if (err) { | 744 | if (err) { |
743 | mutex_unlock(&ei->truncate_mutex); | 745 | mutex_unlock(&ei->truncate_mutex); |
744 | goto cleanup; | 746 | goto cleanup; |
@@ -874,6 +876,14 @@ ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset) | |||
874 | static int | 876 | static int |
875 | ext2_writepages(struct address_space *mapping, struct writeback_control *wbc) | 877 | ext2_writepages(struct address_space *mapping, struct writeback_control *wbc) |
876 | { | 878 | { |
879 | #ifdef CONFIG_FS_DAX | ||
880 | if (dax_mapping(mapping)) { | ||
881 | return dax_writeback_mapping_range(mapping, | ||
882 | mapping->host->i_sb->s_bdev, | ||
883 | wbc); | ||
884 | } | ||
885 | #endif | ||
886 | |||
877 | return mpage_writepages(mapping, wbc, ext2_get_block); | 887 | return mpage_writepages(mapping, wbc, ext2_get_block); |
878 | } | 888 | } |
879 | 889 | ||
@@ -1296,7 +1306,7 @@ void ext2_set_inode_flags(struct inode *inode) | |||
1296 | inode->i_flags |= S_NOATIME; | 1306 | inode->i_flags |= S_NOATIME; |
1297 | if (flags & EXT2_DIRSYNC_FL) | 1307 | if (flags & EXT2_DIRSYNC_FL) |
1298 | inode->i_flags |= S_DIRSYNC; | 1308 | inode->i_flags |= S_DIRSYNC; |
1299 | if (test_opt(inode->i_sb, DAX)) | 1309 | if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode)) |
1300 | inode->i_flags |= S_DAX; | 1310 | inode->i_flags |= S_DAX; |
1301 | } | 1311 | } |
1302 | 1312 | ||
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 9cc57c3b4661..aee960b1af34 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -2478,6 +2478,10 @@ static int ext4_writepages(struct address_space *mapping, | |||
2478 | 2478 | ||
2479 | trace_ext4_writepages(inode, wbc); | 2479 | trace_ext4_writepages(inode, wbc); |
2480 | 2480 | ||
2481 | if (dax_mapping(mapping)) | ||
2482 | return dax_writeback_mapping_range(mapping, inode->i_sb->s_bdev, | ||
2483 | wbc); | ||
2484 | |||
2481 | /* | 2485 | /* |
2482 | * No pages to write? This is mainly a kludge to avoid starting | 2486 | * No pages to write? This is mainly a kludge to avoid starting |
2483 | * a transaction for special inodes like journal inode on last iput() | 2487 | * a transaction for special inodes like journal inode on last iput() |
@@ -4155,7 +4159,7 @@ void ext4_set_inode_flags(struct inode *inode) | |||
4155 | new_fl |= S_NOATIME; | 4159 | new_fl |= S_NOATIME; |
4156 | if (flags & EXT4_DIRSYNC_FL) | 4160 | if (flags & EXT4_DIRSYNC_FL) |
4157 | new_fl |= S_DIRSYNC; | 4161 | new_fl |= S_DIRSYNC; |
4158 | if (test_opt(inode->i_sb, DAX)) | 4162 | if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode)) |
4159 | new_fl |= S_DAX; | 4163 | new_fl |= S_DAX; |
4160 | inode_set_flags(inode, new_fl, | 4164 | inode_set_flags(inode, new_fl, |
4161 | S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX); | 4165 | S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX); |
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index a99b010e2194..eae5917c534e 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
@@ -583,6 +583,11 @@ group_extend_out: | |||
583 | "Online defrag not supported with bigalloc"); | 583 | "Online defrag not supported with bigalloc"); |
584 | err = -EOPNOTSUPP; | 584 | err = -EOPNOTSUPP; |
585 | goto mext_out; | 585 | goto mext_out; |
586 | } else if (IS_DAX(inode)) { | ||
587 | ext4_msg(sb, KERN_ERR, | ||
588 | "Online defrag not supported with DAX"); | ||
589 | err = -EOPNOTSUPP; | ||
590 | goto mext_out; | ||
586 | } | 591 | } |
587 | 592 | ||
588 | err = mnt_want_write_file(filp); | 593 | err = mnt_want_write_file(filp); |
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 794fd1587f34..cda0361e95a4 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -956,6 +956,7 @@ clean_orphan: | |||
956 | tmp_ret = ocfs2_del_inode_from_orphan(osb, inode, di_bh, | 956 | tmp_ret = ocfs2_del_inode_from_orphan(osb, inode, di_bh, |
957 | update_isize, end); | 957 | update_isize, end); |
958 | if (tmp_ret < 0) { | 958 | if (tmp_ret < 0) { |
959 | ocfs2_inode_unlock(inode, 1); | ||
959 | ret = tmp_ret; | 960 | ret = tmp_ret; |
960 | mlog_errno(ret); | 961 | mlog_errno(ret); |
961 | brelse(di_bh); | 962 | brelse(di_bh); |
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 379c089fb051..a9ebabfe7587 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c | |||
@@ -55,7 +55,7 @@ xfs_count_page_state( | |||
55 | } while ((bh = bh->b_this_page) != head); | 55 | } while ((bh = bh->b_this_page) != head); |
56 | } | 56 | } |
57 | 57 | ||
58 | STATIC struct block_device * | 58 | struct block_device * |
59 | xfs_find_bdev_for_inode( | 59 | xfs_find_bdev_for_inode( |
60 | struct inode *inode) | 60 | struct inode *inode) |
61 | { | 61 | { |
@@ -1208,6 +1208,10 @@ xfs_vm_writepages( | |||
1208 | struct writeback_control *wbc) | 1208 | struct writeback_control *wbc) |
1209 | { | 1209 | { |
1210 | xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); | 1210 | xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); |
1211 | if (dax_mapping(mapping)) | ||
1212 | return dax_writeback_mapping_range(mapping, | ||
1213 | xfs_find_bdev_for_inode(mapping->host), wbc); | ||
1214 | |||
1211 | return generic_writepages(mapping, wbc); | 1215 | return generic_writepages(mapping, wbc); |
1212 | } | 1216 | } |
1213 | 1217 | ||
diff --git a/fs/xfs/xfs_aops.h b/fs/xfs/xfs_aops.h index f6ffc9ae5ceb..a4343c63fb38 100644 --- a/fs/xfs/xfs_aops.h +++ b/fs/xfs/xfs_aops.h | |||
@@ -62,5 +62,6 @@ int xfs_get_blocks_dax_fault(struct inode *inode, sector_t offset, | |||
62 | struct buffer_head *map_bh, int create); | 62 | struct buffer_head *map_bh, int create); |
63 | 63 | ||
64 | extern void xfs_count_page_state(struct page *, int *, int *); | 64 | extern void xfs_count_page_state(struct page *, int *, int *); |
65 | extern struct block_device *xfs_find_bdev_for_inode(struct inode *); | ||
65 | 66 | ||
66 | #endif /* __XFS_AOPS_H__ */ | 67 | #endif /* __XFS_AOPS_H__ */ |
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 45ec9e40150c..6c876012b2e5 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c | |||
@@ -75,7 +75,8 @@ xfs_zero_extent( | |||
75 | ssize_t size = XFS_FSB_TO_B(mp, count_fsb); | 75 | ssize_t size = XFS_FSB_TO_B(mp, count_fsb); |
76 | 76 | ||
77 | if (IS_DAX(VFS_I(ip))) | 77 | if (IS_DAX(VFS_I(ip))) |
78 | return dax_clear_blocks(VFS_I(ip), block, size); | 78 | return dax_clear_sectors(xfs_find_bdev_for_inode(VFS_I(ip)), |
79 | sector, size); | ||
79 | 80 | ||
80 | /* | 81 | /* |
81 | * let the block layer decide on the fastest method of | 82 | * let the block layer decide on the fastest method of |
diff --git a/include/linux/dax.h b/include/linux/dax.h index 818e45078929..636dd59ab505 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h | |||
@@ -7,7 +7,7 @@ | |||
7 | 7 | ||
8 | ssize_t dax_do_io(struct kiocb *, struct inode *, struct iov_iter *, loff_t, | 8 | ssize_t dax_do_io(struct kiocb *, struct inode *, struct iov_iter *, loff_t, |
9 | get_block_t, dio_iodone_t, int flags); | 9 | get_block_t, dio_iodone_t, int flags); |
10 | int dax_clear_blocks(struct inode *, sector_t block, long size); | 10 | int dax_clear_sectors(struct block_device *bdev, sector_t _sector, long _size); |
11 | int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t); | 11 | int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t); |
12 | int dax_truncate_page(struct inode *, loff_t from, get_block_t); | 12 | int dax_truncate_page(struct inode *, loff_t from, get_block_t); |
13 | int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t, | 13 | int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t, |
@@ -52,6 +52,8 @@ static inline bool dax_mapping(struct address_space *mapping) | |||
52 | { | 52 | { |
53 | return mapping->host && IS_DAX(mapping->host); | 53 | return mapping->host && IS_DAX(mapping->host); |
54 | } | 54 | } |
55 | int dax_writeback_mapping_range(struct address_space *mapping, loff_t start, | 55 | |
56 | loff_t end); | 56 | struct writeback_control; |
57 | int dax_writeback_mapping_range(struct address_space *mapping, | ||
58 | struct block_device *bdev, struct writeback_control *wbc); | ||
57 | #endif | 59 | #endif |
diff --git a/include/linux/random.h b/include/linux/random.h index a75840c1aa71..9c29122037f9 100644 --- a/include/linux/random.h +++ b/include/linux/random.h | |||
@@ -34,6 +34,7 @@ extern const struct file_operations random_fops, urandom_fops; | |||
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | unsigned int get_random_int(void); | 36 | unsigned int get_random_int(void); |
37 | unsigned long get_random_long(void); | ||
37 | unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); | 38 | unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); |
38 | 39 | ||
39 | u32 prandom_u32(void); | 40 | u32 prandom_u32(void); |
diff --git a/mm/filemap.c b/mm/filemap.c index 23edccecadb0..3461d97ecb30 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -446,7 +446,8 @@ int filemap_write_and_wait(struct address_space *mapping) | |||
446 | { | 446 | { |
447 | int err = 0; | 447 | int err = 0; |
448 | 448 | ||
449 | if (mapping->nrpages) { | 449 | if ((!dax_mapping(mapping) && mapping->nrpages) || |
450 | (dax_mapping(mapping) && mapping->nrexceptional)) { | ||
450 | err = filemap_fdatawrite(mapping); | 451 | err = filemap_fdatawrite(mapping); |
451 | /* | 452 | /* |
452 | * Even if the above returned error, the pages may be | 453 | * Even if the above returned error, the pages may be |
@@ -482,13 +483,8 @@ int filemap_write_and_wait_range(struct address_space *mapping, | |||
482 | { | 483 | { |
483 | int err = 0; | 484 | int err = 0; |
484 | 485 | ||
485 | if (dax_mapping(mapping) && mapping->nrexceptional) { | 486 | if ((!dax_mapping(mapping) && mapping->nrpages) || |
486 | err = dax_writeback_mapping_range(mapping, lstart, lend); | 487 | (dax_mapping(mapping) && mapping->nrexceptional)) { |
487 | if (err) | ||
488 | return err; | ||
489 | } | ||
490 | |||
491 | if (mapping->nrpages) { | ||
492 | err = __filemap_fdatawrite_range(mapping, lstart, lend, | 488 | err = __filemap_fdatawrite_range(mapping, lstart, lend, |
493 | WB_SYNC_ALL); | 489 | WB_SYNC_ALL); |
494 | /* See comment of filemap_write_and_wait() */ | 490 | /* See comment of filemap_write_and_wait() */ |
diff --git a/mm/memory.c b/mm/memory.c index 635451abc8f7..8132787ae4d5 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -3404,8 +3404,18 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
3404 | if (unlikely(pmd_none(*pmd)) && | 3404 | if (unlikely(pmd_none(*pmd)) && |
3405 | unlikely(__pte_alloc(mm, vma, pmd, address))) | 3405 | unlikely(__pte_alloc(mm, vma, pmd, address))) |
3406 | return VM_FAULT_OOM; | 3406 | return VM_FAULT_OOM; |
3407 | /* if an huge pmd materialized from under us just retry later */ | 3407 | /* |
3408 | if (unlikely(pmd_trans_huge(*pmd) || pmd_devmap(*pmd))) | 3408 | * If a huge pmd materialized under us just retry later. Use |
3409 | * pmd_trans_unstable() instead of pmd_trans_huge() to ensure the pmd | ||
3410 | * didn't become pmd_trans_huge under us and then back to pmd_none, as | ||
3411 | * a result of MADV_DONTNEED running immediately after a huge pmd fault | ||
3412 | * in a different thread of this mm, in turn leading to a misleading | ||
3413 | * pmd_trans_huge() retval. All we have to ensure is that it is a | ||
3414 | * regular pmd that we can walk with pte_offset_map() and we can do that | ||
3415 | * through an atomic read in C, which is what pmd_trans_unstable() | ||
3416 | * provides. | ||
3417 | */ | ||
3418 | if (unlikely(pmd_trans_unstable(pmd) || pmd_devmap(*pmd))) | ||
3409 | return 0; | 3419 | return 0; |
3410 | /* | 3420 | /* |
3411 | * A regular pmd is established and it can't morph into a huge pmd | 3421 | * A regular pmd is established and it can't morph into a huge pmd |
diff --git a/mm/migrate.c b/mm/migrate.c index b1034f9c77e7..3ad0fea5c438 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -1582,7 +1582,7 @@ static struct page *alloc_misplaced_dst_page(struct page *page, | |||
1582 | (GFP_HIGHUSER_MOVABLE | | 1582 | (GFP_HIGHUSER_MOVABLE | |
1583 | __GFP_THISNODE | __GFP_NOMEMALLOC | | 1583 | __GFP_THISNODE | __GFP_NOMEMALLOC | |
1584 | __GFP_NORETRY | __GFP_NOWARN) & | 1584 | __GFP_NORETRY | __GFP_NOWARN) & |
1585 | ~(__GFP_IO | __GFP_FS), 0); | 1585 | ~__GFP_RECLAIM, 0); |
1586 | 1586 | ||
1587 | return newpage; | 1587 | return newpage; |
1588 | } | 1588 | } |