Commit Graph

310 Commits

Author SHA1 Message Date
Scott Mayhew 852fd33f32 nfs: remove dead code for the old swap over NFS implementation
JIRA: https://issues.redhat.com/browse/RHEL-59704
Conflicts:
	fs/nfs/write.c: Context difference due to RHEL not having
	600f111ef51d ("fs: Rename mapping private members")

commit 7e8e78a0ba00c88f0ded86de64bdddc82e06b196
Author: Christoph Hellwig <hch@lst.de>
Date:   Mon Jul 1 07:26:48 2024 +0200

    nfs: remove dead code for the old swap over NFS implementation

    Remove the code testing folio_test_swapcache either explicitly or
    implicitly in pagemap.h headers, as is now handled using the direct I/O
    path and not the buffered I/O path that these helpers are located in.

    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2024-11-05 07:34:02 -05:00
Scott Mayhew 06cd08852e NFSv4: Add a flags argument to the 'have_delegation' callback
JIRA: https://issues.redhat.com/browse/RHEL-59704

commit 4201916f2ab13577d45876f4bc784be55e4a83da
Author: Trond Myklebust <trond.myklebust@primarydata.com>
Date:   Sun Jun 16 21:21:24 2024 -0400

    NFSv4: Add a flags argument to the 'have_delegation' callback

    This argument will be used to allow the caller to specify whether or not
    they need to know that this is an attribute delegation.

    Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
    Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com>
    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2024-11-05 07:33:59 -05:00
Scott Mayhew 546a377f27 nfs: drop usage of folio_file_pos
JIRA: https://issues.redhat.com/browse/RHEL-59704
Conflicts:
	fs/nfs/nfstrace.h: Hunks affecting both tracepoints were no
	longer needed and were dropped due to out of order backport of
	5560756ea2 ("nfs: pass explicit offset/count to trace events")
	fs/nfs/write.c: Ditto, for the hunk that changed nfs_wb_folio_cancel().

