From: Jan Kara <jack@suse.cz>
To: rdodgen@gmail.com
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu,
Randy Dodgen <dodgen@google.com>,
linux-nvdimm@lists.01.org
Subject: Re: [PATCH v3] Fix ext4 fault handling when mounted with -o dax,ro
Date: Thu, 24 Aug 2017 16:45:44 +0200 [thread overview]
Message-ID: <20170824144544.GE8969@quack2.suse.cz> (raw)
In-Reply-To: <416a465a9fbe1d27085883dbf652c115cd195697.1503523424.git.dodgen@google.com>
On Wed 23-08-17 14:26:52, rdodgen@gmail.com wrote:
> From: Randy Dodgen <dodgen@google.com>
>
> If an ext4 filesystem is mounted with both the DAX and read-only
> options, executables on that filesystem will fail to start (claiming
> 'Segmentation fault') due to the fault handler returning
> VM_FAULT_SIGBUS.
>
> This is due to the DAX fault handler (see ext4_dax_huge_fault)
> attempting to write to the journal when FAULT_FLAG_WRITE is set. This is
> the wrong behavior for write faults which will lead to a COW page; in
> particular, this fails for readonly mounts.
>
> This change avoids journal writes for faults that are expected to COW.
>
> It might be the case that this could be better handled in
> ext4_iomap_begin / ext4_iomap_end (called via iomap_ops inside
> dax_iomap_fault). These is some overlap already (e.g. grabbing journal
> handles).
>
> Signed-off-by: Randy Dodgen <dodgen@google.com>
Thanks for the verbose comment :). The patch looks good to me. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
>
> This version is simplified as suggested by Ross; all fault sizes and fallbacks
> are handled by dax_iomap_fault.
>
> fs/ext4/file.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index 0d7cf0cc9b87..dc1e1fb6b54c 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -279,7 +279,20 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf,
> handle_t *handle = NULL;
> struct inode *inode = file_inode(vmf->vma->vm_file);
> struct super_block *sb = inode->i_sb;
> - bool write = vmf->flags & FAULT_FLAG_WRITE;
> +
> + /*
> + * We have to distinguish real writes from writes which will result in a
> + * COW page; COW writes should *not* poke the journal (the file will not
> + * be changed). Doing so would cause unintended failures when mounted
> + * read-only.
> + *
> + * We check for VM_SHARED rather than vmf->cow_page since the latter is
> + * unset for pe_size != PE_SIZE_PTE (i.e. only in do_cow_fault); for
> + * other sizes, dax_iomap_fault will handle splitting / fallback so that
> + * we eventually come back with a COW page.
> + */
> + bool write = (vmf->flags & FAULT_FLAG_WRITE) &&
> + (vmf->vma->vm_flags & VM_SHARED);
>
> if (write) {
> sb_start_pagefault(sb);
> --
> 2.14.1.342.g6490525c54-goog
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2017-08-24 14:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20170822222434.146233-1-dodgen@google.com>
2017-08-23 3:37 ` [PATCH v2] Fix ext4 fault handling when mounted with -o dax,ro rdodgen
2017-08-23 16:38 ` Ross Zwisler
2017-08-23 20:11 ` Randy Dodgen
2017-08-23 21:26 ` [PATCH v3] " rdodgen
2017-08-24 14:45 ` Jan Kara [this message]
2017-08-24 15:11 ` Ross Zwisler
2017-08-24 16:01 ` Christoph Hellwig
2017-08-24 20:57 ` Theodore Ts'o
2017-08-25 7:28 ` Christoph Hellwig
2017-08-29 21:20 ` Christoph Hellwig
2017-08-29 21:37 ` Ross Zwisler
2017-08-29 22:07 ` Randy Dodgen
2017-08-29 22:37 ` [fstests PATCH] generic: add test for executables on read-only DAX mounts Ross Zwisler
2017-08-30 10:59 ` Eryu Guan
2017-08-31 4:01 ` Ross Zwisler
2017-08-31 4:09 ` [fstests v2] " Ross Zwisler
2017-08-30 14:51 ` [fstests PATCH] " Christoph Hellwig
2017-08-31 4:02 ` Ross Zwisler
2017-08-31 13:09 ` Christoph Hellwig
2017-08-24 19:26 ` [PATCH v3] Fix ext4 fault handling when mounted with -o dax,ro Theodore Ts'o
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=20170824144544.GE8969@quack2.suse.cz \
--to=jack@suse.cz \
--cc=dodgen@google.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=rdodgen@gmail.com \
--cc=tytso@mit.edu \
/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