Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1392535rdd; Wed, 10 Jan 2024 19:22:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGb02Feq6l0cwN3V82DO99Fb5WQJYbNvrro67maBYg5hZTIlX8nuLUEt0ZewGe8eCY0Ipmx X-Received: by 2002:ac8:5e49:0:b0:429:bc16:b4b4 with SMTP id i9-20020ac85e49000000b00429bc16b4b4mr119822qtx.43.1704943368824; Wed, 10 Jan 2024 19:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704943368; cv=none; d=google.com; s=arc-20160816; b=BXdrC8lc3VyccqOwJxarFcpLaYWCH+b7rt6orSVnUEhcHFyhfQqC/ftZoTipv/bSxQ E7SKQm6O5uER5c3Tv/qTJyvtOVNGh+rnBE3Ue/bAFpZbPmupbNAdkUBhvZVzLkvGqEo+ I1k76ELy0Ep1cNWG9l1ho5kNvAcDNXoSn1q0RlVL1+WYtiVe2zwCRD3jTLeT5R1/nZV/ ewU+iDgSF9vTYfO3NqdQF/mLGyCCVYcyL2Gurg5snsZUkZShHNd2p24I58xb1uwqrURm QzfCcsQnKMF2+JH2ZzcUJaAp6cEt8C1o7LZbZp7vog1FkTFz+VNqTslJSlU+io8XVXig 5knA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=k1Ho/05+osX5yBSt3dsuOnnijSKuAo5CebqXC420Q7U=; fh=ibj0IwplJyeuAF+X2vqBIpOOEUE9KBluHxouCFj7l2Y=; b=RjiyYplu7I8nt/mbU6YXWh274Z8Em4nrjeuYY3dY0Xv7qgR+frmfEJuOzhg1a0YJbE fBxlk02me/Zx9cQAR7/T7WuH7x+GVS0+feY7/G2CBmyyZtPEmXEovRVKjl6bh1oVAivc MU07xtBoZ9+mcn2/TH/OG7O/hvTB8Bm/RC01FHsTaWZV3YSCvrcNQ1q5QjbfrIVqOt/z HDMGqnuZaC+M0E4DDFL6rxHkXAlMSwXWUgokylkAJ4nUMhFJx4o6/w195+ILR63VnYlz I1MJKgWGWRD4bb9QsIZoxfhFyRzylxG0Ufn+HSzTnYcXZhKr27BcjsHm+d0OUORFgWNB BExg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=MWF2Dpq7; spf=pass (google.com: domain of linux-kernel+bounces-23022-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23022-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y16-20020a05622a165000b0042604f94036si165337qtj.739.2024.01.10.19.22.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 19:22:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23022-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=MWF2Dpq7; spf=pass (google.com: domain of linux-kernel+bounces-23022-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23022-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 926A41C22C93 for ; Thu, 11 Jan 2024 03:22:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 890E01C31; Thu, 11 Jan 2024 03:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="MWF2Dpq7" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 4C74415A1; Thu, 11 Jan 2024 03:22:35 +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=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Sender:Reply-To:Content-ID:Content-Description; bh=k1Ho/05+osX5yBSt3dsuOnnijSKuAo5CebqXC420Q7U=; b=MWF2Dpq7Y6wltSXPDDINajcI5z GhKGOIHtn/iLM+LJ31ocb50G/zGRv9WgoBOdPN1TOs8JykLCj8Gl9i6djrIYjtQqas8MjVYXPV0Aq GV3HqHmZZEknI5KXH+mzG2SSyiJ8KsqyI7C03URgKjcGhZ9XT7UpQkKhJKP00wIP9cqBM4sbORtNc xpXLLhh7oo2SJfj8gMZuYuCq47n0a8Hbj7Dcsg1AkLcRT4fFe9YZYapYiTpSWeIhmSs226DK/EE4K DThCQgo5w0AKIpDk9oU4dL36zaeM2RIC3A+ZmqRgriedyiHl+T7jCwTkruDtW9jHj1Oif59TTPvUp 9u/kWvSQ==; Received: from [50.53.46.231] (helo=[192.168.254.15]) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rNleL-00FbcJ-1o; Thu, 11 Jan 2024 03:22:33 +0000 Message-ID: <55680bae-966a-4a31-85f9-9ca516b80145@infradead.org> Date: Wed, 10 Jan 2024 19:22:33 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/8] buffer: Add kernel-doc for try_to_free_buffers() Content-Language: en-US To: "Matthew Wilcox (Oracle)" , Jonathan Corbet Cc: linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240109143357.2375046-1-willy@infradead.org> <20240109143357.2375046-4-willy@infradead.org> From: Randy Dunlap In-Reply-To: <20240109143357.2375046-4-willy@infradead.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, On 1/9/24 06:33, Matthew Wilcox (Oracle) wrote: > 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 071f01b28c90..25861241657f 100644 > --- a/fs/buffer.c > +++ b/fs/buffer.c > @@ -2864,26 +2864,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 i_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 > - * i_private_lock. > - * > - * try_to_free_buffers() is non-blocking. > - */ > static inline int buffer_busy(struct buffer_head *bh) > { > return atomic_read(&bh->b_count) | > @@ -2917,6 +2897,30 @@ drop_buffers(struct folio *folio, struct buffer_head **buffers_to_free) > return false; > } > > +/** > + * try_to_free_buffers: Release buffers attached to this folio. preferably s/_buffers: /_buffers - / > + * @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 > + * i_private_lock. > + * > + * Exclusion against try_to_free_buffers may be obtained by either > + * locking the folio or by holding its mapping's i_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; -- #Randy