OSDN Git Service

afs: Fix to take ref on page when PG_private is set
authorDavid Howells <dhowells@redhat.com>
Wed, 21 Oct 2020 12:22:19 +0000 (13:22 +0100)
committerDavid Howells <dhowells@redhat.com>
Thu, 29 Oct 2020 13:53:04 +0000 (13:53 +0000)
commitfa04a40b169fcee615afbae97f71a09332993f64
tree3a6123e3b15b9881cd1227f5c129d5e3f8c36732
parentd383e346f97d6bb0d654bb3d63c44ab106d92d29
afs: Fix to take ref on page when PG_private is set

Fix afs to take a ref on a page when it sets PG_private on it and to drop
the ref when removing the flag.

Note that in afs_write_begin(), a lot of the time, PG_private is already
set on a page to which we're going to add some data.  In such a case, we
leave the bit set and mustn't increment the page count.

As suggested by Matthew Wilcox, use attach/detach_page_private() where
possible.

Fixes: 31143d5d515e ("AFS: implement basic file write support")
Reported-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
fs/afs/dir.c
fs/afs/dir_edit.c
fs/afs/file.c
fs/afs/write.c