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
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.
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.
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.
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
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
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