[RHEL7,COMMIT] ms/mm: fix mapping_set_error call in me_pagecache_dirty

Submitted by Konstantin Khorenko on June 9, 2018, 10:29 a.m.


Message ID 201806091029.w59ATUaN023938@finist_ce7.work
State New
Series "ms/mm: fix mapping_set_error call in me_pagecache_dirty"
Headers show

Commit Message

Konstantin Khorenko June 9, 2018, 10:29 a.m.
The commit is pushed to "branch-rh7-3.10.0-862.vz7.48.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.el7
commit 5b3f955ea90904f3a9be04d982b93b48092e9bb6
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Sat Jun 9 13:29:30 2018 +0300

    ms/mm: fix mapping_set_error call in me_pagecache_dirty
    mainline commit af21bfa ("mm: fix mapping_set_error call in me_pagecache_dirty")
    The error code should be negative.  Since this ends up in the default case
    anyway, this is harmless, but it's less confusing to negate it.  Also,
    later patches will require a negative error code here.
    Link: http://lkml.kernel.org/r/20170525103355.6760-1-jlayton@redhat.com
    Signed-off-by: Jeff Layton <jlayton@redhat.com>
    Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Patchset description:
    [PATH RH7 00/16] Writeback error handling updates
    ANK requested to backport mainline commit 088737f44bbf6378745f5b57b035e57ee3dc4750
     Pull Writeback error handling updates from Jeff Layton
         "This pile represents the bulk of the writeback error handling fixes
          that I have for this cycle. Some of the earlier patches in this pile
          may look trivial but they are prerequisites for later patches in the
          The aim of this set is to improve how we track and report writeback
          errors to userland. Most applications that care about data integrity
          will periodically call fsync/fdatasync/msync to ensure that their
          writes have made it to the backing store.
          For a very long time, we have tracked writeback errors using two flags
          in the address_space: AS_EIO and AS_ENOSPC. Those flags are set when a
          writeback error occurs (via mapping_set_error) and are cleared as a
          side-effect of filemap_check_errors (as you noted yesterday). This
          model really sucks for userland.
          Only the first task to call fsync (or msync or fdatasync) will see the
          error. Any subsequent task calling fsync on a file will get back 0
          (unless another writeback error occurs in the interim). If I have
          several tasks writing to a file and calling fsync to ensure that their
          writes got stored, then I need to have them coordinate with one
          another. That's difficult enough, but in a world of containerized
          setups that coordination may even not be possible.
          But wait...it gets worse!
          The calls to filemap_check_errors can be buried pretty far down in the
          call stack, and there are internal callers of filemap_write_and_wait
          and the like that also end up clearing those errors. Many of those
          callers ignore the error return from that function or return it to
          userland at nonsensical times (e.g. truncate() or stat()). If I get
          back -EIO on a truncate, there is no reason to think that it was
          because some previous writeback failed, and a subsequent fsync() will
          (incorrectly) return 0.
          This pile aims to do three things:
           1) ensure that when a writeback error occurs that that error will be
              reported to userland on a subsequent fsync/fdatasync/msync call,
              regardless of what internal callers are doing
           2) report writeback errors on all file descriptions that were open at
              the time that the error occurred. This is a user-visible change,
              but I think most applications are written to assume this behavior
              anyway. Those that aren't are unlikely to be hurt by it.
           3) document what filesystems should do when there is a writeback
              error. Today, there is very little consistency between them, and a
              lot of cargo-cult copying. We need to make it very clear what
              filesystems should do in this situation.
          To achieve this, the set adds a new data type (errseq_t) and then
          builds new writeback error tracking infrastructure around that. Once
          all of that is in place, we change the filesystems to use the new
          infrastructure for reporting wb errors to userland.
          Note that this is just the initial foray into cleaning up this mess.
          There is a lot of work remaining here:
           1) convert the rest of the filesystems in a similar fashion. Once the
              initial set is in, then I think most other fs' will be fairly
              simple to convert. Hopefully most of those can in via individual
              filesystem trees.
           2) convert internal waiters on writeback to use errseq_t for
              detecting errors instead of relying on the AS_* flags. I have some
              draft patches for this for ext4, but they are not quite ready for
              prime time yet.
          This was a discussion topic this year at LSF/MM too. If you're
          interested in the gory details, LWN has some good articles about this:
    Jeff Layton (16):
      mm: fix mapping_set_error call in me_pagecache_dirty
      buffer: use mapping_set_error instead of setting the flag
      fs: check for writeback errors after syncing out buffers in
      buffer: set errors in mapping at the time that the error occurs
      jbd2: don't clear and reset errors after waiting on writeback
      mm: clear AS_EIO/AS_ENOSPC when writeback initiation fails
      mm: don't TestClearPageError in __filemap_fdatawait_range
      lib: add errseq_t type and infrastructure for handling it
      fs: new infrastructure for writeback error handling and reporting
      mm: set both AS_EIO/AS_ENOSPC and errseq_t in mapping_set_error
      Documentation: flesh out the section in vfs.txt on storing and
        reporting writeback errors
      dax: set errors in mapping when writeback fails
      block: convert to errseq_t based writeback error tracking
      ext4: use errseq_t based error handling for reporting data writeback
      xfs: minimal conversion to errseq_t writeback error reporting
      btrfs: minimal conversion to errseq_t writeback error reporting on
     Documentation/filesystems/vfs.txt |  44 +++++++-
     MAINTAINERS                       |   6 ++
     drivers/dax/device.c              |   1 +
     fs/block_dev.c                    |   3 +-
     fs/btrfs/file.c                   |  13 ++-
     fs/buffer.c                       |  20 ++--
     fs/dax.c                          |   4 +-
     fs/ext2/file.c                    |   5 +-
     fs/ext4/fsync.c                   |   2 +-
     fs/file_table.c                   |   1 +
     fs/gfs2/lops.c                    |   2 +-
     fs/jbd2/commit.c                  |  17 +---
     fs/libfs.c                        |   6 +-
     fs/open.c                         |   3 +
     fs/xfs/xfs_file.c                 |   2 +-
     include/linux/buffer_head.h       |   1 +
     include/linux/errseq.h            |  19 ++++
     include/linux/fs.h                |  62 +++++++++++-
     include/linux/pagemap.h           |  31 ++++--
     include/trace/events/filemap.h    |  57 +++++++++++
     lib/Makefile                      |   2 +-
     lib/errseq.c                      | 208 ++++++++++++++++++++++++++++++++++++++
     mm/filemap.c                      | 126 +++++++++++++++++++----
     mm/memory-failure.c               |   2 +-
     24 files changed, 572 insertions(+), 65 deletions(-)
     create mode 100644 include/linux/errseq.h
     create mode 100644 lib/errseq.c
 mm/memory-failure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index ea04d53a2c83..3e71a82f9c89 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -677,7 +677,7 @@  static int me_pagecache_dirty(struct page *p, unsigned long pfn)
 		 * the first EIO, but we're not worse than other parts
 		 * of the kernel.
-		mapping_set_error(mapping, EIO);
+		mapping_set_error(mapping, -EIO);
 	return me_pagecache_clean(p, pfn);