From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-00364e01.pphosted.com (mx0b-00364e01.pphosted.com [148.163.139.74]) (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 F0592376BEA for ; Wed, 20 May 2026 20:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.139.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779310245; cv=none; b=FOTrLGoBgHSciZzKVKX+KLdP5ULLQkGN/KS5H8KvhbbIouY1ebNzn0vCgeGDoahYPArHPx9A/dAWoybf5XiTzbrUP8SiZm+Qx1aAh/28B8rpzg2g0GPRKsrbHbpTyOacL0lE8OvV989/9z9nGMnz7CuFPIKILNyLYSohXrjYodk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779310245; c=relaxed/simple; bh=MdnqSRc2FJHBhrARlYsy3cs/9UevS5fEoCvn0pE0sDw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KGXkKoci9IIIXfw4mVQa+WP9VH42IYi+tqt7ztwd9z8nIzm+yewQymKuLZVTJ7qOUlgvtPXqqnAHIRUeHYD9RGSeD4WGunqUFDU20LPVYAQk50vPRDjIO3hZ2/xMN2iwN+b9Szmh51UXBOlD4gSKFf6CaP2gS2W/ISyV9Xwzmoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu; spf=pass smtp.mailfrom=columbia.edu; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=CxuJGpWL; arc=none smtp.client-ip=148.163.139.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=columbia.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="CxuJGpWL" Received: from pps.filterd (m0499198.ppops.net [127.0.0.1]) by mx0b-00364e01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64KKOEv32013624 for ; Wed, 20 May 2026 16:50:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps01; bh=y+gj tILqDLOQsRHv/xOkAmWQ2cCtCFJ6veJFyW78pUo=; b=CxuJGpWL+kS84wunAt9h U/LMKliWuP4nB71UXrm5g2rej0P5N7Idq6BmiNfKDH80LLeVfW44ieNa0/BkXXsi +L9TIuteWD2e2V/oKCwp2pBm8/BevB3hAA68MBGegIkV4f6lcMhzEeWtaWIZ/onj AS5ayl3chCL64tG3bR5sORVXXnch8+A3TP6eyrsP+oZjdBtNP6ga3aSMnRwc0p6/ BYV5Iilum2otM/TkKY8H/+zERGVJ7saJ/nflnYcYRup6RXfZY6tt6SAiOZhn8cYW OdnmFxoq6yyFwNO6fg+uSBMB8Kt/ndgipMDZ0G1TcX+iqata3s5oeMrGTtuoq5nS pg== Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by mx0b-00364e01.pphosted.com (PPS) with ESMTPS id 4e9fdn2mud-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 20 May 2026 16:50:36 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-90fb4c8390aso556567485a.3 for ; Wed, 20 May 2026 13:50:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779310235; x=1779915035; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to;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k2ci1G+bkrkdJ21M aOURAfzPk+zO5OnDbzFCL3szPN3H0iCwAJ1htz2gGNkNXl+1n6ORTL3V2I65VEolQG5s= X-Received: by 2002:a05:620a:4542:b0:8ee:dc47:3b70 with SMTP id af79cd13be357-911cef062demr3495260085a.39.1779310235408; Wed, 20 May 2026 13:50:35 -0700 (PDT) X-Received: by 2002:a05:620a:4542:b0:8ee:dc47:3b70 with SMTP id af79cd13be357-911cef062demr3495254485a.39.1779310234746; Wed, 20 May 2026 13:50:34 -0700 (PDT) Received: from [127.0.1.1] (dyn-160-39-33-242.dyn.columbia.edu. [160.39.33.242]) by smtp.gmail.com with ESMTPSA id af79cd13be357-910bcf37274sm2232692085a.37.2026.05.20.13.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 13:50:34 -0700 (PDT) From: Tal Zussman Date: Wed, 20 May 2026 16:48:55 -0400 Subject: [PATCH RFC 04/11] folio_wait: move folio_wait_writeback() family to mm/folio_wait.c Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260520-filemap-split-v1-4-c36ddc2b6cf2@columbia.edu> References: <20260520-filemap-split-v1-0-c36ddc2b6cf2@columbia.edu> In-Reply-To: <20260520-filemap-split-v1-0-c36ddc2b6cf2@columbia.edu> To: "Matthew Wilcox (Oracle)" , Jan Kara , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Alexander Viro , Christian Brauner , Jens Axboe Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Tal Zussman X-Mailer: b4 0.14.3-dev-d7477 X-Developer-Signature: v=1; a=ed25519-sha256; t=1779310229; l=7803; i=tz2294@columbia.edu; s=20250528; h=from:subject:message-id; bh=MdnqSRc2FJHBhrARlYsy3cs/9UevS5fEoCvn0pE0sDw=; b=rkMG4EwgIAXfDMJhpCN/bphiVIHAebicxGt8s33PBw5nTp2DJPdH7PqP6gawcVTAxyPkOdXvw WsorbnVQOqHC4h13v+JdnPOZqm2wLrEZ0r4jbfVOfOBi4GxGI+ybNHp X-Developer-Key: i=tz2294@columbia.edu; a=ed25519; pk=BIj5KdACscEOyAC0oIkeZqLB3L94fzBnDccEooxeM5Y= X-Proofpoint-GUID: QLBRdYToT3csAHx6Jd1Ul8tSeZxV-zzY X-Authority-Analysis: v=2.4 cv=P/4KQCAu c=1 sm=1 tr=0 ts=6a0e1e9c cx=c_pps a=HLyN3IcIa5EE8TELMZ618Q==:117 a=GaPK54s0Se3oFqK5NkZy0g==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=x7bEGLp0ZPQA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Da8U98TiO7q1upZEImrf:22 a=BpGzv1V74M3SfeTrGa8v:22 a=oq273MN9QaURjshXV2UA:9 a=QEXdDO2ut3YA:10 a=bTQJ7kPSJx9SKPbeHEYW:22 X-Proofpoint-ORIG-GUID: QLBRdYToT3csAHx6Jd1Ul8tSeZxV-zzY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIwMDIwMyBTYWx0ZWRfX2HDATFqcw/1z cgs2ffymzg/CgetAFCI50WZ2IEs7IepcymH/HJqSiL5JSs2ykfQYc13HXAyYLK+id/Hq5yCmBzH ZhnWAUEGT/ELre7dO76KPwfbk59UBNfAgmwGlVCarU4uerYQ2IRB6MK/wC0jvnbPU8VZGl0gX6t 94NNBs4t7Uu0lz2SJjVjUqkDT6afvdupvEc1ydaKQmQiIilOAL7+2Jdgjklmgv4LuDU+oWjLQ7D bF7wByOw04DU24yL5ydvX0d0M5TryVcd50uAQCSmgoYZJNhCZnwqC4xTTHLArP75R0z92SE4mtZ q3aepU+S/69OWxBU71zr7lz0BrPWDy06OMCNEhJ2tnQKkjczlTbOXOjdZ+sbcLdQo5F2kpYFeWV jGkQ6teiCcDFugmD/sDjFE0aHAonqVKmC6BwqHTpv3ocUvY7TrboHOT+xrmtu4WHRumtmSeg0gf WRfmE9kwO+Ulz8KYpYQ== X-Proofpoint-Virus-Version: vendor=nai engine=6900 definitions=11792 signatures=596817 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 impostorscore=10 malwarescore=0 phishscore=0 adultscore=0 lowpriorityscore=10 spamscore=0 priorityscore=1501 bulkscore=10 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605200203 folio_wait_writeback(), folio_wait_writeback_killable() and folio_wait_stable() are thin wrappers around folio_wait_bit() and folio_wait_bit_killable() on PG_writeback. Move them to mm/folio_wait.c, next to the rest of the folio bit-wait infrastructure. The legacy wait_on_page_writeback() wrapper stays in folio-compat.c, as its days are numbered, and it will be deleted once the remaining callers are converted. Signed-off-by: Tal Zussman --- include/linux/folio_wait.h | 4 +++ include/linux/pagemap.h | 3 --- mm/folio_wait.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++ mm/page-writeback.c | 66 --------------------------------------------- 4 files changed, 71 insertions(+), 69 deletions(-) diff --git a/include/linux/folio_wait.h b/include/linux/folio_wait.h index 80ddf1ffcae4..4a5cb2fcf046 100644 --- a/include/linux/folio_wait.h +++ b/include/linux/folio_wait.h @@ -178,4 +178,8 @@ void folio_end_private_2(struct folio *folio); void folio_wait_private_2(struct folio *folio); int folio_wait_private_2_killable(struct folio *folio); +void folio_wait_writeback(struct folio *folio); +int folio_wait_writeback_killable(struct folio *folio); +void folio_wait_stable(struct folio *folio); + #endif /* _LINUX_FOLIO_WAIT_H */ diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 7f65c2b0097b..84ccb682cca8 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1074,13 +1074,10 @@ static inline pgoff_t linear_page_index(const struct vm_area_struct *vma, } void wait_on_page_writeback(struct page *page); -void folio_wait_writeback(struct folio *folio); -int folio_wait_writeback_killable(struct folio *folio); void end_page_writeback(struct page *page); void folio_end_writeback(struct folio *folio); void folio_end_writeback_no_dropbehind(struct folio *folio); void folio_end_dropbehind(struct folio *folio); -void folio_wait_stable(struct folio *folio); void __folio_mark_dirty(struct folio *folio, struct address_space *, int warn); void folio_account_cleaned(struct folio *folio, struct bdi_writeback *wb); void __folio_cancel_dirty(struct folio *folio); diff --git a/mm/folio_wait.c b/mm/folio_wait.c index 06156e138c09..9d3328717bb3 100644 --- a/mm/folio_wait.c +++ b/mm/folio_wait.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "internal.h" @@ -572,6 +573,72 @@ int folio_wait_private_2_killable(struct folio *folio) } EXPORT_SYMBOL(folio_wait_private_2_killable); +/** + * folio_wait_writeback - Wait for a folio to finish writeback. + * @folio: The folio to wait for. + * + * If the folio is currently being written back to storage, wait for the + * I/O to complete. + * + * Context: Sleeps. Must be called in process context and with + * no spinlocks held. Caller should hold a reference on the folio. + * If the folio is not locked, writeback may start again after writeback + * has finished. + */ +void folio_wait_writeback(struct folio *folio) +{ + while (folio_test_writeback(folio)) { + trace_folio_wait_writeback(folio, folio_mapping(folio)); + folio_wait_bit(folio, PG_writeback); + } +} +EXPORT_SYMBOL_GPL(folio_wait_writeback); + +/** + * folio_wait_writeback_killable - Wait for a folio to finish writeback. + * @folio: The folio to wait for. + * + * If the folio is currently being written back to storage, wait for the + * I/O to complete or a fatal signal to arrive. + * + * Context: Sleeps. Must be called in process context and with + * no spinlocks held. Caller should hold a reference on the folio. + * If the folio is not locked, writeback may start again after writeback + * has finished. + * Return: 0 on success, -EINTR if we get a fatal signal while waiting. + */ +int folio_wait_writeback_killable(struct folio *folio) +{ + while (folio_test_writeback(folio)) { + trace_folio_wait_writeback(folio, folio_mapping(folio)); + if (folio_wait_bit_killable(folio, PG_writeback)) + return -EINTR; + } + + return 0; +} +EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); + +/** + * folio_wait_stable() - wait for writeback to finish, if necessary. + * @folio: The folio to wait on. + * + * This function determines if the given folio is related to a backing + * device that requires folio contents to be held stable during writeback. + * If so, then it will wait for any pending writeback to complete. + * + * Context: Sleeps. Must be called in process context and with + * no spinlocks held. Caller should hold a reference on the folio. + * If the folio is not locked, writeback may start again after writeback + * has finished. + */ +void folio_wait_stable(struct folio *folio) +{ + if (mapping_stable_writes(folio_mapping(folio))) + folio_wait_writeback(folio); +} +EXPORT_SYMBOL_GPL(folio_wait_stable); + /** * __folio_lock - Get a lock on the folio, assuming we need to sleep to get it. * @folio: The folio to lock diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 833f743f309f..50f548bbb375 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -3042,69 +3042,3 @@ void __folio_start_writeback(struct folio *folio, bool keep_write) VM_BUG_ON_FOLIO(access_ret != 0, folio); } EXPORT_SYMBOL(__folio_start_writeback); - -/** - * folio_wait_writeback - Wait for a folio to finish writeback. - * @folio: The folio to wait for. - * - * If the folio is currently being written back to storage, wait for the - * I/O to complete. - * - * Context: Sleeps. Must be called in process context and with - * no spinlocks held. Caller should hold a reference on the folio. - * If the folio is not locked, writeback may start again after writeback - * has finished. - */ -void folio_wait_writeback(struct folio *folio) -{ - while (folio_test_writeback(folio)) { - trace_folio_wait_writeback(folio, folio_mapping(folio)); - folio_wait_bit(folio, PG_writeback); - } -} -EXPORT_SYMBOL_GPL(folio_wait_writeback); - -/** - * folio_wait_writeback_killable - Wait for a folio to finish writeback. - * @folio: The folio to wait for. - * - * If the folio is currently being written back to storage, wait for the - * I/O to complete or a fatal signal to arrive. - * - * Context: Sleeps. Must be called in process context and with - * no spinlocks held. Caller should hold a reference on the folio. - * If the folio is not locked, writeback may start again after writeback - * has finished. - * Return: 0 on success, -EINTR if we get a fatal signal while waiting. - */ -int folio_wait_writeback_killable(struct folio *folio) -{ - while (folio_test_writeback(folio)) { - trace_folio_wait_writeback(folio, folio_mapping(folio)); - if (folio_wait_bit_killable(folio, PG_writeback)) - return -EINTR; - } - - return 0; -} -EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); - -/** - * folio_wait_stable() - wait for writeback to finish, if necessary. - * @folio: The folio to wait on. - * - * This function determines if the given folio is related to a backing - * device that requires folio contents to be held stable during writeback. - * If so, then it will wait for any pending writeback to complete. - * - * Context: Sleeps. Must be called in process context and with - * no spinlocks held. Caller should hold a reference on the folio. - * If the folio is not locked, writeback may start again after writeback - * has finished. - */ -void folio_wait_stable(struct folio *folio) -{ - if (mapping_stable_writes(folio_mapping(folio))) - folio_wait_writeback(folio); -} -EXPORT_SYMBOL_GPL(folio_wait_stable); -- 2.39.5