Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp363611rdd; Tue, 9 Jan 2024 06:37:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtqWkxD7jBAfhJvxDM0m8UtU4H9Jg5pecaCEv9sWt3UZr5NuDdehyMU1r+LDJ1kAC+3qao X-Received: by 2002:a05:6402:1495:b0:557:5162:4ffb with SMTP id e21-20020a056402149500b0055751624ffbmr2795382edv.50.1704811051159; Tue, 09 Jan 2024 06:37:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704811051; cv=none; d=google.com; s=arc-20160816; b=e6ymI96M3FSv6jSqKorzbYM4aYsPgCEo3NO9h7EbBky8Kx/NZ+M9oJTksEUEzBZJ08 Z0vAL4UwrUV7Z7LseH2Jt3A7trLf6Ab5yLP73MCcmn1EbpAMQ8Mw5OJV0yeKqfnvcJuX K3FciXIN6A4sJ0SGs69kf4yJZZGatM+dk5zBoUFYa3YGytaKilgLh96luZHtiUTB/CNA a2DJbIoc1ofMuyJws5vCQit/+ivjYFevYU6GFmkff9gviNioXDICMzr6sXd/s/g8oRNW yugjw7+0E273LOXQfVg+8366k6LmKN8CSWvbNeD3mEXS8ir8q7sEmHzv2C9cvVGzk3hH ViAA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20999-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h19-20020a50cdd3000000b00555a8172c70si793200edj.364.2024.01.09.06.37.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 06:37:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20999-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20999-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E121A1F25081 for ; Tue, 9 Jan 2024 14:37:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3AB993C49E; Tue, 9 Jan 2024 14:34:28 +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 Content-Transfer-Encoding: 8bit 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) -- 2.43.0