From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0667840BCCB for ; Mon, 27 Jul 2026 13:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785157698; cv=none; b=o2ILYNqrg56N4lpYe+RUHNrsy9q+MrRsOrihh6Ejgx1X9ytvfE5IOlVI3u/BDjHYekogbAtYjIXAJFTJAdn0R/40eR0UjLQxRxxef/wvBLjk0F3OfAjoD9EWIoFaBhTfjf7Hmj5On3tD2G/bq1WIIPwqBm9Fp/zTD+2wv7L/g+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785157698; c=relaxed/simple; bh=w23b0JbOxNEGjzuU1PXY3kc0xOYVWl30OQdDnETC6eM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SZd57hRnLeLYFLPYi1paqRSb1674C2j5iSYRmxkWwdfH9/9ltVO5DLyqlNH3IxGuAZ2+59jOadeqGwDEAa09c4G50O6KhzaWaIykqsUvLBiKggDngaDj9EFMnlzrVfN0iShl6LCw4dWDei8w49YYyy/VG6dFSsNLpY2ZbBB25QQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WMv7sMqW; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WMv7sMqW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785157696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a8oEAiWjd86z1Gi65KRoWCtZfHjQ+oKK2jcEq+W4JMo=; b=WMv7sMqWIjy6pCWRelfwz75vajmMCAyI9EVqEagcCOlne+E03N/LTNaMKE9mTRT0Euy7hh tOyBC64Oq7GekvrgS7BWd5f6JIh51jwQmDp+qTyVLEWEmDxIObMelDRudbzw85wUj+BFhO bzy9Dv1xql3fe2huYQ+ORztyjdTYmJc= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-577-asgnWC8GN_-SMdNpCkNWBA-1; Mon, 27 Jul 2026 09:08:09 -0400 X-MC-Unique: asgnWC8GN_-SMdNpCkNWBA-1 X-Mimecast-MFC-AGG-ID: asgnWC8GN_-SMdNpCkNWBA_1785157687 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 617AA1955D5E; Mon, 27 Jul 2026 13:08:07 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.33.159]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7B44330010C8; Mon, 27 Jul 2026 13:08:03 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Paulo Alcantara , Christoph Hellwig , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yichong Chen Subject: [PATCH 3/4] netfs: release readahead folios on iterator preparation failure Date: Mon, 27 Jul 2026 14:07:14 +0100 Message-ID: <20260727130716.1099906-4-dhowells@redhat.com> In-Reply-To: <20260727130716.1099906-1-dhowells@redhat.com> References: <20260727130716.1099906-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 From: Yichong Chen netfs_prepare_read_iterator() batches readahead folios in put_batch so that the folio references can be dropped after the I/O iterator has been prepared. If rolling_buffer_load_from_ra() fails after earlier folios have been batched, the function returns immediately and leaves those references held. Release the batch before returning the error. Fixes: 06fa229ceb36 ("netfs: Abstract out a rolling folio buffer implementation") Signed-off-by: Yichong Chen Signed-off-by: David Howells cc: Paulo Alcantara cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/buffered_read.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 24a8a5418e31..3d86414ee40f 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -102,8 +102,10 @@ static ssize_t netfs_prepare_read_iterator(struct netfs_io_subrequest *subreq, added = rolling_buffer_load_from_ra(&rreq->buffer, ractl, &put_batch); - if (added < 0) + if (added < 0) { + folio_batch_release(&put_batch); return added; + } rreq->submitted += added; } folio_batch_release(&put_batch);