From patchwork Tue Jan 9 14:33:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 186423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp150730dyi; Tue, 9 Jan 2024 06:37:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3m2UaaApBlUF+gjHEY8Fi9YWwDVio1QzUaU5fMEzcPl/YDvISETLLlSNubQI62mXdbDcx X-Received: by 2002:a05:6808:1b0d:b0:3bd:22b4:b562 with SMTP id bx13-20020a0568081b0d00b003bd22b4b562mr6138095oib.106.1704811058308; Tue, 09 Jan 2024 06:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704811058; cv=none; d=google.com; s=arc-20160816; b=qbZ3nKWm41Siv+YLDcWG127ArDQ+6lyXYfv+Gm0aV4FTgDoWJQ5ZbYU7frdRJ8fFFu OK3w1qQWJbpYgnQuT5z/Zvq7LFL12fAZReyHycYDj8Bdf7mBK8c9HES1XCoQqh3mll9g 0gGOAm17N4U7IpnoYsQya/QMt24pkZNaYO1nvqd1O6C9wepd2iVMbBvns2ClW5CV8qTz C8Dr7mcrS0bX2bStWzuzdwRSvcCT45o375VO4pdJQ06rt7euloCBrnaIcFX61KN3wAoX 8MALmV5HJan/QxwttLbc0psmJH0yXSqndFvXpAW9OTBbdaPpnfLQYvi60Skx0R7JKAqA k2jA== 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=OxfIaVCptnL2Ku+19F0c3pEPzF3dZDzT7NBA3grsvvg=; fh=C1THyYX8mZv7/wM+MHV1ZUcnQSQiZbUrxk0HRhdecS4=; b=NobcLGsF92UmT1KbZqD58uOp/8R9ssUz3RiSBKSb3oHD1MBnmDW9I7RSl+mZFM9DOx zM6q2MUrENb2PkyW8HrmPPB+ekDMWTxtbLfdDPDb0eD+2OMaVQLkHNJN2VCAdulkUeAx 5e8Es6la3FJWckUNvQMwUjY2Jx6adoXCU9UyeGmvd5R+WoXwVcw0iZXgOrFil/Dtx+aN TmO0+3zyeWlmLa6EnCymDhev4qaxOuNrTlOds7YDS9Qs87mCTeKp/YB7FJdoGzizzn8P 247B2Z5QC/VbPfs1tyf54J/ffYA4caGAF3lYGKtUGASR6QhyUxE8SDuEU4zZsad2yKiL xYhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hGupIP86; spf=pass (google.com: domain of linux-kernel+bounces-20999-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20999-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o12-20020a0ce40c000000b0067f040246acsi2413259qvl.207.2024.01.09.06.37.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 06:37:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20999-ouuuleilei=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=hGupIP86; spf=pass (google.com: domain of linux-kernel+bounces-20999-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20999-ouuuleilei=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 19AC01C24498 for ; Tue, 9 Jan 2024 14:37:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 050493C6BC; Tue, 9 Jan 2024 14:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hGupIP86" 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 29A8D3C481; Tue, 9 Jan 2024 14:34:25 +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=OxfIaVCptnL2Ku+19F0c3pEPzF3dZDzT7NBA3grsvvg=; b=hGupIP86Lcpom0DkHphtQajPbO HXwIe8TJDCYILaA1beUztFAWD5PDxrfHloqmSPK5Hoxm73HAhHDYQ9B1+qW96hj8q6JMiYv9CVxGC IVhPSbqGoKSFYEYj2eSb2EIiU3FY2WAxgbvrtEYho0pQ2pAwyW/jGFTQYMmYieceg+l9fcE+0Mpnt 7H/hZnvulSuk+A0tWgBNEZOgOTkXAY826yGrfGMQlI8kH4ZEPmPWHynnB4OWNzy2qVQutfhFCb9Y0 sXlH74lhDdYo/4lM2MwUx7IEpkwfgCF5FgkhPTHnutArNUL/XQ6FHEmggXFYTqicQiHgX4G1DNGXw R6Ppwo8w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNDB1-009xrY-5o; Tue, 09 Jan 2024 14:33:59 +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 v2 5/8] buffer: Add kernel-doc for brelse() and __brelse() Date: Tue, 9 Jan 2024 14:33:54 +0000 Message-Id: <20240109143357.2375046-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240109143357.2375046-1-willy@infradead.org> References: <20240109143357.2375046-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787623960234021115 X-GMAIL-MSGID: 1787623960234021115 Move the documentation for __brelse() to brelse(), format it as kernel-doc and update it from talking about pages to folios. Signed-off-by: Matthew Wilcox (Oracle) --- fs/buffer.c | 17 ++++++++--------- include/linux/buffer_head.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 160bbc1f929c..9a7b3649c872 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1226,17 +1226,16 @@ void mark_buffer_write_io_error(struct buffer_head *bh) } EXPORT_SYMBOL(mark_buffer_write_io_error); -/* - * Decrement a buffer_head's reference count. If all buffers against a page - * have zero reference count, are clean and unlocked, and if the page is clean - * and unlocked then try_to_free_buffers() may strip the buffers from the page - * in preparation for freeing it (sometimes, rarely, buffers are removed from - * a page but it ends up not being freed, and buffers may later be reattached). +/** + * __brelse - Release a buffer. + * @bh: The buffer to release. + * + * This variant of brelse() can be called if @bh is guaranteed to not be NULL. */ -void __brelse(struct buffer_head * buf) +void __brelse(struct buffer_head *bh) { - if (atomic_read(&buf->b_count)) { - put_bh(buf); + if (atomic_read(&bh->b_count)) { + put_bh(bh); return; } WARN(1, KERN_ERR "VFS: brelse: Trying to free free buffer\n"); diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 56a1e9c1e71e..3cbc01bbc398 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -303,6 +303,22 @@ static inline void put_bh(struct buffer_head *bh) atomic_dec(&bh->b_count); } +/** + * brelse - Release a buffer. + * @bh: The buffer to release. + * + * Decrement a buffer_head's reference count. If @bh is NULL, this + * function is a no-op. + * + * If all buffers on a folio have zero reference count, are clean + * and unlocked, and if the folio is clean and unlocked then + * try_to_free_buffers() may strip the buffers from the folio in + * preparation for freeing it (sometimes, rarely, buffers are removed + * from a folio but it ends up not being freed, and buffers may later + * be reattached). + * + * Context: Any context. + */ static inline void brelse(struct buffer_head *bh) { if (bh)