From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
Ross Zwisler <ross.zwisler@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Andy Lutomirski <luto@kernel.org>,
linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH 4/7] dax: Make dax_insert_mapping() return VM_FAULT_ state
Date: Thu, 27 Jul 2017 16:22:30 -0600 [thread overview]
Message-ID: <20170727222230.GE22000@linux.intel.com> (raw)
In-Reply-To: <20170727131245.28279-5-jack@suse.cz>
On Thu, Jul 27, 2017 at 03:12:42PM +0200, Jan Kara wrote:
> Currently dax_insert_mapping() returns normal error code which is later
> converted to VM_FAULT_ state. Since we will need to do more state
> modifications specific to dax_insert_mapping() it does not make sense to
> push them up to the caller of dax_insert_mapping(). Instead make
> dax_insert_mapping() return VM_FAULT_ state the same way as
> dax_pmd_insert_mapping() does that.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/dax.c | 45 +++++++++++++++++++++++++--------------------
> 1 file changed, 25 insertions(+), 20 deletions(-)
>
> diff --git a/fs/dax.c b/fs/dax.c
> index 0673efd72f53..9658975b926a 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -814,6 +814,15 @@ int dax_writeback_mapping_range(struct address_space *mapping,
> }
> EXPORT_SYMBOL_GPL(dax_writeback_mapping_range);
>
> +static int dax_fault_return(int error)
> +{
> + if (error == 0)
> + return VM_FAULT_NOPAGE;
> + if (error == -ENOMEM)
> + return VM_FAULT_OOM;
> + return VM_FAULT_SIGBUS;
> +}
> +
> static sector_t dax_iomap_sector(struct iomap *iomap, loff_t pos)
> {
> return iomap->blkno + (((pos & PAGE_MASK) - iomap->offset) >> 9);
> @@ -828,7 +837,7 @@ static int dax_insert_mapping(struct vm_fault *vmf, struct iomap *iomap,
> unsigned long vaddr = vmf->address;
> void *ret, *kaddr;
> pgoff_t pgoff;
> - int id, rc;
> + int id, rc, vmf_ret;
> pfn_t pfn;
>
> rc = bdev_dax_pgoff(iomap->bdev, sector, PAGE_SIZE, &pgoff);
> @@ -850,9 +859,18 @@ static int dax_insert_mapping(struct vm_fault *vmf, struct iomap *iomap,
>
> trace_dax_insert_mapping(mapping->host, vmf, ret);
> if (vmf->flags & FAULT_FLAG_WRITE)
> - return vm_insert_mixed_mkwrite(vma, vaddr, pfn);
> + rc = vm_insert_mixed_mkwrite(vma, vaddr, pfn);
> else
> - return vm_insert_mixed(vma, vaddr, pfn);
> + rc = vm_insert_mixed(vma, vaddr, pfn);
> +
> + /* -EBUSY is fine, somebody else faulted on the same PTE */
> + if (rc == -EBUSY)
> + rc = 0;
> +
> + vmf_ret = dax_fault_return(rc);
Prior to this point where we convert our 'rc' (which is a normal error code
like 0, -ENOMEM, etc) to a 'vmf_ret' (which is a VM return code like
VM_FAULT_NOPAGE, VM_FAULT_SIGBUS, etc), there are several paths in
dax_insert_mapping() where we could still return a normal error code. I think
this will confuse the fault handler because this code will get returned all
the way up to do_fault() which expects to get a VM return code.
So, I think we either need to:
a) Make sure all return paths through dax_insert_mapping() end up going
through dax_fault_return(), as we do in the PMD case, or
b) Keep allowing this function to return normal error codes, and just teach
dax_fault_return() to look for IOMAP_F_NEEDSYNC flag so it knows when to set
VM_FAULT_RO.
next prev parent reply other threads:[~2017-07-27 22:22 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-27 13:12 [RFC PATCH 0/7] dax, ext4: Synchronous page faults Jan Kara
2017-07-27 13:12 ` [PATCH 1/7] mm: Remove VM_FAULT_HWPOISON_LARGE_MASK Jan Kara
2017-07-27 21:57 ` Ross Zwisler
2017-08-01 10:52 ` Christoph Hellwig
2017-07-27 13:12 ` [PATCH 2/7] dax: Add sync argument to dax_iomap_fault() Jan Kara
2017-07-27 22:06 ` Ross Zwisler
2017-07-28 9:40 ` Jan Kara
2017-07-27 13:12 ` [PATCH 3/7] dax: Simplify arguments of dax_insert_mapping() Jan Kara
2017-07-27 22:09 ` Ross Zwisler
2017-08-01 10:54 ` Christoph Hellwig
2017-07-27 13:12 ` [PATCH 4/7] dax: Make dax_insert_mapping() return VM_FAULT_ state Jan Kara
2017-07-27 22:22 ` Ross Zwisler [this message]
2017-07-28 9:43 ` Jan Kara
2017-07-27 13:12 ` [PATCH 5/7] dax, iomap: Add support for synchronous faults Jan Kara
2017-07-27 22:42 ` Ross Zwisler
2017-08-01 10:56 ` Christoph Hellwig
2017-07-27 13:12 ` [PATCH 6/7] dax: Implement dax_pfn_mkwrite() Jan Kara
2017-07-27 22:53 ` Ross Zwisler
2017-07-27 23:04 ` Ross Zwisler
2017-07-28 10:37 ` Jan Kara
2017-07-27 13:12 ` [PATCH 7/7] ext4: Support for synchronous DAX faults Jan Kara
2017-07-27 22:57 ` Ross Zwisler
2017-07-27 14:09 ` [RFC PATCH 0/7] dax, ext4: Synchronous page faults Jeff Moyer
2017-07-27 21:57 ` Ross Zwisler
2017-07-28 2:05 ` Andy Lutomirski
2017-07-28 9:38 ` Jan Kara
2017-08-01 11:02 ` Christoph Hellwig
2017-08-01 11:26 ` Jan Kara
2017-08-08 0:24 ` Dan Williams
2017-08-11 10:03 ` Christoph Hellwig
2017-08-13 2:44 ` Dan Williams
2017-08-13 9:25 ` Christoph Hellwig
2017-08-13 17:08 ` Dan Williams
2017-08-14 8:30 ` Jan Kara
2017-08-14 14:04 ` Boaz Harrosh
2017-08-14 16:03 ` Dan Williams
2017-08-15 9:06 ` Boaz Harrosh
2017-08-15 9:44 ` Boaz Harrosh
2017-08-21 19:57 ` Ross Zwisler
2017-08-17 16:08 ` Jan Kara
2017-08-01 10:52 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170727222230.GE22000@linux.intel.com \
--to=ross.zwisler@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=linux-xfs@vger.kernel.org \
--cc=luto@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).