]> Git Repo - linux.git/commit
fs: nfs: fix missing refcnt by replacing folio_set_private by folio_attach_private
authorZhaoyang Huang <[email protected]>
Fri, 30 Aug 2024 03:27:47 +0000 (11:27 +0800)
committerAnna Schumaker <[email protected]>
Mon, 23 Sep 2024 19:03:13 +0000 (15:03 -0400)
commit03e02b94171b1985dd0aa184296fe94425b855a3
treecf61c395926b93d20d790d7974804f91d0452e77
parent40c80881ebef97a2ad4bba1e34edb80fd8585e8c
fs: nfs: fix missing refcnt by replacing folio_set_private by folio_attach_private

This patch is inspired by a code review of fs codes which aims at
folio's extra refcnt that could introduce unwanted behavious when
judging refcnt, such as[1].That is, the folio passed to
mapping_evict_folio carries the refcnts from find_lock_entries,
page_cache, corresponding to PTEs and folio's private if has. However,
current code doesn't take the refcnt for folio's private which could
have mapping_evict_folio miss the one to only PTE and lead to
call filemap_release_folio wrongly.

[1]
long mapping_evict_folio(struct address_space *mapping, struct folio *folio)
{
...
//current code will misjudge here if there is one pte on the folio which
is be deemed as the one as folio's private
        if (folio_ref_count(folio) >
                        folio_nr_pages(folio) + folio_has_private(folio) + 1)
                return 0;
        if (!filemap_release_folio(folio, 0))
                return 0;

        return remove_mapping(mapping, folio);
}

Signed-off-by: Zhaoyang Huang <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
fs/nfs/write.c
This page took 0.051324 seconds and 4 git commands to generate.