netfs: Fix i_dio_count leak on DIO read past i_size
authorMarc Dionne <marc.dionne@auristor.com>
Mon, 29 Jan 2024 09:49:18 +0000 (09:49 +0000)
committerChristian Brauner <brauner@kernel.org>
Mon, 29 Jan 2024 13:53:18 +0000 (14:53 +0100)
If netfs_begin_read gets a NETFS_DIO_READ request that begins
past i_size, it won't perform any i/o and just return 0.  This
will leak an increment to i_dio_count that is done at the top
of the function.

This can cause subsequent buffered read requests to block
indefinitely, waiting for a non existing dio operation to complete.

Add a inode_dio_end() for the NETFS_DIO_READ case, before returning.

Signed-off-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20240129094924.1221977-2-dhowells@redhat.com
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: Jeff Layton <jlayton@kernel.org>
cc:  <linux-afs@lists.infradead.org>
cc:  <netfs@lists.linux.dev>
cc:  <linux-fsdevel@vger.kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/netfs/io.c

index e8ff1e61ce79b7f67e1252f4b66aa461bfe1d4b8..4261ad6c55b664a7e3da006d007de03664790641 100644 (file)
@@ -748,6 +748,8 @@ int netfs_begin_read(struct netfs_io_request *rreq, bool sync)
 
        if (!rreq->submitted) {
                netfs_put_request(rreq, false, netfs_rreq_trace_put_no_submit);
+               if (rreq->origin == NETFS_DIO_READ)
+                       inode_dio_end(rreq->inode);
                ret = 0;
                goto out;
        }