lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMgjq7Cu8q9ed_HY2K_iHwm7gKvYWkadS+Zj-GR1CaVwDMwqNQ@mail.gmail.com>
Date: Wed, 24 Apr 2024 16:48:46 +0800
From: Kairui Song <ryncsn@...il.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: "Huang, Ying" <ying.huang@...el.com>, linux-mm@...ck.org, 
	Andrew Morton <akpm@...ux-foundation.org>, Chris Li <chrisl@...nel.org>, 
	Barry Song <v-songbaohua@...o.com>, Ryan Roberts <ryan.roberts@....com>, Neil Brown <neilb@...e.de>, 
	Minchan Kim <minchan@...nel.org>, Hugh Dickins <hughd@...gle.com>, 
	David Hildenbrand <david@...hat.com>, Yosry Ahmed <yosryahmed@...gle.com>, linux-fsdevel@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-nfs@...r.kernel.org, 
	Trond Myklebust <trond.myklebust@...merspace.com>, Anna Schumaker <anna@...nel.org>, 
	linux-afs@...ts.infradead.org, David Howells <dhowells@...hat.com>, 
	Marc Dionne <marc.dionne@...istor.com>
Subject: Re: [PATCH v2 7/8] mm: drop page_index/page_file_offset and convert
 swap helpers to use folio

On Wed, Apr 24, 2024 at 12:06 PM Matthew Wilcox <willy@...radead.org> wrote:
>
> On Wed, Apr 24, 2024 at 10:17:04AM +0800, Huang, Ying wrote:
> > Kairui Song <ryncsn@...il.com> writes:
> > >  static inline loff_t folio_file_pos(struct folio *folio)
> > >  {
> > > -   return page_file_offset(&folio->page);
> > > +   if (unlikely(folio_test_swapcache(folio)))
> > > +           return __folio_swap_dev_pos(folio);
> > > +   return ((loff_t)folio->index << PAGE_SHIFT);
> >
> > This still looks confusing for me.  The function returns the byte
> > position of the folio in its file.  But we returns the swap device
> > position of the folio.
> >
> > Tried to search folio_file_pos() usage.  The 2 usage in page_io.c is
> > swap specific, we can use swap_dev_pos() directly.
> >
> > There are also other file system users (NFS and AFS) of
> > folio_file_pos(), I don't know why they need to work with swap
> > cache. Cced file system maintainers for help.
>
> Time for a history lesson!
>
> In d56b4ddf7781 (2012) we introduced page_file_index() and
> page_file_mapping() to support swap-over-NFS.  Writes to the swapfile went
> through ->direct_IO but reads went through ->readpage.  So NFS was changed
> to remove direct references to page->mapping and page->index because
> those aren't right for anon pages (or shmem pages being swapped out).
>
> In e1209d3a7a67 (2022), we stopped using ->readpage in favour of using
> ->swap_rw.  Now we don't need to use page_file_*(); we get the swap_file
> and ki_pos directly in the swap_iocb.  But there are still relics in NFS
> that nobody has dared rip out.  And there are all the copy-and-pasted
> filesystems that use page_file_* because they don't know any better.
>
> We should delete page_file_*() and folio_file_*().  They shouldn't be
> needed any more.

Thanks for the explanation! I'll update the series, and just delete
paeg_file_offset and folio_file_pos with more auditing, to make the
code cleaner. Should I add a suggest-by for the removal?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