Commit ed98b01
mm/filemap: fix mapping_seek_hole_data on THP & 32-bit
No problem on 64-bit, or without huge pages, but xfstests generic/285
and other SEEK_HOLE/SEEK_DATA tests have regressed on huge tmpfs, and on
32-bit architectures, with the new mapping_seek_hole_data(). Several
different bugs turned out to need fixing.
u64 cast to stop losing bits when converting unsigned long to loff_t
(and let's use shifts throughout, rather than mixed with * and /).
Use round_up() when advancing pos, to stop assuming that pos was already
THP-aligned when advancing it by THP-size. (This use of round_up()
assumes that any THP has THP-aligned index: true at present and true
going forward, but could be recoded to avoid the assumption.)
Use xas_set() when iterating away from a THP, so that xa_index stays in
synch with start, instead of drifting away to return bogus offset.
Check start against end to avoid wrapping 32-bit xa_index to 0 (and to
handle these additional cases, seek_data or not, it's easier to break
the loop than goto: so rearrange exit from the function).
[hughd@google.com: remove unneeded u64 casts, per Matthew]
Link: https://lkml.kernel.org/r/alpine.LSU.2.11.2104221347240.1170@eggly.anvils
Link: https://lkml.kernel.org/r/alpine.LSU.2.11.2104211737410.3299@eggly.anvils
Fixes: 41139aa ("mm/filemap: add mapping_seek_hole_data")
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: Yang Shi <yang.shi@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent 2d11e73 commit ed98b01
1 file changed
Lines changed: 11 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2678 | 2678 | | |
2679 | 2679 | | |
2680 | 2680 | | |
2681 | | - | |
| 2681 | + | |
2682 | 2682 | | |
2683 | 2683 | | |
2684 | 2684 | | |
| |||
2687 | 2687 | | |
2688 | 2688 | | |
2689 | 2689 | | |
2690 | | - | |
| 2690 | + | |
| 2691 | + | |
2691 | 2692 | | |
2692 | 2693 | | |
2693 | 2694 | | |
2694 | 2695 | | |
2695 | 2696 | | |
2696 | 2697 | | |
2697 | 2698 | | |
2698 | | - | |
| 2699 | + | |
| 2700 | + | |
2699 | 2701 | | |
2700 | 2702 | | |
2701 | 2703 | | |
2702 | 2704 | | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
2703 | 2709 | | |
2704 | 2710 | | |
2705 | 2711 | | |
2706 | | - | |
2707 | | - | |
2708 | 2712 | | |
2709 | | - | |
2710 | | - | |
2711 | | - | |
| 2713 | + | |
2712 | 2714 | | |
2713 | 2715 | | |
2714 | | - | |
| 2716 | + | |
2715 | 2717 | | |
2716 | | - | |
2717 | 2718 | | |
2718 | 2719 | | |
2719 | 2720 | | |
| |||
0 commit comments