netfs: do not unlock and put the folio twice
authorXiubo Li <xiubli@redhat.com>
Mon, 11 Jul 2022 04:11:21 +0000 (12:11 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 14 Jul 2022 08:10:12 +0000 (10:10 +0200)
commitfac47b43c760ea90e64b895dba60df0327be7775
treece9fe5b54a150c80acf4683288924f94a6b5cfc8
parent32346491ddf24599decca06190ebca03ff9de7f8
netfs: do not unlock and put the folio twice

check_write_begin() will unlock and put the folio when return
non-zero.  So we should avoid unlocking and putting it twice in
netfs layer.

Change the way ->check_write_begin() works in the following two ways:

 (1) Pass it a pointer to the folio pointer, allowing it to unlock and put
     the folio prior to doing the stuff it wants to do, provided it clears
     the folio pointer.

 (2) Change the return values such that 0 with folio pointer set means
     continue, 0 with folio pointer cleared means re-get and all error
     codes indicating an error (no special treatment for -EAGAIN).

[ bagasdotme: use Sphinx code text syntax for *foliop pointer ]

Cc: stable@vger.kernel.org
Link: https://tracker.ceph.com/issues/56423
Link: https://lore.kernel.org/r/cf169f43-8ee7-8697-25da-0204d1b4343e@redhat.com
Co-developed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Documentation/filesystems/netfs_library.rst
fs/afs/file.c
fs/ceph/addr.c
fs/netfs/buffered_read.c
include/linux/netfs.h