From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: willy@infradead.org, adilger.kernel@dilger.ca,
darrick.wong@oracle.com, axboe@kernel.dk, agruenba@redhat.com,
ebiggers@google.com, gregkh@linuxfoundation.org,
kemi.wang@intel.com, sabyasachi.linux@gmail.com,
brajeswar.linux@gmail.com, linux-ext4@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ext4: Convert int to vm_fault_t type
Date: Wed, 1 Aug 2018 08:55:12 -0400 [thread overview]
Message-ID: <20180801125512.GA10761@thunk.org> (raw)
In-Reply-To: <20180728085000.GA9136@jordon-HP-15-Notebook-PC>
On Sat, Jul 28, 2018 at 02:20:00PM +0530, Souptick Joarder wrote:
> Use new return type vm_fault_t for ext4_page_mkwrite
> handler and block_page_mkwrite_return.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
FYI, this patch was very sloppy, and didn't do the right thing. That's
because of how you messed with the changing how the return codes are
now handled.
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -6108,27 +6108,27 @@ static int ext4_bh_unmapped(handle_t *handle, struct buffer_head *bh)
> return !buffer_mapped(bh);
> }
>
> -int ext4_page_mkwrite(struct vm_fault *vmf)
> +vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf)
> {
> struct vm_area_struct *vma = vmf->vma;
> struct page *page = vmf->page;
> loff_t size;
> unsigned long len;
> - int ret;
> + vm_fault_t ret;
> struct file *file = vma->vm_file;
> struct inode *inode = file_inode(file);
> struct address_space *mapping = inode->i_mapping;
> handle_t *handle;
> get_block_t *get_block;
> - int retries = 0;
> + int retries = 0, err;
OK, ret now is a vm_fault_t, and err is an error return....
> @@ -6138,9 +6138,9 @@ int ext4_page_mkwrite(struct vm_fault *vmf)
> do {
> ret = block_page_mkwrite(vma, vmf,
> ext4_da_get_block_prep);
But block_page_mkwrite() still returns an int, not a vm_fault_t....
> - } while (ret == -ENOSPC &&
> + } while (ret == VM_FAULT_SIGBUS &&
> ext4_should_retry_alloc(inode->i_sb, &retries));
So this is Just wrong, This needed to be:
do {
err = block_page_mkwrite(vma, vmf,
ext4_da_get_block_prep);
} while (err == -ENOSPC &&
ext4_should_retry_alloc(inode->i_sb, &retries));
goto out_ret;
That's because out_ret is what will translate the int error code to
the vm_fault_t via:
ret = block_page_mkwrite_return(err);
The fact that ext4_page_mkwrite() returns a vm_fault_t, while
block_page_mkwrite() returns an int which then has to get translated
into a vm_fault_t via block_page_mkwrite_return() is I suspect going
to confuse an awful lot of callers.
I'll fix up the patch, but I just wanted to call your attention to
this pitfall in the patch which confused even you as the patch author....
(BTW, the buggy patch triggered a new failure, ext4/307, which is how
I noticed that the patch was all wrong. If you had run any kind of
static code checker you would have noticed that block_page_mkwrite()
was returning an int and that was getting assigned into a variable of
type vm_fault_t. The fact that you *didn't* notice makes me worry
that all of this code churn may, in the end, not actually help us as
much as we thought. :-(
- Ted
next prev parent reply other threads:[~2018-08-01 12:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-28 8:50 [PATCH] ext4: Convert int to vm_fault_t type Souptick Joarder
2018-07-28 8:49 ` Souptick Joarder
2018-08-01 12:55 ` Theodore Y. Ts'o [this message]
2018-08-01 13:04 ` Souptick Joarder
2018-08-01 13:11 ` Souptick Joarder
2018-08-01 13:13 ` Matthew Wilcox
2018-08-01 13:26 ` Souptick Joarder
2018-08-01 14:38 ` Theodore Y. Ts'o
2018-08-01 16:06 ` Theodore Y. Ts'o
2018-08-01 16:13 ` Matthew Wilcox
2018-08-01 16:22 ` Theodore Y. 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=20180801125512.GA10761@thunk.org \
--to=tytso@mit.edu \
--cc=adilger.kernel@dilger.ca \
--cc=agruenba@redhat.com \
--cc=axboe@kernel.dk \
--cc=brajeswar.linux@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=ebiggers@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jrdr.linux@gmail.com \
--cc=kemi.wang@intel.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sabyasachi.linux@gmail.com \
--cc=willy@infradead.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).