commit 237d29075ca71feeadf38e801ef657858d9e9598
Author: Kairui Song <kasong@tencent.com>
Date:   Wed May 22 01:58:49 2024 +0800

    nfs: drop usage of folio_file_pos

    folio_file_pos is only needed for mixed usage of page cache and swap
    cache, for pure page cache usage, the caller can just use folio_pos
    instead.

    After commit e1209d3a7a67 ("mm: introduce ->swap_rw and use it for reads
    from SWP_FS_OPS swap-space"), swap cache should never be exposed to nfs.

    So remove the usage of folio_file_pos in following NFS functions / helpers:

    - nfs_vm_page_mkwrite

      It's only used by nfs_file_vm_ops.page_mkwrite

    - trace event helper: nfs_folio_event
    - trace event helper: nfs_folio_event_done

      These two are used through DEFINE_NFS_FOLIO_EVENT and
      DEFINE_NFS_FOLIO_EVENT_DONE, which defined following events:

      - trace_nfs_aop_readpage{_done}: only called by nfs_read_folio
      - trace_nfs_writeback_folio: only called by nfs_wb_folio
      - trace_nfs_invalidate_folio: only called by nfs_invalidate_folio
      - trace_nfs_launder_folio_done: only called by nfs_launder_folio

      None of them could possibly be used on swap cache folio,
      nfs_read_folio only called by:
      .write_begin -> nfs_read_folio
      .read_folio

      nfs_wb_folio only called by nfs mapping:
      .release_folio -> nfs_wb_folio
      .launder_folio -> nfs_wb_folio
      .write_begin -> nfs_read_folio -> nfs_wb_folio
      .read_folio -> nfs_wb_folio
      .write_end -> nfs_update_folio -> nfs_writepage_setup -> nfs_setup_write_request -> nfs_try_to_update_request -> nfs_wb_folio
      .page_mkwrite -> nfs_update_folio -> nfs_writepage_setup -> nfs_setup_write_request -> nfs_try_to_update_request -> nfs_wb_folio
      .write_begin -> nfs_flush_incompatible -> nfs_wb_folio
      .page_mkwrite -> nfs_vm_page_mkwrite -> nfs_flush_incompatible -> nfs_wb_folio

      nfs_invalidate_folio is only called by .invalidate_folio.
      nfs_launder_folio is only called by .launder_folio

    - nfs_grow_file
    - nfs_update_folio

      nfs_grow_file is only called by nfs_update_folio, and all
      possible callers of them are:

      .write_end -> nfs_update_folio
      .page_mkwrite -> nfs_update_folio

    - nfs_wb_folio_cancel

      .invalidate_folio -> nfs_wb_folio_cancel

    Also, seeing from the swap side, swap_rw is now the only interface calling
    into fs, the offset info is always in iocb.ki_pos now.

    So we can remove all these folio_file_pos call safely.

    Link: https://lkml.kernel.org/r/20240521175854.96038-8-ryncsn@gmail.com
    Signed-off-by: Kairui Song <kasong@tencent.com>
    Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    Cc: Anna Schumaker <anna@kernel.org>
    Cc: Barry Song <v-songbaohua@oppo.com>
    Cc: Chao Yu <chao@kernel.org>
    Cc: Chris Li <chrisl@kernel.org>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: David Howells <dhowells@redhat.com>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Ilya Dryomov <idryomov@gmail.com>
    Cc: Jaegeuk Kim <jaegeuk@kernel.org>
    Cc: Jeff Layton <jlayton@kernel.org>
    Cc: Marc Dionne <marc.dionne@auristor.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: NeilBrown <neilb@suse.de>
    Cc: Ryan Roberts <ryan.roberts@arm.com>
    Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
    Cc: Xiubo Li <xiubli@redhat.com>
    Cc: Yosry Ahmed <yosryahmed@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2024-11-05 07:33:57 -05:00
Benjamin Coddington 5560756ea2 nfs: pass explicit offset/count to trace events
JIRA: https://issues.redhat.com/browse/RHEL-53004
Conflicts: Slight context diff in nfs_invalidate_folio as RHEL is missing
	the work to unload page->private from netfs

commit fada32ed6dbc748f447c8d050a961b75d946055a
Author: Christoph Hellwig <hch@lst.de>
Date:   Thu Jul 11 09:17:02 2024 +0200

    nfs: pass explicit offset/count to trace events

    nfs_folio_length is unsafe to use without having the folio locked and a
    check for a NULL ->f_mapping that protects against truncations and can
    lead to kernel crashes.  E.g. when running xfstests generic/065 with
    all nfs trace points enabled.

    Follow the model of the XFS trace points and pass in an explіcit offset
    and length.  This has the additional benefit that these values can
    be more accurate as some of the users touch partial folio ranges.

    Fixes: eb5654b3b89d ("NFS: Enable tracing of nfs_invalidate_folio() and nfs_launder_folio()")
    Reported-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2024-08-06 09:32:38 -04:00
Waiman Long 6d0328a7cf Revert "Revert "Merge: cgroup: Backport upstream cgroup commits up to v6.8""
JIRA: https://issues.redhat.com/browse/RHEL-36683
Upstream Status: RHEL only

This reverts commit 08637d76a2 which is a
revert of "Merge: cgroup: Backport upstream cgroup commits up to v6.8"

Signed-off-by: Waiman Long <longman@redhat.com>
2024-05-18 21:38:20 -04:00
Lucas Zampieri 08637d76a2 Revert "Merge: cgroup: Backport upstream cgroup commits up to v6.8"
This reverts merge request !4128
2024-05-16 15:26:41 +00:00
Lucas Zampieri 1ce55b7cbb Merge: cgroup: Backport upstream cgroup commits up to v6.8
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4128

JIRA: https://issues.redhat.com/browse/RHEL-34600    
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4128

This MR backports upstream cgroup commits up to v6.8 with related fixes,
if applicable. It also pulls in a number of scheduler and PSI related
commits due to their interaction with cgroup.

Signed-off-by: Waiman Long <longman@redhat.com>

Approved-by: Tony Camuso <tcamuso@redhat.com>
Approved-by: Chris von Recklinghausen <crecklin@redhat.com>
Approved-by: Xin Long <lxin@redhat.com>

Merged-by: Lucas Zampieri <lzampier@redhat.com>
2024-05-16 13:28:22 +00:00
Chris von Recklinghausen c0aa51a6e5 fs: Add FGP_WRITEBEGIN
Conflicts:
	fs/iomap/buffered-io.c - We already have
		66dabbb65d67 ("mm: return an ERR_PTR from __filemap_get_folio")
		so don't add declaration for folio
	include/linux/pagemap.h - We already have
		263e721e3ba1 ("mm: make mapping_get_entry available outside of filemap.c")
		so keep declaration of filemap_get_entry
	fs/nfs/file.c - We already have
		66dabbb65d67 (" mm: return an ERR_PTR from __filemap_get_folio")
		so keep IS_ERR/PTR_ERR

JIRA: https://issues.redhat.com/browse/RHEL-27741

commit e999a5c5a19cf3b679f3d93c49ad5f5c04e4806c
Author: Matthew Wilcox <willy@infradead.org>
Date:   Fri Mar 24 18:01:01 2023 +0000

    fs: Add FGP_WRITEBEGIN

    This particular combination of flags is used by most filesystems
    in their ->write_begin method, although it does find use in a
    few other places.  Before folios, it warranted its own function
    (grab_cache_page_write_begin()), but I think that just having specialised
    flags is enough.  It certainly helps the few places that have been
    converted from grab_cache_page_write_begin() to __filemap_get_folio().

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Link: https://lore.kernel.org/r/20230324180129.1220691-2-willy@infradead.org
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2024-04-30 07:00:46 -04:00
Chris von Recklinghausen c0446613df mm: return an ERR_PTR from __filemap_get_folio
Conflicts:
	fs/nilfs2/page.c - We already have
		f6e0e1734424 ("nilfs2: Convert nilfs_copy_back_pages() to use filemap_get_folios()")
		so use folios instead of pages
	fs/smb/client/cifsfs.c - The backport of
		7b2404a886f8 ("cifs: Fix flushing, invalidation and file size with copy_file_range()")
		cited the lack of this patch as a conflict. Fix it.

JIRA: https://issues.redhat.com/browse/RHEL-27741

commit 66dabbb65d673aef40dd17bf62c042be8f6d4a4b
Author: Christoph Hellwig <hch@lst.de>
Date:   Tue Mar 7 15:34:10 2023 +0100

    mm: return an ERR_PTR from __filemap_get_folio

    Instead of returning NULL for all errors, distinguish between:

     - no entry found and not asked to allocated (-ENOENT)
     - failed to allocate memory (-ENOMEM)
     - would block (-EAGAIN)

    so that callers don't have to guess the error based on the passed in
    flags.

    Also pass through the error through the direct callers: filemap_get_folio,
    filemap_lock_folio filemap_grab_folio and filemap_get_incore_folio.

    [hch@lst.de: fix null-pointer deref]
      Link: https://lkml.kernel.org/r/20230310070023.GA13563@lst.de
      Link: https://lkml.kernel.org/r/20230310043137.GA1624890@u2004
    Link: https://lkml.kernel.org/r/20230307143410.28031-8-hch@lst.de
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com> [nilfs2]
    Cc: Andreas Gruenbacher <agruenba@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2024-04-30 07:00:24 -04:00
Waiman Long 724656e7cf freezer,sched: Rewrite core freezer logic
JIRA: https://issues.redhat.com/browse/RHEL-34600
Conflicts:
 1) A merge conflict in the kernel/signal.c hunk due to the presence
    of RHEL-only commit 975d318867 ("signal: Don't disable preemption
    in ptrace_stop() on PREEMPT_RT.").
 2) A merge conflict in the kernel/time/hrtimer.c hunk due to the
    presence of RHEL-only commit 5f76194136 ("time/hrtimer: Embed
    hrtimer mode into hrtimer_sleeper").
 3) The fs/cifs/inode.c hunk was applied to fs/smb/client/inode.c due
    to the presence of upstream commit 38c8a9a52082 ("smb: move client
    and server files to common directory fs/smb").
 4) Similarly, the fs/cifs/transport.c hunk was applied to
    fs/smb/client/transport.c manually due to the presence of
    a later upstream commit d527f51331ca ("cifs: Fix UAF in
    cifs_demultiplex_thread()").

Note that all the prerequiste patches in the same patch series
(https://lore.kernel.org/lkml/20220822111816.760285417@infradead.org/)
had already been merged into RHEL9.

commit f5d39b020809146cc28e6e73369bf8065e0310aa
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Mon, 22 Aug 2022 13:18:22 +0200

    freezer,sched: Rewrite core freezer logic

    Rewrite the core freezer to behave better wrt thawing and be simpler
    in general.

    By replacing PF_FROZEN with TASK_FROZEN, a special block state, it is
    ensured frozen tasks stay frozen until thawed and don't randomly wake
    up early, as is currently possible.

    As such, it does away with PF_FROZEN and PF_FREEZER_SKIP, freeing up
    two PF_flags (yay!).

    Specifically; the current scheme works a little like:

            freezer_do_not_count();
            schedule();
            freezer_count();

    And either the task is blocked, or it lands in try_to_freezer()
    through freezer_count(). Now, when it is blocked, the freezer
    considers it frozen and continues.

    However, on thawing, once pm_freezing is cleared, freezer_count()
    stops working, and any random/spurious wakeup will let a task run
    before its time.

    That is, thawing tries to thaw things in explicit order; kernel
    threads and workqueues before doing bringing SMP back before userspace
    etc.. However due to the above mentioned races it is entirely possible
    for userspace tasks to thaw (by accident) before SMP is back.

    This can be a fatal problem in asymmetric ISA architectures (eg ARMv9)
    where the userspace task requires a special CPU to run.

    As said; replace this with a special task state TASK_FROZEN and add
    the following state transitions:

            TASK_FREEZABLE  -> TASK_FROZEN
            __TASK_STOPPED  -> TASK_FROZEN
            __TASK_TRACED   -> TASK_FROZEN

    The new TASK_FREEZABLE can be set on any state part of TASK_NORMAL
    (IOW. TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE) -- any such state
    is already required to deal with spurious wakeups and the freezer
    causes one such when thawing the task (since the original state is
    lost).

    The special __TASK_{STOPPED,TRACED} states *can* be restored since
    their canonical state is in ->jobctl.

    With this, frozen tasks need an explicit TASK_FROZEN wakeup and are
    free of undue (early / spurious) wakeups.

    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://lore.kernel.org/r/20220822114649.055452969@infradead.org

Signed-off-by: Waiman Long <longman@redhat.com>
2024-04-26 22:49:06 -04:00
Ming Lei 078c82c4f8 filemap: update ki_pos in generic_perform_write
JIRA: https://issues.redhat.com/browse/RHEL-29564
Conflicts: drop f2fs change

commit 182c25e9c157f37bd0ab5a82fe2417e2223df459
Author: Christoph Hellwig <hch@lst.de>
Date:   Thu Jun 1 16:58:55 2023 +0200

    filemap: update ki_pos in generic_perform_write

    All callers of generic_perform_write need to updated ki_pos, move it into
    common code.

    Link: https://lkml.kernel.org/r/20230601145904.1385409-4-hch@lst.de
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Xiubo Li <xiubli@redhat.com>
    Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Acked-by: Theodore Ts'o <tytso@mit.edu>
    Acked-by: Darrick J. Wong <djwong@kernel.org>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Andreas Gruenbacher <agruenba@redhat.com>
    Cc: Anna Schumaker <anna@kernel.org>
    Cc: Chao Yu <chao@kernel.org>
    Cc: Christian Brauner <brauner@kernel.org>
    Cc: Ilya Dryomov <idryomov@gmail.com>
    Cc: Jaegeuk Kim <jaegeuk@kernel.org>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Miklos Szeredi <miklos@szeredi.hu>
    Cc: Miklos Szeredi <mszeredi@redhat.com>
    Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Ming Lei <ming.lei@redhat.com>
2024-04-17 10:04:37 +08:00
Ming Lei 80c8d8c3fd backing_dev: remove current->backing_dev_info
JIRA: https://issues.redhat.com/browse/RHEL-29564
Conflicts: drop f2fs and ntfs2 changes

commit 0d625446d0a451a683a357799912b9e688629707
Author: Christoph Hellwig <hch@lst.de>
Date:   Thu Jun 1 16:58:53 2023 +0200

    backing_dev: remove current->backing_dev_info

    Patch series "cleanup the filemap / direct I/O interaction", v4.

    This series cleans up some of the generic write helper calling conventions
    and the page cache writeback / invalidation for direct I/O.  This is a
    spinoff from the no-bufferhead kernel project, for which we'll want to an
    use iomap based buffered write path in the block layer.

    This patch (of 12):

    The last user of current->backing_dev_info disappeared in commit
    b9b1335e6403 ("remove bdi_congested() and wb_congested() and related
    functions").  Remove the field and all assignments to it.

    Link: https://lkml.kernel.org/r/20230601145904.1385409-1-hch@lst.de
    Link: https://lkml.kernel.org/r/20230601145904.1385409-2-hch@lst.de
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Christian Brauner <brauner@kernel.org>
    Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Reviewed-by: Darrick J. Wong <djwong@kernel.org>
    Acked-by: Theodore Ts'o <tytso@mit.edu>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Andreas Gruenbacher <agruenba@redhat.com>
    Cc: Anna Schumaker <anna@kernel.org>
    Cc: Chao Yu <chao@kernel.org>
    Cc: Ilya Dryomov <idryomov@gmail.com>
    Cc: Jaegeuk Kim <jaegeuk@kernel.org>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Miklos Szeredi <miklos@szeredi.hu>
    Cc: Miklos Szeredi <mszeredi@redhat.com>
    Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    Cc: Xiubo Li <xiubli@redhat.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Ming Lei <ming.lei@redhat.com>
2024-04-17 10:04:36 +08:00
Jeffrey Layton cce4b531f8 nfs: Remove writepage
JIRA: https://issues.redhat.com/browse/RHEL-28630
Conflicts: minor page/folio contextual conflict

commit 12fc0a963128b54b82e98b9909f463e784b90b07
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Fri Dec 15 20:47:07 2023 +0000

    nfs: Remove writepage

    NFS already has writepages and migrate_folio, so it does not need to
    implement writepage.  The writepage operation is deprecated as it leads
    to worse performance under high memory pressure due to folios being
    written out in LRU order rather than sequentially within a file.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Jeffrey Layton <jlayton@redhat.com>
2024-03-22 10:29:58 -04:00
Jeffrey Layton fabaf3df7e filemap: Fix errors in file.c
JIRA: https://issues.redhat.com/browse/RHEL-7936

commit a841c9cb9b04b05525f0928633e84e95921ab298
Author: huzhi001@208suo.com <huzhi001@208suo.com>
Date:   Wed Jul 19 19:00:38 2023 +0800

    filemap: Fix errors in file.c

    The following checkpatch errors are removed:
    ERROR: "foo * bar" should be "foo *bar"
    "foo * bar" should be "foo *bar"

    Signed-off-by: ZhiHu <huzhi001@208suo.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Jeffrey Layton <jlayton@redhat.com>
2023-12-02 05:12:37 -05:00
Scott Mayhew 1fa336f8a5 NFS: Enable tracing of nfs_invalidate_folio() and nfs_launder_folio()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit eb5654b3b89d5e836312cea9f3fdb49457852e89
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Thu Jan 19 16:33:49 2023 -0500

    NFS: Enable tracing of nfs_invalidate_folio() and nfs_launder_folio()

    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:41:31 -04:00
Scott Mayhew ee20d016e0 NFS: fix up nfs_release_folio() to try to release the page
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit 96780ca55e3cbf4f150fd5a833a61492c9947b5b
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Thu Jan 19 16:33:48 2023 -0500

    NFS: fix up nfs_release_folio() to try to release the page

    If the gfp context allows it, and we're not kswapd, then try to write
    out the folio that has private data.

    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:41:31 -04:00
Scott Mayhew 98952b9e34 NFS: Fix up nfs_vm_page_mkwrite() for folios
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit 4fa7a717b432c3311192aa85a34fedf5f8de4689
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Thu Jan 19 16:33:46 2023 -0500

    NFS: Fix up nfs_vm_page_mkwrite() for folios

    Mechanical conversion of struct page and functions into the folio
    equivalents.

    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:41:30 -04:00
Scott Mayhew 7fa2c3a1a4 NFS: Convert nfs_write_begin/end to use folios
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit 54d99381b7371d2999566d1fb4ea88d46cf9d865
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Thu Jan 19 16:33:45 2023 -0500

    NFS: Convert nfs_write_begin/end to use folios

    Add a helper nfs_folio_grab_cache_write_begin() that can call
    __filemap_get_folio() directly with the appropriate parameters.

    Since write_begin()/write_end() take struct page arguments, just pass
    the folio->page back for now.

    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:41:30 -04:00
Scott Mayhew 0c2c4eaad2 NFS: Convert buffered writes to use folios
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit 0c493b5cf16e28d761b6e77c7c32aa0e7af70813
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Thu Jan 19 16:33:43 2023 -0500

    NFS: Convert buffered writes to use folios

    Mostly mechanical conversion of struct page and functions into struct
    folio equivalents.
    The lack of support for folios in write_cache_pages(), means we still
    only support order 0 folio allocations. However the rest of the
    writeback code should now be ready for order n > 0.

    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:41:30 -04:00
Scott Mayhew 8aa08d5ebc NFS: Add a helper nfs_wb_folio()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit 4b27232a6e064f3d779cfa76cd251d6023949d22
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Thu Jan 19 16:33:40 2023 -0500

    NFS: Add a helper nfs_wb_folio()

    ...and use it in nfs_launder_folio().

    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:41:29 -04:00
Scott Mayhew bfe7500c56 NFS: clean up a needless assignment in nfs_file_write()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit 384edeb46f07f4ee1b3adda9416e724421e2fad5
Author: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Date:   Wed Aug 10 13:40:01 2022 +0200

    NFS: clean up a needless assignment in nfs_file_write()

    Commit 064109db53ec ("NFS: remove redundant code in nfs_file_write()")
    identifies that filemap_fdatawait_range() will always return 0 and removes
    a dead error-handling case in nfs_file_write(). With this change however,
    assigning the return of filemap_fdatawait_range() to the result variable is
    a dead store.

    Remove this needless assignment.

    No functional change. No change in object code.

    Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:41:11 -04:00
Scott Mayhew 1921bbc123 NFS: remove redundant code in nfs_file_write()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit 064109db53ecc5d88621d02f36da9f33ca0d64bd
Author: ChenXiaoSong <chenxiaosong2@huawei.com>
Date:   Thu Jun 23 09:58:58 2022 +0800

    NFS: remove redundant code in nfs_file_write()

    filemap_fdatawait_range() will always return 0, after patch 6c984083ec24
    ("NFS: Use of mapping_set_error() results in spurious errors"), it will not
    save the wb err in struct address_space->flags:

      result = filemap_fdatawait_range(file->f_mapping, ...) = 0
        filemap_check_errors(mapping) = 0
          test_bit(..., &mapping->flags) // flags is 0

    Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:40:57 -04:00
Scott Mayhew 382a0c66ad nfs: rename nfs_direct_IO and use as ->swap_rw
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183621

commit eb79f3af9395fbe448e91b0940a6c395b7d06be4
Author: NeilBrown <neilb@suse.de>
Date:   Mon May 9 18:20:48 2022 -0700

    nfs: rename nfs_direct_IO and use as ->swap_rw

    The nfs_direct_IO() exists to support SWAP IO, but hasn't worked for a
    while.  We now need a ->swap_rw function which behaves slightly
    differently, returning zero for success rather than a byte count.

    So modify nfs_direct_IO accordingly, rename it, and use it as the
    ->swap_rw function.

    Link: https://lkml.kernel.org/r/165119301493.15698.7491285551903597618.stgit@noble.brown
    Signed-off-by: NeilBrown <neilb@suse.de>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> (on Renesas RSK+RZA1 with 32 MiB of SDRAM)
    Cc: David Howells <dhowells@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Miaohe Lin <linmiaohe@huawei.com>
    Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2023-05-08 10:40:52 -04:00
Chris von Recklinghausen 3a51424db2 nfs: Convert to migrate_folio
Bugzilla: https://bugzilla.redhat.com/2160210

commit 4ae84a80475144f739f77ed8bc789bc7feaa08ce
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Mon Jun 6 09:22:19 2022 -0400

    nfs: Convert to migrate_folio

    Use a folio throughout this function.  migrate_page() will be converted
    later.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Acked-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:19:29 -04:00
Chris von Recklinghausen 51850be1bf nfs: Convert to release_folio
Conflicts: fs/nfs/file.c - We already have
	a2ad63daa88b ("VFS: add FMODE_CAN_ODIRECT file flag")
	so don't add entry for direct_IO

Bugzilla: https://bugzilla.redhat.com/2160210

commit 3577da4aa895847da74890903a3ae7e67ba1ee2f
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Sat Apr 30 23:53:28 2022 -0400

    nfs: Convert to release_folio

    Use folios throughout the release_folio paths.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: Jeff Layton <jlayton@kernel.org>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:19:01 -04:00
Chris von Recklinghausen 3f6b9d910f VFS: add FMODE_CAN_ODIRECT file flag
Bugzilla: https://bugzilla.redhat.com/2160210

commit a2ad63daa88b9d6846976fd2a0b5e4f5cfc58377
Author: NeilBrown <neilb@suse.de>
Date:   Mon May 9 18:20:49 2022 -0700

    VFS: add FMODE_CAN_ODIRECT file flag

    Currently various places test if direct IO is possible on a file by
    checking for the existence of the direct_IO address space operation.
    This is a poor choice, as the direct_IO operation may not be used - it is
    only used if the generic_file_*_iter functions are called for direct IO
    and some filesystems - particularly NFS - don't do this.

    Instead, introduce a new f_mode flag: FMODE_CAN_ODIRECT and change the
    various places to check this (avoiding pointer dereferences).
    do_dentry_open() will set this flag if ->direct_IO is present, so
    filesystems do not need to be changed.

    NFS *is* changed, to set the flag explicitly and discard the direct_IO
    entry in the address_space_operations for files.

    Other filesystems which currently use noop_direct_IO could usefully be
    changed to set this flag instead.

    Link: https://lkml.kernel.org/r/164859778128.29473.15189737957277399416.stgit@noble.brown
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: NeilBrown <neilb@suse.de>
    Tested-by: David Howells <dhowells@redhat.com>
    Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    Cc: Miaohe Lin <linmiaohe@huawei.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:19:01 -04:00
Chris von Recklinghausen 2fd69ebf77 mm: introduce ->swap_rw and use it for reads from SWP_FS_OPS swap-space
Conflicts: mm/page_io.c - We already have
	0f312591d656 ("mm: Convert swap_readpage to call read_folio instead of readpage")
	so this causes a merge conflict. Just replace the chunk with
	"ret = swap_readpage_fs(page);"

Bugzilla: https://bugzilla.redhat.com/2160210

commit e1209d3a7a67c281260ba9989621060ba7328b8c
Author: NeilBrown <neilb@suse.de>
Date:   Mon May 9 18:20:48 2022 -0700

    mm: introduce ->swap_rw and use it for reads from SWP_FS_OPS swap-space

    swap currently uses ->readpage to read swap pages.  This can only request
    one page at a time from the filesystem, which is not most efficient.

    swap uses ->direct_IO for writes which while this is adequate is an
    inappropriate over-loading.  ->direct_IO may need to had handle allocate
    space for holes or other details that are not relevant for swap.

    So this patch introduces a new address_space operation: ->swap_rw.  In
    this patch it is used for reads, and a subsequent patch will switch writes
    to use it.

    No filesystem yet supports ->swap_rw, but that is not a problem because
    no filesystem actually works with filesystem-based swap.
    Only two filesystems set SWP_FS_OPS:
    - cifs sets the flag, but ->direct_IO always fails so swap cannot work.
    - nfs sets the flag, but ->direct_IO calls generic_write_checks()
      which has failed on swap files for several releases.

    To ensure that a NULL ->swap_rw isn't called, ->activate_swap() for both
    NFS and cifs are changed to fail if ->swap_rw is not set.  This can be
    removed if/when the function is added.

    Future patches will restore swap-over-NFS functionality.

    To submit an async read with ->swap_rw() we need to allocate a structure
    to hold the kiocb and other details.  swap_readpage() cannot handle
    transient failure, so we create a mempool to provide the structures.

    Link: https://lkml.kernel.org/r/164859778125.29473.13430559328221330589.stgi
t@noble.brown
    Signed-off-by: NeilBrown <neilb@suse.de>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Tested-by: David Howells <dhowells@redhat.com>
    Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    Cc: Miaohe Lin <linmiaohe@huawei.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:19:00 -04:00
Chris von Recklinghausen 912f4071ac mm: move responsibility for setting SWP_FS_OPS to ->swap_activate
Bugzilla: https://bugzilla.redhat.com/2160210

commit 4b60c0ff2f2021ab99b7fb9da63b7ed1579ef1d8
Author: NeilBrown <neilb@suse.de>
Date:   Mon May 9 18:20:48 2022 -0700

    mm: move responsibility for setting SWP_FS_OPS to ->swap_activate

    If a filesystem wishes to handle all swap IO itself (via ->direct_IO and
    ->readpage), rather than just providing devices addresses for
    submit_bio(), SWP_FS_OPS must be set.

    Currently the protocol for setting this it to have ->swap_activate return
    zero.  In that case SWP_FS_OPS is set, and add_swap_extent() is called for
    the entire file.

    This is a little clumsy as different return values for ->swap_activate
    have quite different meanings, and it makes it hard to search for which
    filesystems require SWP_FS_OPS to be set.

    So remove the special meaning of a zero return, and require the filesystem
    to set SWP_FS_OPS if it so desires, and to always call add_swap_extent()
    as required.

    Currently only NFS and CIFS return zero for add_swap_extent().

    Link: https://lkml.kernel.org/r/164859778123.29473.17908205846599043598.stgit@noble.brown
    Signed-off-by: NeilBrown <neilb@suse.de>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Tested-by: David Howells <dhowells@redhat.com>
    Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    Cc: Miaohe Lin <linmiaohe@huawei.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:19:00 -04:00
Chris von Recklinghausen 56b8b0d665 nfs: Convert nfs to read_folio
Bugzilla: https://bugzilla.redhat.com/2160210

commit 65d023af7f29eb1250a6105141a74776bae7e1f8
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Fri Apr 29 11:12:16 2022 -0400

    nfs: Convert nfs to read_folio

    This is a "weak" conversion which converts straight back to using pages.
    A full conversion should be performed at some point, hopefully by
    someone familiar with the filesystem.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:18:59 -04:00
Chris von Recklinghausen 0483dc9361 fs: Convert is_dirty_writeback() to take a folio
Bugzilla: https://bugzilla.redhat.com/2160210

commit 520f301c54faa3484e820b80d4505d48ee587163
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Mon Jan 17 14:35:22 2022 -0500

    fs: Convert is_dirty_writeback() to take a folio

    Pass a folio instead of a page to aops->is_dirty_writeback().
    Convert both implementations and the caller.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: Christoph Hellwig <hch@lst.de>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:18:58 -04:00
Chris von Recklinghausen c1e99d68fb fs: Remove flags parameter from aops->write_begin
Conflicts: drop changes to fs/ntfs3/inode.c, fs/jffs2/file.c -
	unsupported configs

Bugzilla: https://bugzilla.redhat.com/2160210

commit 9d6b0cd7579844761ed68926eb3073bab1dca87b
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Tue Feb 22 14:31:43 2022 -0500

    fs: Remove flags parameter from aops->write_begin

    There are no more aop flags left, so remove the parameter.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: Christoph Hellwig <hch@lst.de>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:18:58 -04:00
Chris von Recklinghausen ef6a91bc18 fs: Remove aop flags parameter from grab_cache_page_write_begin()
Conflicts: drop changes to fs/ntfs3/inode.c, fs/jffs2/file.c -
	unsupported configs

Conflicts: drop changes to fs/ntfs3/inode.c - unsupported config

Bugzilla: https://bugzilla.redhat.com/2160210

commit b7446e7cf15f0926866c8e5de90ab278998bf8c8
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Tue Feb 22 11:25:12 2022 -0500

    fs: Remove aop flags parameter from grab_cache_page_write_begin()

    There are no more aop flags left, so remove the parameter.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: Christoph Hellwig <hch@lst.de>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:18:58 -04:00
Chris von Recklinghausen 3bab348e76 nfs: Convert from launder_page to launder_folio
Bugzilla: https://bugzilla.redhat.com/2160210

commit 15a30ab2b35b02a9f2cf7f78f5b5709b484c9a18
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Wed Feb 9 20:21:57 2022 +0000

    nfs: Convert from launder_page to launder_folio

    We don't need to use page_file_mapping() here because launder_folio
    is never called for swap cache pages.  We also don't need to
    cast an loff_t in order to print it.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Tested-by: Mike Marshall <hubcap@omnibond.com> # orangefs
    Tested-by: David Howells <dhowells@redhat.com> # afs

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:18:47 -04:00
Chris von Recklinghausen d9b9cd9f74 nfs: Convert from invalidatepage to invalidate_folio
Bugzilla: https://bugzilla.redhat.com/2160210

commit 6d740c76ea86053208b20c41fb5ec1de07acb996
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Wed Feb 9 20:21:47 2022 +0000

    nfs: Convert from invalidatepage to invalidate_folio

    Print the folio index instead of the pointer, since this is more
    useful.  We also don't need to use page_file_mapping() as we do not
    invalidate swapcache pages.  Since this is the only caller of
    nfs_wb_page_cancel(), convert it to nfs_wb_folio_cancel().

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Tested-by: Mike Marshall <hubcap@omnibond.com> # orangefs
    Tested-by: David Howells <dhowells@redhat.com> # afs

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:18:47 -04:00
Frantisek Hrbata e9e9bc8da2 Merge: mm changes through v5.18 for 9.2
Merge conflicts:
-----------------
Conflicts with !1142(merged) "io_uring: update to v5.15"

fs/io-wq.c
        - static bool io_wqe_create_worker(struct io_wqe *wqe, struct io_wqe_acct *acct)
          !1142 already contains backport of 3146cba99aa2 ("io-wq: make worker creation resilient against signals")
          along with other commits which are not present in !1370. Resolved in favor of HEAD(!1142)
        - static int io_wqe_worker(void *data)
          !1370 does not contain 767a65e9f317 ("io-wq: fix potential race of acct->nr_workers")
          Resolved in favor of HEAD(!1142)
        - static void io_init_new_worker(struct io_wqe *wqe, struct io_worker *worker,
          HEAD(!1142) does not contain e32cf5dfbe22 ("kthread: Generalize pf_io_worker so it can point to struct kthread")
          Resolved in favor of !1370
        - static void create_worker_cont(struct callback_head *cb)
          !1370 does not contain 66e70be72288 ("io-wq: fix memory leak in create_io_worker()")
          Resolved in favor of HEAD(!1142)
        - static void io_workqueue_create(struct work_struct *work)
          !1370 does not contain 66e70be72288 ("io-wq: fix memory leak in create_io_worker()")
          Resolved in favor of HEAD(!1142)
        - static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
          !1370 does not contain 66e70be72288 ("io-wq: fix memory leak in create_io_worker()")
          Resolved in favor of HEAD(!1142)
        - static bool io_wq_work_match_item(struct io_wq_work *work, void *data)
          !1370 does not contain 713b9825a4c4 ("io-wq: fix cancellation on create-worker failure")
          Resolved in favor of HEAD(!1142)
        - static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work)
          !1370 is missing 713b9825a4c4 ("io-wq: fix cancellation on create-worker failure")
          removed wrongly merged run_cancel label
          Resolved in favor of HEAD(!1142)
        - static bool io_task_work_match(struct callback_head *cb, void *data)
          !1370 is missing 3b33e3f4a6c0 ("io-wq: fix silly logic error in io_task_work_match()")
          Resolved in favor of HEAD(!1142)
        - static void io_wq_exit_workers(struct io_wq *wq)
          !1370 is missing 3b33e3f4a6c0 ("io-wq: fix silly logic error in io_task_work_match()")
          Resolved in favor of HEAD(!1142)
        - int io_wq_max_workers(struct io_wq *wq, int *new_count)
          !1370 is missing 3b33e3f4a6c0 ("io-wq: fix silly logic error in io_task_work_match()")
fs/io_uring.c
        - static int io_register_iowq_max_workers(struct io_ring_ctx *ctx,
          !1370 is missing bunch of commits after 2e480058ddc2 ("io-wq: provide a way to limit max number of workers")
          Resolved in favor of HEAD(!1142)
include/uapi/linux/io_uring.h
        - !1370 is missing dd47c104533d ("io-wq: provide IO_WQ_* constants for IORING_REGISTER_IOWQ_MAX_WORKERS arg items")
          just a comment conflict
          Resolved in favor of HEAD(!1142)
kernel/exit.c
        - void __noreturn do_exit(long code)
        - !1370 contains bunch of commits after f552a27afe67 ("io_uring: remove files pointer in cancellation functions")
          Resolved in favor of !1370

Conflicts with !1357(merged) "NFS refresh for RHEL-9.2"

fs/nfs/callback.c
        - nfs4_callback_svc(void *vrqstp)
          !1370 is missing f49169c97fce ("NFSD: Remove svc_serv_ops::svo_module") where the module_put_and_kthread_exit() was removed
          Resolved in favor of HEAD(!1357)
fs/nfs/file.c
          !1357 is missing 187c82cb0380 ("fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_folio")
          Resolved in favor of HEAD(!1370)
fs/nfsd/nfssvc.c
        - nfsd(void *vrqstp)
          !1370 is missing f49169c97fce ("NFSD: Remove svc_serv_ops::svo_module")
          Resolved in favor of HEAD(!1357)
-----------------

MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1370

Bugzilla: https://bugzilla.redhat.com/2120352

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2099722

Patches 1-9 are changes to selftests
Patches 10-31 are reverts of RHEL-only patches to address COR CVE
Patches 32-320 are the machine dependent mm changes ported by Rafael
Patch 321 reverts the backport of 6692c98c7df5. See below.
Patches 322-981 are the machine independent mm changes
Patches 982-1016 are David Hildebrand's upstream changes to address the COR CVE

RHEL commit b23c298982 fork: Stop protecting back_fork_cleanup_cgroup_lock with CONFIG_NUMA
which is a backport of upstream 6692c98c7df5 and is reverted early in this series. 6692c98c7df5
is a fix for upstream 40966e316f86 which was not in RHEL until this series. 6692c98c7df5 is re-added
after 40966e316f86.

Omitted-fix: 310d1344e3c5 ("Revert "powerpc: Remove unused FW_FEATURE_NATIVE references"")
        to be fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2131716

Omitted-fix: 465d0eb0dc31 ("Docs/admin-guide/mm/damon/usage: fix the example code snip")
        to be fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2131716

Omitted-fix: 317314527d17 ("mm/hugetlb: correct demote page offset logic")
        to be fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2131716

Omitted-fix: 37dcc673d065 ("frontswap: don't call ->init if no ops are registered")
        to be fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2131716

Omitted-fix: 30c19366636f ("mm: fix BUG splat with kvmalloc + GFP_ATOMIC")
        to be fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2131716

Omitted: fix: fa84693b3c89 io_uring: ensure IORING_REGISTER_IOWQ_MAX_WORKERS works with SQPOLL
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107656

Omitted-fix: 009ad9f0c6ee io_uring: drop ctx->uring_lock before acquiring sqd->lock
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107656

Omitted-fix: bc369921d670 io-wq: max_worker fixes
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107743

Omitted-fix: e139a1ec92f8 io_uring: apply max_workers limit to all future users
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107743

Omitted-fix: 71c9ce27bb57 io-wq: fix max-workers not correctly set on multi-node system
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107743

Omitted-fix: 41d3a6bd1d37 io_uring: pin SQPOLL data before unlocking ring lock
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107656

Omitted-fix: bad119b9a000 io_uring: honour zeroes as io-wq worker limits
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107743

Omitted-fix: 08bdbd39b584 io-wq: ensure that hash wait lock is IRQ disabling
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107656

Omitted-fix: 713b9825a4c4 io-wq: fix cancellation on create-worker failure
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107656

Omitted-fix: 3b33e3f4a6c0 io-wq: fix silly logic error in io_task_work_match()
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107656

Omitted-fix: 71e1cef2d794 io-wq: Remove duplicate code in io_workqueue_create()
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=210774

Omitted-fix: a226abcd5d42 io-wq: don't retry task_work creation failure on fatal conditions
	fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107743

Omitted-fix: fa84693b3c89 io_uring: ensure IORING_REGISTER_IOWQ_MAX_WORKERS works with SQPOLL
        fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107656

Omitted-fix: dd47c104533d io-wq: provide IO_WQ_* constants for IORING_REGISTER_IOWQ_MAX_WORKERS arg items
        fixed under https://bugzilla.redhat.com/show_bug.cgi?id=2107656

Omitted-fix: 4f0712ccec09 hexagon: Fix function name in die()
	unsupported arch

Omitted-fix: 751971af2e36 csky: Fix function name in csky_alignment() and die()
	unsupported arch

Omitted-fix: dcbc65aac283 ptrace: Remove duplicated include in ptrace.c
        unsupported arch

Omitted-fix: eb48d4219879 drm/i915: Fix oops due to missing stack depot
	fixed in RHEL commit 105d2d4832 Merge DRM changes from upstream v5.16..v5.17

Omitted-fix: 751a9d69b197 drm/i915: Fix oops due to missing stack depot
	fixed in RHEL commit 99fc716fc4 Merge DRM changes from upstream v5.17..v5.18

Omitted-fix: eb48d4219879 drm/i915: Fix oops due to missing stack depot
	fixed in RHEL commit 105d2d4832 Merge DRM changes from upstream v5.16..v5.17

Omitted-fix: 751a9d69b197 drm/i915: Fix oops due to missing stack depot
	fixed in RHEL commit 99fc716fc4 Merge DRM changes from upstream v5.17..v5.18

Omitted-fix: b95dc06af3e6 drm/amdgpu: disable runpm if we are the primary adapter
        reverted later

Omitted-fix: 5a90c24ad028 Revert "drm/amdgpu: disable runpm if we are the primary adapter"
        revert of above omitted fix

Omitted-fix: 724bbe49c5e4 fs/ntfs3: provide block_invalidate_folio to fix memory leak
	unsupported fs

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>

Approved-by: John W. Linville <linville@redhat.com>
Approved-by: Jiri Benc <jbenc@redhat.com>
Approved-by: Jarod Wilson <jarod@redhat.com>
Approved-by: Prarit Bhargava <prarit@redhat.com>
Approved-by: Lyude Paul <lyude@redhat.com>
Approved-by: Donald Dutile <ddutile@redhat.com>
Approved-by: Rafael Aquini <aquini@redhat.com>
Approved-by: Phil Auld <pauld@redhat.com>
Approved-by: Waiman Long <longman@redhat.com>

Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
2022-10-23 19:49:41 +02:00
Chris von Recklinghausen 1608e0ce6d fs: Pass an iocb to generic_perform_write()
Conflicts: drop changes to fs/f2fs/file.c - CONFIG_F2FS_FS not set

Bugzilla: https://bugzilla.redhat.com/2120352

commit 800ba29547e16d5fbe67ca764ba660e049e9f1bf
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Sat Feb 19 23:19:49 2022 -0500

    fs: Pass an iocb to generic_perform_write()

    We can extract both the file pointer and the pos from the iocb.
    This simplifies each caller as well as allowing generic_perform_write()
    to see more of the iocb contents in the future.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Christian Brauner <brauner@kernel.org>
    Reviewed-by: Al Viro <viro@zeniv.linux.org.uk>
    Acked-by: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2022-10-12 07:28:04 -04:00
Chris von Recklinghausen 65044383cc fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_folio
Conflicts:
	Drop changes to fs/jfs/jfs_metapage.c - CONFIG_JFS_FS is not set
	fs/ext4/inode.c - Comment block in conflict was first modified
		by
		2bb8dd401a4f ("ext4: warn when dirtying page w/o buffers in data
=journal mode")
		and an intermediary form was in merge commit
		9b03992f0c88 ("Merge tag 'ext4_for_linus' of git://git.kernel.or
g/pub/scm/linux/kernel/git/tytso/ext4")
		and that is the form this patch expects.
		Also, change 'WARN_ON_ONCE(!page_has_buffers(page));' to
		WARN_ON_ONCE(!folio_buffers(folio));
	fs/nfs/file.c - We already have
		8786fde8421c ("Convert NFS from readpages to readahead")
		so keep the line that sets .readahead

Bugzilla: https://bugzilla.redhat.com/2120352

commit 187c82cb03808ede4ee6f36aabbeb74213cd4928
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Wed Feb 9 20:22:03 2022 +0000

    fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_foli
o

    These filesystems use __set_page_dirty_nobuffers() either directly or
    with a very thin wrapper; convert them en masse.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Tested-by: Mike Marshall <hubcap@omnibond.com> # orangefs
    Tested-by: David Howells <dhowells@redhat.com> # afs

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2022-10-12 07:27:48 -04:00
Chris von Recklinghausen bb208ac175 Convert NFS from readpages to readahead
Bugzilla: https://bugzilla.redhat.com/2120352

commit 8786fde8421ce755a842051f9528674a1b1f0b9a
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Sat Jan 22 20:54:52 2022 +0000

    Convert NFS from readpages to readahead

    NFS is one of the last two users of the deprecated ->readpages aop.
    This conversion looks straightforward, but I have only compile-tested
    it.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2022-10-12 07:27:45 -04:00
Benjamin Coddington 55fe491306 NFS: Fix another fsync() issue after a server reboot
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094072

commit 67f4b5dc49913abcdb5cc736e73674e2f352f81d
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat Aug 13 08:22:25 2022 -0400

    NFS: Fix another fsync() issue after a server reboot

    Currently, when the writeback code detects a server reboot, it redirties
    any pages that were not committed to disk, and it sets the flag
    NFS_CONTEXT_RESEND_WRITES in the nfs_open_context of the file descriptor
    that dirtied the file. While this allows the file descriptor in question
    to redrive its own writes, it violates the fsync() requirement that we
    should be synchronising all writes to disk.
    While the problem is infrequent, we do see corner cases where an
    untimely server reboot causes the fsync() call to abandon its attempt to
    sync data to disk and causing data corruption issues due to missed error
    conditions or similar.

    In order to tighted up the client's ability to deal with this situation
    without introducing livelocks, add a counter that records the number of
    times pages are redirtied due to a server reboot-like condition, and use
    that in fsync() to redrive the sync to disk.

    Fixes: 2197e9b06c ("NFS: Fix up fsync() when the server rebooted")
    Cc: stable@vger.kernel.org
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2022-09-26 09:34:28 -04:00
Benjamin Coddington 253bcfb978 NFS: Do not report flush errors in nfs_write_end()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094072

commit d95b26650e86175e4a97698d89bc1626cd1df0c6
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat May 14 10:27:03 2022 -0400

    NFS: Do not report flush errors in nfs_write_end()

    If we do flush cached writebacks in nfs_write_end() due to the imminent
    expiration of an RPCSEC_GSS session, then we should defer reporting any
    resulting errors until the calls to file_check_and_advance_wb_err() in
    nfs_file_write() and nfs_file_fsync().

    Fixes: 6fbda89b25 ("NFS: Replace custom error reporting mechanism with generic one")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2022-09-26 09:34:26 -04:00
Benjamin Coddington b15829e7a8 NFS: Don't report ENOSPC write errors twice
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094072

commit e6005436f6cc9ed13288f936903f0151e5543485
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat May 14 10:27:02 2022 -0400

    NFS: Don't report ENOSPC write errors twice

    Any errors reported by the write() system call need to be cleared from
    the file descriptor's error tracking. The current call to nfs_wb_all()
    causes the error to be reported, but since it doesn't call
    file_check_and_advance_wb_err(), we can end up reporting the same error
    a second time when the application calls fsync().

    Note that since Linux 4.13, the rule is that EIO may be reported for
    write(), but it must be reported by a subsequent fsync(), so let's just
    drop reporting it in write.

    The check for nfs_ctx_key_to_expire() is just a duplicate to the one
    already in nfs_write_end(), so let's drop that too.

    Reported-by: ChenXiaoSong <chenxiaosong2@huawei.com>
    Fixes: ce368536dd ("nfs: nfs_file_write() should check for writeback errors")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2022-09-26 09:34:26 -04:00
Benjamin Coddington 2f5641f708 NFS: fsync() should report filesystem errors over EINTR/ERESTARTSYS
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094072

commit 9641d9bc9b75f11f70646f5c6ee9f5f519a1012e
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat May 14 10:27:01 2022 -0400

    NFS: fsync() should report filesystem errors over EINTR/ERESTARTSYS

    If the commit to disk is interrupted, we should still first check for
    filesystem errors so that we can report them in preference to the error
    due to the signal.

    Fixes: 2197e9b06c ("NFS: Fix up fsync() when the server rebooted")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2022-09-26 09:34:25 -04:00
Benjamin Coddington a209be954b NFS: swap IO handling is slightly different for O_DIRECT IO
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094072

commit 64158668ac8b31626a8ce48db4cad08496eb8340
Author: NeilBrown <neilb@suse.de>
Date:   Mon Mar 7 10:41:44 2022 +1100

    NFS: swap IO handling is slightly different for O_DIRECT IO

    1/ Taking the i_rwsem for swap IO triggers lockdep warnings regarding
       possible deadlocks with "fs_reclaim".  These deadlocks could, I believe,
       eventuate if a buffered read on the swapfile was attempted.

       We don't need coherence with the page cache for a swap file, and
       buffered writes are forbidden anyway.  There is no other need for
       i_rwsem during direct IO.  So never take it for swap_rw()

    2/ generic_write_checks() explicitly forbids writes to swap, and
       performs checks that are not needed for swap.  So bypass it
       for swap_rw().

    Signed-off-by: NeilBrown <neilb@suse.de>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2022-09-26 09:34:19 -04:00
Benjamin Coddington 736b1b6219 NFSv4: keep state manager thread active if swap is enabled
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094072

commit 4dc73c679114a2f408567e2e44770ed934190db2
Author: NeilBrown <neilb@suse.de>
Date:   Mon Mar 7 10:41:44 2022 +1100

    NFSv4: keep state manager thread active if swap is enabled

    If we are swapping over NFSv4, we may not be able to allocate memory to
    start the state-manager thread at the time when we need it.
    So keep it always running when swap is enabled, and just signal it to
    start.

    This requires updating and testing the cl_swapper count on the root
    rpc_clnt after following all ->cl_parent links.

    Signed-off-by: NeilBrown <neilb@suse.de>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2022-09-26 09:34:19 -04:00
Benjamin Coddington d66bd6b1e2 NFS: remove IS_SWAPFILE hack
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094072

commit 944d95f766c6fe97fa358c661281a741758cee7e
Author: NeilBrown <neilb@suse.de>
Date:   Mon Mar 7 10:41:44 2022 +1100

    NFS: remove IS_SWAPFILE hack

    This code is pointless as IS_SWAPFILE is always defined.
    So remove it.

    Suggested-by: Mark Hemment <markhemm@googlemail.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: NeilBrown <neilb@suse.de>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2022-09-26 09:34:18 -04:00
Benjamin Coddington cc8e729114 Convert NFS from readpages to readahead
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094072
Conflicts: some context difference in nfs_readpages due to mis-ordered
fscache changes.

commit 8786fde8421ce755a842051f9528674a1b1f0b9a
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Sat Jan 22 20:54:52 2022 +0000

    Convert NFS from readpages to readahead

    NFS is one of the last two users of the deprecated ->readpages aop.
    This conversion looks straightforward, but I have only compile-tested
    it.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
2022-09-26 09:34:10 -04:00
Jeffrey Layton fc6c4cab69 nfs: Convert to new fscache volume/cookie API
Bugzilla: http://bugzilla.redhat.com/1229736

commit a6b5a28eb56c3f4988f7ff5290b954ba296e309a
Author: Dave Wysochanski <dwysocha@redhat.com>
Date:   Sat Nov 14 13:43:54 2020 -0500

    nfs: Convert to new fscache volume/cookie API

    Change the nfs filesystem to support fscache's indexing rewrite and
    reenable caching in nfs.

    The following changes have been made:

     (1) The fscache_netfs struct is no more, and there's no need to register
         the filesystem as a whole.

     (2) The session cookie is now an fscache_volume cookie, allocated with
         fscache_acquire_volume().  That takes three parameters: a string
         representing the "volume" in the index, a string naming the cache to
         use (or NULL) and a u64 that conveys coherency metadata for the
         volume.

         For nfs, I've made it render the volume name string as:

            "nfs,<ver>,<family>,<address>,<port>,<fsidH>,<fsidL>*<,param>[,<uniq>]"

     (3) The fscache_cookie_def is no more and needed information is passed
         directly to fscache_acquire_cookie().  The cache no longer calls back
         into the filesystem, but rather metadata changes are indicated at
         other times.

         fscache_acquire_cookie() is passed the same keying and coherency
         information as before.

     (4) fscache_enable/disable_cookie() have been removed.

         Call fscache_use_cookie() and fscache_unuse_cookie() when a file is
         opened or closed to prevent a cache file from being culled and to keep
         resources to hand that are needed to do I/O.

         If a file is opened for writing, we invalidate it with
         FSCACHE_INVAL_DIO_WRITE in lieu of doing writeback to the cache,
         thereby making it cease caching until all currently open files are
         closed.  This should give the same behaviour as the uptream code.
         Making the cache store local modifications isn't straightforward for
         NFS, so that's left for future patches.

     (5) fscache_invalidate() now needs to be given uptodate auxiliary data and
         a file size.  It also takes a flag to indicate if this was due to a
         DIO write.

     (6) Call nfs_fscache_invalidate() with FSCACHE_INVAL_DIO_WRITE on a file
         to which a DIO write is made.

     (7) Call fscache_note_page_release() from nfs_release_page().

     (8) Use a killable wait in nfs_vm_page_mkwrite() when waiting for
         PG_fscache to be cleared.

     (9) The functions to read and write data to/from the cache are stubbed out
         pending a conversion to use netfslib.

    Changes
    =======
    ver #3:
     - Added missing =n fallback for nfs_fscache_release_file()[1][2].

    ver #2:
     - Use gfpflags_allow_blocking() rather than using flag directly.
     - fscache_acquire_volume() now returns errors.
     - Remove NFS_INO_FSCACHE as it's no longer used.
     - Need to unuse a cookie on file-release, not inode-clear.

    Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
    Co-developed-by: David Howells <dhowells@redhat.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Tested-by: Dave Wysochanski <dwysocha@redhat.com>
    Acked-by: Jeff Layton <jlayton@kernel.org>
    cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    cc: Anna Schumaker <anna.schumaker@netapp.com>
    cc: linux-nfs@vger.kernel.org
    cc: linux-cachefs@redhat.com
    Link: https://lore.kernel.org/r/202112100804.nksO8K4u-lkp@intel.com/ [1]
    Link: https://lore.kernel.org/r/202112100957.2oEDT20W-lkp@intel.com/ [2]
    Link: https://lore.kernel.org/r/163819668938.215744.14448852181937731615.stgit@warthog.procyon.org.uk/ # v1
    Link: https://lore.kernel.org/r/163906979003.143852.2601189243864854724.stgit@warthog.procyon.org.uk/ # v2
    Link: https://lore.kernel.org/r/163967182112.1823006.7791504655391213379.stgit@warthog.procyon.org.uk/ # v3
    Link: https://lore.kernel.org/r/164021575950.640689.12069642327533368467.stgit@warthog.procyon.org.uk/ # v4

Signed-off-by: Jeffrey Layton <jlayton@redhat.com>
2022-08-22 12:32:16 -04:00
Scott Mayhew 3b5a1a2f0c nfs: don't allow reexport reclaims
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2049200
Conflicts:
    fs/nfs/file.c - minor context difference due to RHEL commit 5b7ac1214f
    ("fs: remove mandatory file locking support")

commit bb0a55bb7148a49e549ee992200860e7a040d3a5
Author: J. Bruce Fields <bfields@redhat.com>
Date:   Fri Aug 20 17:02:06 2021 -0400

    nfs: don't allow reexport reclaims

    In the reexport case, nfsd is currently passing along locks with the
    reclaim bit set.  The client sends a new lock request, which is granted
    if there's currently no conflict--even if it's possible a conflicting
    lock could have been briefly held in the interim.

    We don't currently have any way to safely grant reclaim, so for now
    let's just deny them all.

    I'm doing this by passing the reclaim bit to nfs and letting it fail the
    call, with the idea that eventually the client might be able to do
    something more forgiving here.

    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Acked-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
2022-02-03 11:39:49 -05:00
Jeffrey Layton 23e989128b locks: remove LOCK_MAND flock lock support
Bugzilla: http://bugzilla.redhat.com/2017438

commit 90f7d7a0d0d68623b5f7df5621a8d54d9518fcc4
Author: Jeff Layton <jlayton@kernel.org>
Date:   Fri Sep 10 15:36:29 2021 -0400

    locks: remove LOCK_MAND flock lock support

    As best I can tell, the logic for these has been broken for a long time
    (at least before the move to git), such that they never conflict with
    anything. Also, nothing checks for these flags and prevented opens or
    read/write behavior on the files. They don't seem to do anything.

    Given that, we can rip these symbols out of the kernel, and just make
    flock(2) return 0 when LOCK_MAND is set in order to preserve existing
    behavior.

    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Jeff Layton <jlayton@kernel.org>

Signed-off-by: Jeffrey Layton <jlayton@redhat.com>
2021-11-01 13:56:12 -04:00
Jeffrey Layton 5b7ac1214f fs: remove mandatory file locking support
Bugzilla: http://bugzilla.redhat.com/2017438

commit f7e33bdbd6d1bdf9c3df8bba5abcf3399f957ac3
Author: Jeff Layton <jlayton@kernel.org>
Date:   Thu Aug 19 14:56:38 2021 -0400

    fs: remove mandatory file locking support

    We added CONFIG_MANDATORY_FILE_LOCKING in 2015, and soon after turned it
    off in Fedora and RHEL8. Several other distros have followed suit.

    I've heard of one problem in all that time: Someone migrated from an
    older distro that supported "-o mand" to one that didn't, and the host
    had a fstab entry with "mand" in it which broke on reboot. They didn't
    actually _use_ mandatory locking so they just removed the mount option
    and moved on.

    This patch rips out mandatory locking support wholesale from the kernel,
    along with the Kconfig option and the Documentation file. It also
    changes the mount code to ignore the "mand" mount option instead of
    erroring out, and to throw a big, ugly warning.

    Signed-off-by: Jeff Layton <jlayton@kernel.org>

Signed-off-by: Jeffrey Layton <jlayton@redhat.com>
2021-11-01 13:56:12 -04:00