2020-04-26 21:51:44

by Guoqing Jiang

[permalink] [raw]
Subject: [RFC PATCH 6/9] iomap: use set/clear_fs_page_private

Since the new pair function is introduced, we can call them to clean the
code in iomap.

Cc: Christoph Hellwig <[email protected]>
Cc: "Darrick J. Wong" <[email protected]>
Cc: [email protected]
Signed-off-by: Guoqing Jiang <[email protected]>
---
fs/iomap/buffered-io.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 89e21961d1ad..cc48bf4f1193 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -59,24 +59,18 @@ iomap_page_create(struct inode *inode, struct page *page)
* migrate_page_move_mapping() assumes that pages with private data have
* their count elevated by 1.
*/
- get_page(page);
- set_page_private(page, (unsigned long)iop);
- SetPagePrivate(page);
- return iop;
+ return (struct iomap_page *)set_fs_page_private(page, iop);
}

static void
iomap_page_release(struct page *page)
{
- struct iomap_page *iop = to_iomap_page(page);
+ struct iomap_page *iop = clear_fs_page_private(page);

if (!iop)
return;
WARN_ON_ONCE(atomic_read(&iop->read_count));
WARN_ON_ONCE(atomic_read(&iop->write_count));
- ClearPagePrivate(page);
- set_page_private(page, 0);
- put_page(page);
kfree(iop);
}

@@ -556,11 +550,9 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage,

if (page_has_private(page)) {
ClearPagePrivate(page);
- get_page(newpage);
- set_page_private(newpage, page_private(page));
+ set_fs_page_private(newpage, (void *)page_private(page));
set_page_private(page, 0);
put_page(page);
- SetPagePrivate(newpage);
}

if (mode != MIGRATE_SYNC_NO_COPY)
--
2.17.1


2020-04-27 00:28:33

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [RFC PATCH 6/9] iomap: use set/clear_fs_page_private

On Sun, Apr 26, 2020 at 11:49:22PM +0200, Guoqing Jiang wrote:
> @@ -59,24 +59,18 @@ iomap_page_create(struct inode *inode, struct page *page)
> * migrate_page_move_mapping() assumes that pages with private data have
> * their count elevated by 1.
> */
> - get_page(page);
> - set_page_private(page, (unsigned long)iop);
> - SetPagePrivate(page);
> - return iop;
> + return (struct iomap_page *)set_fs_page_private(page, iop);
> }

This cast is unnecessary. void * will be automatically cast to the
appropriate pointer type.

> @@ -556,11 +550,9 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage,
>
> if (page_has_private(page)) {
> ClearPagePrivate(page);
> - get_page(newpage);
> - set_page_private(newpage, page_private(page));
> + set_fs_page_private(newpage, (void *)page_private(page));
> set_page_private(page, 0);
> put_page(page);
> - SetPagePrivate(newpage);
> }

Same comment here as for the btrfs migrate page that Dave reviewed.

2020-04-27 05:58:02

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [RFC PATCH 6/9] iomap: use set/clear_fs_page_private

On Sun, Apr 26, 2020 at 05:26:31PM -0700, Matthew Wilcox wrote:
> On Sun, Apr 26, 2020 at 11:49:22PM +0200, Guoqing Jiang wrote:
> > @@ -59,24 +59,18 @@ iomap_page_create(struct inode *inode, struct page *page)
> > * migrate_page_move_mapping() assumes that pages with private data have
> > * their count elevated by 1.
> > */
> > - get_page(page);
> > - set_page_private(page, (unsigned long)iop);
> > - SetPagePrivate(page);
> > - return iop;
> > + return (struct iomap_page *)set_fs_page_private(page, iop);
> > }
>
> This cast is unnecessary. void * will be automatically cast to the
> appropriate pointer type.

I also find the pattern eather strange. A:

attach_page_private(page, iop);
return iop;

explains the intent much better.

2020-04-27 05:59:37

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [RFC PATCH 6/9] iomap: use set/clear_fs_page_private

FYI, you've only Cced the xfs list on this one patch. Please Cc the
whole list to everyone, otherwise a person just on the xfs list has
no idea what your helpers added in patch 1 actually do.

2020-04-27 08:14:14

by Guoqing Jiang

[permalink] [raw]
Subject: Re: [RFC PATCH 6/9] iomap: use set/clear_fs_page_private

On 4/27/20 7:57 AM, Christoph Hellwig wrote:
> FYI, you've only Cced the xfs list on this one patch. Please Cc the
> whole list to everyone, otherwise a person just on the xfs list has
> no idea what your helpers added in patch 1 actually do.

Sorry, I should cc more lists for patch 1, thanks for reminder!

Thanks,
Guoqing

2020-04-27 08:17:33

by Guoqing Jiang

[permalink] [raw]
Subject: Re: [RFC PATCH 6/9] iomap: use set/clear_fs_page_private

On 4/27/20 7:55 AM, Christoph Hellwig wrote:
> On Sun, Apr 26, 2020 at 05:26:31PM -0700, Matthew Wilcox wrote:
>> On Sun, Apr 26, 2020 at 11:49:22PM +0200, Guoqing Jiang wrote:
>>> @@ -59,24 +59,18 @@ iomap_page_create(struct inode *inode, struct page *page)
>>> * migrate_page_move_mapping() assumes that pages with private data have
>>> * their count elevated by 1.
>>> */
>>> - get_page(page);
>>> - set_page_private(page, (unsigned long)iop);
>>> - SetPagePrivate(page);
>>> - return iop;
>>> + return (struct iomap_page *)set_fs_page_private(page, iop);
>>> }
>> This cast is unnecessary. void * will be automatically cast to the
>> appropriate pointer type.
> I also find the pattern eather strange. A:
>
> attach_page_private(page, iop);
> return iop;
>
> explains the intent much better.

Thanks for the review, will do it.

Thanks,
Guoqing

2020-04-27 08:17:57

by Guoqing Jiang

[permalink] [raw]
Subject: Re: [RFC PATCH 6/9] iomap: use set/clear_fs_page_private

On 4/27/20 2:26 AM, Matthew Wilcox wrote:
> On Sun, Apr 26, 2020 at 11:49:22PM +0200, Guoqing Jiang wrote:
>> @@ -59,24 +59,18 @@ iomap_page_create(struct inode *inode, struct page *page)
>> * migrate_page_move_mapping() assumes that pages with private data have
>> * their count elevated by 1.
>> */
>> - get_page(page);
>> - set_page_private(page, (unsigned long)iop);
>> - SetPagePrivate(page);
>> - return iop;
>> + return (struct iomap_page *)set_fs_page_private(page, iop);
>> }
> This cast is unnecessary. void * will be automatically cast to the
> appropriate pointer type.
>
>> @@ -556,11 +550,9 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage,
>>
>> if (page_has_private(page)) {
>> ClearPagePrivate(page);
>> - get_page(newpage);
>> - set_page_private(newpage, page_private(page));
>> + set_fs_page_private(newpage, (void *)page_private(page));
>> set_page_private(page, 0);
>> put_page(page);
>> - SetPagePrivate(newpage);
>> }
> Same comment here as for the btrfs migrate page that Dave reviewed.

Yes, thanks for the review.

Thanks,
Guoqing