mm, THP, swap: fix allocating cluster for swapfile by mistake
Gao Xiang authored
commit 41663430 upstream.

SWP_FS is used to make swap_{read,write}page() go through the
filesystem, and it's only used for swap files over NFS.  So, !SWP_FS
means non NFS for now, it could be either file backed or device backed.
Something similar goes with legacy SWP_FILE.

So in order to achieve the goal of the original patch, SWP_BLKDEV should
be used instead.

FS corruption can be observed with SSD device + XFS + fragmented
swapfile due to CONFIG_THP_SWAP=y.

I reproduced the issue with the following details:

Environment:

  QEMU + upstream kernel + buildroot + NVMe (2 GB)

Kernel config:

  CONFIG_BLK_DEV_NVME=y
  CONFIG_THP_SWAP=y

Some reproducible steps:

  mkfs.xfs -f /dev/nvme0n1
  mkdir /tmp/mnt
  mount /dev/nvme0n1 /tmp/mnt
  bs="32k"
  sz="1024m"    # doesn't matter too much, I also tried 16m
  xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw
  xfs_io -f -c "pwrite -R -b $bs 0 $sz" -...
f082d13c
Name Last commit Last update
Documentation dt-bindings: sound: wm8994: Correct required supplies based on actual implementaion
arch MIPS: Add the missing 'CPU_1074K' into __get_cpu_type()
block block: ensure bdi->io_pages is always initialized
certs Replace magic for trusting the secondary keyring with #define
crypto crypto: af_alg - fix use-after-free in af_alg_accept() due to bh_lock_sock()
drivers s390/dasd: Fix zero write for FBA devices
firmware Fix built-in early-load Intel microcode alignment
fs btrfs: qgroup: fix data leak caused by race between writeback and truncate
include NFS: Fix races nfs_page_group_destroy() vs nfs_destroy_unlinked_subrequests()
init x86: Fix early boot crash on gcc-10, third try
ipc ipc/util.c: sysvipc_find_ipc() incorrectly updates position index
kernel kprobes: Fix to check probe enabled before disarm_kprobe_ftrace()
lib test_kmod: avoid potential double free in trigger_config_run_type()
mm mm, THP, swap: fix allocating cluster for swapfile by mistake
net batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh
samples samples: bpf: Fix build error
scripts checkpatch: fix the usage of capture group ( ... )
security selinux: sel_avc_get_stat_idx should increase position index
sound ALSA: asihpi: fix iounmap in error handler
tools objtool: Fix noreturn detection for ignored functions
usr initramfs: restore default compression behavior
virt KVM: fix overflow of zero page refcount with ksm running
.cocciconfig scripts: add Linux .cocciconfig for coccinelle
.get_maintainer.ignore Add hch to .get_maintainer.ignore
.gitattributes .gitattributes: set git diff driver for C source code files
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Linux kernel
============

This file was moved to Documentation/admin-guide/README.rst

Please notice that there are several guides for kernel developers and users.
These guides can be rendered in a number of formats, like HTML and PDF.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
See Documentation/00-INDEX for a list of what is contained in each file.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.