Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7821286rdb; Thu, 4 Jan 2024 08:40:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGM211BEIQhXeMO7ZP7uH0Rc7wOoT5v7dqBeXHMoMxLMPlzy6Lo5SDWr7RvY0U6mB7Eutxm X-Received: by 2002:a05:6102:3a08:b0:467:ac6e:cb2e with SMTP id b8-20020a0561023a0800b00467ac6ecb2emr720679vsu.11.1704386431161; Thu, 04 Jan 2024 08:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704386431; cv=none; d=google.com; s=arc-20160816; b=bFNtQgM8NufKZ6O3AKGobQmvboPh/x0a4YSmfDb6yIKh25jRGyc9qf1u68OkjGx/LY o1j1ub8HkBwGr5rVVu8GpyS+o19Y9nIlKecLzUuY0pF4JkTPOiw0MWGFF+fo5KwjC4h2 M4ucHRZuUvh/Hju6jSD+Ip7lXNV0PtPx82nMPm5ExdXIP56xYJmOpBEImi3yGyRHpuXX GhC8M7DgVM6NAzQj/+go5QkjN7D9pYSl21+DmkIziemdDpc/222t7H0EL/2tt2hSx/gq hEX1OktELfBg6W/qB3j0CBSRGxzMAiPHfoPuBXVOoWOCZCJr+UQADaiKtdgO75uj41j6 nEhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FPwsr0b5fglYQXWUN5NF5I5tBgC3MgAQLlBQ5JhnBJ0=; fh=C1THyYX8mZv7/wM+MHV1ZUcnQSQiZbUrxk0HRhdecS4=; b=taNKDGBj/nUMzwe4vRh2GUNCwXUG63XogliaWvfXijqqLa2YyuiicqrSCWMIsqHZJc lx6XvEIUsTQCte6b6BXScZL07P92i8fPdxJQLFwgPuT7ZnInDLUAYbNgXw3XEHzXm+BM QHypzQt3uBXGkDZY7rsWGCP1xIv5oMJpO26CH94hqWpLwaSNVAGE/ppG8GL5rMhEh7sS oKeZrMTIlEPTD19zhFAsPP4Ot4+3lOCXIh0A0FBLQTDz5o/O5K6sIWwccd2qyALl5Qsa utN8YXdviedeJPAjXvRXnJ0y66SqcNxxYpQIH4RDLuip2KoJhffQhT3DeJnghI3Vn8Ow 4JTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HS6Lr8NJ; spf=pass (google.com: domain of linux-kernel+bounces-16951-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16951-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l22-20020a056102243600b00466f6f43b34si2646160vsi.75.2024.01.04.08.40.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 08:40:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16951-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HS6Lr8NJ; spf=pass (google.com: domain of linux-kernel+bounces-16951-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16951-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E230D1C21EF6 for ; Thu, 4 Jan 2024 16:40:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41C442D025; Thu, 4 Jan 2024 16:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="HS6Lr8NJ" X-Original-To: linux-kernel@vger.kernel.org Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 D8D222C855; Thu, 4 Jan 2024 16:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=FPwsr0b5fglYQXWUN5NF5I5tBgC3MgAQLlBQ5JhnBJ0=; b=HS6Lr8NJasM40FJXxml08nOWCE R5dzJa4VWPkI+0xH0t0rdnBC4ZkdWG8hMKCI7/l6t+DQE21Xh2nviclqPiZ3J12UwjewG3A06Is3f VF1mDBFQrEeUxg4MtJwA4mSEv7VeTKryd6+d7EKaraa4tkBEEAsoXHrphR2f3V2wUqcotF1Upk0qj KWJWIdlbGUbDxdGMjeKazHHle/Fp20/zQ4WS18X/vn8W1GVOTJX8wna/yeH2NJ2oug0Gu+10cnh9U T0cc1amt93PR7gTrdN1mWXPMrjhqJ3i3/mv/tIQ1chd60CHhNxdqsFVAlWQt3NVxu9aplbnK1ve1t UG3WiSNA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rLQiE-00FY2V-Nt; Thu, 04 Jan 2024 16:36:54 +0000 From: "Matthew Wilcox (Oracle)" To: Jonathan Corbet Cc: "Matthew Wilcox (Oracle)" , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] buffer: Add kernel-doc for try_to_free_buffers() Date: Thu, 4 Jan 2024 16:36:50 +0000 Message-Id: <20240104163652.3705753-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240104163652.3705753-1-willy@infradead.org> References: <20240104163652.3705753-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The documentation for this function has become separated from it over time; move it to the right place and turn it into kernel-doc. Mild editing of the content to make it more about what the function does, and less about how it does it. Signed-off-by: Matthew Wilcox (Oracle) --- fs/buffer.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 31e171382e00..a657920802ac 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2863,26 +2863,6 @@ int sync_dirty_buffer(struct buffer_head *bh) } EXPORT_SYMBOL(sync_dirty_buffer); -/* - * try_to_free_buffers() checks if all the buffers on this particular folio - * are unused, and releases them if so. - * - * Exclusion against try_to_free_buffers may be obtained by either - * locking the folio or by holding its mapping's private_lock. - * - * If the folio is dirty but all the buffers are clean then we need to - * be sure to mark the folio clean as well. This is because the folio - * may be against a block device, and a later reattachment of buffers - * to a dirty folio will set *all* buffers dirty. Which would corrupt - * filesystem data on the same device. - * - * The same applies to regular filesystem folios: if all the buffers are - * clean then we set the folio clean and proceed. To do that, we require - * total exclusion from block_dirty_folio(). That is obtained with - * private_lock. - * - * try_to_free_buffers() is non-blocking. - */ static inline int buffer_busy(struct buffer_head *bh) { return atomic_read(&bh->b_count) | @@ -2916,6 +2896,30 @@ drop_buffers(struct folio *folio, struct buffer_head **buffers_to_free) return false; } +/** + * try_to_free_buffers: Release buffers attached to this folio. + * @folio: The folio. + * + * If any buffers are in use (dirty, under writeback, elevated refcount), + * no buffers will be freed. + * + * If the folio is dirty but all the buffers are clean then we need to + * be sure to mark the folio clean as well. This is because the folio + * may be against a block device, and a later reattachment of buffers + * to a dirty folio will set *all* buffers dirty. Which would corrupt + * filesystem data on the same device. + * + * The same applies to regular filesystem folios: if all the buffers are + * clean then we set the folio clean and proceed. To do that, we require + * total exclusion from block_dirty_folio(). That is obtained with + * private_lock. + * + * Exclusion against try_to_free_buffers may be obtained by either + * locking the folio or by holding its mapping's private_lock. + * + * Context: Process context. @folio must be locked. Will not sleep. + * Return: true if all buffers attached to this folio were freed. + */ bool try_to_free_buffers(struct folio *folio) { struct address_space * const mapping = folio->mapping; -- 2.43.0