public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Al Viro <viro@zeniv.linux.org.uk>, Al Viro <viro@zeniv.linux.org.uk>
Cc: Evgeniy Dushistov <dushistov@mail.ru>,
	Ira Weiny <ira.weiny@intel.com>,
	linux-kernel@vger.kernel.org, Jeff Moyer <jmoyer@redhat.com>,
	Evgeniy Dushistov <dushistov@mail.ru>,
	Ira Weiny <ira.weiny@intel.com>,
	linux-kernel@vger.kernel.org, Jeff Moyer <jmoyer@redhat.com>
Subject: Re: [PATCH v2 2/3] fs/ufs: Change the signature of ufs_get_page()
Date: Tue, 13 Dec 2022 20:08:22 +0100	[thread overview]
Message-ID: <3174926.0WQXIW03uk@suse> (raw)
In-Reply-To: <Y5glgpD7fFifC4Fi@ZenIV>

On martedì 13 dicembre 2022 08:10:58 CET Al Viro wrote:
> On Tue, Dec 13, 2022 at 12:19:05AM +0100, Fabio M. De Francesco wrote:
> > +static void *ufs_get_page(struct inode *dir, unsigned long n, struct page
> > **page)> 
> >  {
> >  
> >  	struct address_space *mapping = dir->i_mapping;
> > 
> > -	struct page *page = read_mapping_page(mapping, n, NULL);
> > -	if (!IS_ERR(page)) {
> > -		kmap(page);
> > -		if (unlikely(!PageChecked(page))) {
> > -			if (!ufs_check_page(page))
> > +	*page = read_mapping_page(mapping, n, NULL);
> > +	if (!IS_ERR(*page)) {
> > +		kmap(*page);
> > +		if (unlikely(!PageChecked(*page))) {
> > +			if (!ufs_check_page(*page))
> > 
> >  				goto fail;
> >  		
> >  		}
> >  	
> >  	}
> > 
> > -	return page;
> > +	return page_address(*page);
> 
> Er...   You really don't want to do that when you've got ERR_PTR()
> from read_mapping_page().
> 

Sure :-)

Obviously, I'll fix it ASAP.

But I can't yet understand why that pointer was returned unconditionally in 
the code which I'm changing with this patch (i.e., regardless of any potential  
errors from read_mapping_page()) :-/ 

>
> >  fail:
> > -	ufs_put_page(page);
> > +	ufs_put_page(*page);
> > 
> >  	return ERR_PTR(-EIO);
> >  
> >  }
> 
> IDGI...
> 
> static void *ufs_get_page(struct inode *dir, unsigned long n, struct page 
**p)
> {
> 	struct address_space *mapping = dir->i_mapping;
> 	struct page *page = read_mapping_page(mapping, n, NULL);
> 
> 	if (!IS_ERR(page)) {
> 		kmap(page);
> 		if (unlikely(!PageChecked(page))) {
> 			if (!ufs_check_page(page))
> 				goto fail;
> 		}
> 		*p = page;
> 		return page_address(page);
> 	}
> 	return ERR_CAST(page);
> 
> fail:
> 	ufs_put_page(page);
> 	return ERR_PTR(-EIO);
> }
> 
> all there is to it...  The only things you need to change are
> 1) type of function
> 2) make sure to store the page into that pointer to pointer to page on 
success
> 3) return page_address(page) instead of page on success
> 4) use ERR_CAST() to convert ERR_PTR() that is struct page * into equal
> ERR_PTR() that is void * (the last one is optional, just makes the intent
> more clear).

I've never seen anything like this: you are spoon feeding me :-)

Please don't misunderstand: I'm OK with it and, above all, I'm surely  
appreciating how much patience and time you are devolving to help me.

I'll send v3 ASAP (for sure within the next 24 hours).

Furthermore, if there are no other issues, I'd start ASAP with the 
decomposition of the patch to fs/sysv into a series of three units and rework 
the whole design in accordance to the suggestions you have been kindly 
providing.

I'm sorry for responding and reacting so slowly. Aside from being slow because 
of a fundamental lack of knowledge and experience, I can do Kernel development 
(including studying new subjects and code, doing patches, doing reviews, and 
the likes) about 7 hours a week. This is all the time I can set aside until I 
quit one of my jobs at the end of January.

Again thanks,

Fabio

P.S.: While at this patch I'd like to gently ping you about another conversion 
that I sent (and resent) months ago:

[RESEND PATCH] fs/aio: Replace kmap{,_atomic}() with kmap_local_page() at:
https://lore.kernel.org/lkml/20221016150656.5803-1-fmdefrancesco@gmail.com/

This patch to fs/aio.c has already received two "Reviewed-by" tags: the first 
from Ira Weiny and the second from Jeff Moyer (you won't see the second there, 
because I forgot to forward it when I sent again :-( ).

The tag from Jeff is in the following message (from another [RESEND PATCH] 
thread):
https://lore.kernel.org/lkml/x49h6zzvn1a.fsf@segfault.boston.devel.redhat.com/

In that same thread, I explained better I meant in the last sentence of the 
commit message, because Jeff commented that it is ambiguous (I'm adding him in 
the Cc list of recipients).

The original patch, submitted on Thu, 7 Jul 2022 01:33:28 +0200 is at:
https://lore.kernel.org/lkml/20220706233328.18582-1-fmdefrancesco@gmail.com/

I'd appreciate very much if you can spend some time on that patch too :)




  reply	other threads:[~2022-12-13 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bpf@vger.kernel.org,linux-fsdevel@vger.kernel.org>
2022-12-12 23:19 ` [PATCH v2 0/3] fs/ufs: replace kmap() with kmap_local_page Fabio M. De Francesco
2022-12-12 23:19   ` [PATCH v2 1/3] fs/ufs: Use the offset_in_page() helper Fabio M. De Francesco
2022-12-12 23:19   ` [PATCH v2 2/3] fs/ufs: Change the signature of ufs_get_page() Fabio M. De Francesco
2022-12-13  7:10     ` Al Viro
2022-12-13 19:08       ` Fabio M. De Francesco [this message]
2022-12-13 21:02         ` Al Viro
2022-12-12 23:19   ` [PATCH v2 3/3] fs/ufs: Replace kmap() with kmap_local_page() Fabio M. De Francesco

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=3174926.0WQXIW03uk@suse \
    --to=fmdefrancesco@gmail.com \
    --cc=dushistov@mail.ru \
    --cc=ira.weiny@intel.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-kernel@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