From: NeilBrown <neilb@suse.de>
To: Carlos Maiolino <cmaiolino@redhat.com>, linux-fsdevel@vger.kernel.org
Cc: hch@lst.de, viro@zeniv.linux.org.uk, David Howells <dhowells@redhat.com>
Subject: Re: [PATCH 2/5] cachefiles: drop direct usage of ->bmap method.
Date: Thu, 09 Apr 2020 10:32:26 +1000 [thread overview]
Message-ID: <87tv1tv6qt.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20200109133045.382356-3-cmaiolino@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3575 bytes --]
On Thu, Jan 09 2020, Carlos Maiolino wrote:
> Replace the direct usage of ->bmap method by a bmap() call.
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> fs/cachefiles/rdwr.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
> index 44a3ce1e4ce4..1dc97f2d6201 100644
> --- a/fs/cachefiles/rdwr.c
> +++ b/fs/cachefiles/rdwr.c
> @@ -396,7 +396,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
> struct cachefiles_object *object;
> struct cachefiles_cache *cache;
> struct inode *inode;
> - sector_t block0, block;
> + sector_t block;
> unsigned shift;
> int ret;
>
> @@ -412,7 +412,6 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
>
> inode = d_backing_inode(object->backer);
> ASSERT(S_ISREG(inode->i_mode));
> - ASSERT(inode->i_mapping->a_ops->bmap);
> ASSERT(inode->i_mapping->a_ops->readpages);
>
> /* calculate the shift required to use bmap */
> @@ -428,12 +427,14 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
> * enough for this as it doesn't indicate errors, but it's all we've
> * got for the moment
> */
> - block0 = page->index;
> - block0 <<= shift;
> + block = page->index;
> + block <<= shift;
> +
> + ret = bmap(inode, &block);
> + ASSERT(ret < 0);
>
> - block = inode->i_mapping->a_ops->bmap(inode->i_mapping, block0);
> _debug("%llx -> %llx",
> - (unsigned long long) block0,
> + (unsigned long long) (page->index << shift),
> (unsigned long long) block);
>
> if (block) {
> @@ -711,7 +712,6 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
>
> inode = d_backing_inode(object->backer);
> ASSERT(S_ISREG(inode->i_mode));
> - ASSERT(inode->i_mapping->a_ops->bmap);
> ASSERT(inode->i_mapping->a_ops->readpages);
>
> /* calculate the shift required to use bmap */
> @@ -728,7 +728,7 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
>
> ret = space ? -ENODATA : -ENOBUFS;
> list_for_each_entry_safe(page, _n, pages, lru) {
> - sector_t block0, block;
> + sector_t block;
>
> /* we assume the absence or presence of the first block is a
> * good enough indication for the page as a whole
> @@ -736,13 +736,14 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
> * good enough for this as it doesn't indicate errors, but
> * it's all we've got for the moment
> */
> - block0 = page->index;
> - block0 <<= shift;
> + block = page->index;
> + block <<= shift;
> +
> + ret = bmap(inode, &block);
> + ASSERT(!ret);
Hi,
this change corrupts 'ret'.
Some paths from here down change ret, but some paths to do not.
So it is possible that this function would previously return -ENODATA
or -ENOBUFS, but now it returns 0.
This gets caught by a BUG_ON in __nfs_readpages_from_fscache().
Maybe a new variable should be introduced?
or maybe ASSERT(!bmap(..));
Or maybe if (bmap() != 0) ASSET(0);
??
https://bugzilla.opensuse.org/show_bug.cgi?id=1168841
NeilBrown
>
> - block = inode->i_mapping->a_ops->bmap(inode->i_mapping,
> - block0);
> _debug("%llx -> %llx",
> - (unsigned long long) block0,
> + (unsigned long long) (page->index << shift),
> (unsigned long long) block);
>
> if (block) {
> --
> 2.23.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2020-04-09 0:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-09 13:30 [PATCH V8 0/5] Refactor ioctl_fibmap() internal interface Carlos Maiolino
2020-01-09 13:30 ` [PATCH 1/5] fs: Enable bmap() function to properly return errors Carlos Maiolino
2020-01-09 13:30 ` [PATCH 2/5] cachefiles: drop direct usage of ->bmap method Carlos Maiolino
2020-04-09 0:32 ` NeilBrown [this message]
2020-04-16 14:03 ` David Wysochanski
2020-01-09 13:30 ` [PATCH 3/5] ecryptfs: drop direct calls to ->bmap Carlos Maiolino
2020-01-09 13:30 ` [PATCH 4/5] fibmap: Use bmap instead of ->bmap method in ioctl_fibmap Carlos Maiolino
2020-01-09 13:30 ` [PATCH 5/5] fibmap: Reject negative block numbers Carlos Maiolino
2020-01-09 15:05 ` [PATCH V8 0/5] Refactor ioctl_fibmap() internal interface Al Viro
-- strict thread matches above, loose matches on Subject: below --
2019-12-10 15:03 [PATCH " Carlos Maiolino
2019-12-10 15:03 ` [PATCH 2/5] cachefiles: drop direct usage of ->bmap method Carlos Maiolino
2019-11-22 8:53 [PATCH 0/5] Refactor ioctl_fibmap() internal interface Carlos Maiolino
2019-11-22 8:53 ` [PATCH 2/5] cachefiles: drop direct usage of ->bmap method Carlos Maiolino
2019-11-22 13:37 ` Christoph Hellwig
2019-11-22 14:04 ` Carlos Maiolino
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=87tv1tv6qt.fsf@notabene.neil.brown.name \
--to=neilb@suse.de \
--cc=cmaiolino@redhat.com \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).