linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Evgeniy Dushistov <dushistov@mail.ru>,
	Ira Weiny <ira.weiny@intel.com>,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/3] fs/ufs: Replace kmap() with kmap_local_page()
Date: Sun, 11 Dec 2022 22:39:44 +0000	[thread overview]
Message-ID: <Y5ZcMPzPG9h6C9eh@ZenIV> (raw)
In-Reply-To: <20221211213111.30085-4-fmdefrancesco@gmail.com>

On Sun, Dec 11, 2022 at 10:31:11PM +0100, Fabio M. De Francesco wrote:

> +/*
> + * Calls to ufs_get_page()/ufs_put_page() must be nested according to the
> + * rules documented in kmap_local_page()/kunmap_local().
> + *
> + * NOTE: ufs_find_entry() and ufs_dotdot() act as calls to ufs_get_page()
> + * and must be treated accordingly for nesting purposes.
> + */
>  static void *ufs_get_page(struct inode *dir, unsigned long n, struct page **page)
>  {
> +	char *kaddr;
> +
>  	struct address_space *mapping = dir->i_mapping;
>  	*page = read_mapping_page(mapping, n, NULL);
>  	if (!IS_ERR(*page)) {
> -		kmap(*page);
> +		kmap_local_page(*page);
>  		if (unlikely(!PageChecked(*page))) {
> -			if (!ufs_check_page(*page))
> +			if (!ufs_check_page(*page, kaddr))

	Er...  Building the patched tree is occasionally useful.
Here kaddr is obviously uninitialized and compiler would've
probably caught that.

	And return value of kmap_local_page() is lost, which
is related to the previous issue ;-)


>  				goto fail;
>  		}
>  	}
> -	return page;
> +	return *page;

Hell, no.  Callers expect the pointer to the first byte of
your page.  What it should return is kaddr.

> @@ -388,7 +406,8 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
>  	mark_inode_dirty(dir);
>  	/* OFFSET_CACHE */
>  out_put:
> -	ufs_put_page(page);
> +	ufs_put_page(page, kaddr);
> +	return 0;
>  out_unlock:
>  	unlock_page(page);
>  	goto out_put;

That can't be right.  Places like
        if (err)
		goto out_unlock;
do not expect err to be lost.  You end up returning 0 now.  Something strange
happened here (in the previous commit, perhaps?)

  reply	other threads:[~2022-12-11 22:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11 21:31 [PATCH 0/3] fs/ufs: replace kmap() with kmap_local_page() Fabio M. De Francesco
2022-12-11 21:31 ` [PATCH 1/3] fs/ufs: Use the offset_in_page() helper Fabio M. De Francesco
2022-12-11 21:31 ` [PATCH 2/3] fs/ufs: Change the signature of ufs_get_page() Fabio M. De Francesco
2022-12-11 22:29   ` Al Viro
2022-12-11 23:56     ` Fabio M. De Francesco
2022-12-11 22:42   ` Al Viro
2022-12-12 20:08     ` Fabio M. De Francesco
2022-12-11 21:31 ` [PATCH 3/3] fs/ufs: Replace kmap() with kmap_local_page() Fabio M. De Francesco
2022-12-11 22:39   ` Al Viro [this message]
2022-12-12  0:14     ` Fabio M. De Francesco
2022-12-12  0:52   ` kernel test robot
2022-12-12  1:07     ` Al Viro

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=Y5ZcMPzPG9h6C9eh@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=bpf@vger.kernel.org \
    --cc=dushistov@mail.ru \
    --cc=fmdefrancesco@gmail.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.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).