All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Subject: [PATCH 52/56] nilfs: Convert nilfs_set_page_dirty() to nilfs_dirty_folio()
Date: Wed,  9 Feb 2022 20:22:11 +0000	[thread overview]
Message-ID: <20220209202215.2055748-53-willy@infradead.org> (raw)
In-Reply-To: <20220209202215.2055748-1-willy@infradead.org>

The comment about the page always being locked is wrong, so copy
the locking protection from __set_page_dirty_buffers().  That
means moving the call to nilfs_set_file_dirty() down the
function so as to not acquire a new dependency between the
mapping->private_lock and the ns_inode_lock.  That might be a
harmless dependency to add, but it's not necessary.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/nilfs2/inode.c | 39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 153f0569dcf2..c1219c0678a5 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -199,23 +199,23 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
 	return 0;
 }
 
-static int nilfs_set_page_dirty(struct page *page)
+static bool nilfs_dirty_folio(struct address_space *mapping,
+		struct folio *folio)
 {
-	struct inode *inode = page->mapping->host;
-	int ret = __set_page_dirty_nobuffers(page);
+	struct inode *inode = mapping->host;
+	struct buffer_head *head;
+	unsigned int nr_dirty;
+	bool ret = filemap_dirty_folio(mapping, folio);
 
-	if (page_has_buffers(page)) {
-		unsigned int nr_dirty = 0;
-		struct buffer_head *bh, *head;
+	/*
+	 * The page may not be locked, eg if called from try_to_unmap_one()
+	 */
+	spin_lock(&mapping->private_lock);
+	head = folio_buffers(folio);
+	if (head) {
+		struct buffer_head *bh = head;
 
-		/*
-		 * This page is locked by callers, and no other thread
-		 * concurrently marks its buffers dirty since they are
-		 * only dirtied through routines in fs/buffer.c in
-		 * which call sites of mark_buffer_dirty are protected
-		 * by page lock.
-		 */
-		bh = head = page_buffers(page);
+		nr_dirty = 0;
 		do {
 			/* Do not mark hole blocks dirty */
 			if (buffer_dirty(bh) || !buffer_mapped(bh))
@@ -224,14 +224,13 @@ static int nilfs_set_page_dirty(struct page *page)
 			set_buffer_dirty(bh);
 			nr_dirty++;
 		} while (bh = bh->b_this_page, bh != head);
-
-		if (nr_dirty)
-			nilfs_set_file_dirty(inode, nr_dirty);
 	} else if (ret) {
-		unsigned int nr_dirty = 1 << (PAGE_SHIFT - inode->i_blkbits);
+		nr_dirty = 1 << (PAGE_SHIFT - inode->i_blkbits);
+	}
+	spin_unlock(&mapping->private_lock);
 
+	if (nr_dirty)
 		nilfs_set_file_dirty(inode, nr_dirty);
-	}
 	return ret;
 }
 
@@ -299,7 +298,7 @@ const struct address_space_operations nilfs_aops = {
 	.writepage		= nilfs_writepage,
 	.readpage		= nilfs_readpage,
 	.writepages		= nilfs_writepages,
-	.set_page_dirty		= nilfs_set_page_dirty,
+	.dirty_folio		= nilfs_dirty_folio,
 	.readahead		= nilfs_readahead,
 	.write_begin		= nilfs_write_begin,
 	.write_end		= nilfs_write_end,
-- 
2.34.1


  parent reply	other threads:[~2022-02-09 20:23 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 20:21 [PATCH 00/56] Filesystem folio conversions for 5.18 Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 01/56] Convert NFS from readpages to readahead Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 02/56] readahead: Remove read_cache_pages() Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 03/56] iomap: Fix iomap_invalidatepage tracepoint Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 04/56] fs: read_mapping_page() should take a struct file argument Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 05/56] fs/remap_range: Pass the file pointer to read_mapping_folio() Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 06/56] scsicam: Fix use of page cache Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 07/56] buffer: Add folio_buffers() Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 08/56] fs: Convert is_partially_uptodate to folios Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 09/56] fs: Turn do_invalidatepage() into folio_invalidate() Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 10/56] btrfs: Use folio_invalidate() Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 11/56] ceph: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 12/56] ext4: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 13/56] fs: Add invalidate_folio() aops method Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 14/56] iomap: Remove iomap_invalidatepage() Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 15/56] fs: Turn block_invalidatepage into block_invalidate_folio Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 16/56] fs: Remove noop_invalidatepage() Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 17/56] 9p: Convert to invalidate_folio Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 18/56] afs: Convert directory aops " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 19/56] afs: Convert invalidatepage " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 20/56] btrfs: Convert from " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 21/56] ceph: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 22/56] cifs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 23/56] erofs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 24/56] ext4: Convert " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 25/56] f2fs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 26/56] gfs2: " Matthew Wilcox (Oracle)
2022-02-10 12:42   ` Bob Peterson
2022-02-09 20:21 ` [PATCH 27/56] jfs: Convert from " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 28/56] nfs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 29/56] orangefs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 30/56] reiserfs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 31/56] ubifs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 32/56] fs: Remove aops->invalidatepage Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 33/56] fs: Add aops->launder_folio Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 34/56] 9p: Convert from launder_page to launder_folio Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 35/56] afs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 36/56] cifs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 37/56] fuse: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 38/56] nfs: " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 39/56] orangefs: Convert " Matthew Wilcox (Oracle)
2022-02-09 20:21 ` [PATCH 40/56] fs: Remove aops->launder_page Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 41/56] fs: Add aops->dirty_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 42/56] fscache: Convert fscache_set_page_dirty() to fscache_dirty_folio() Matthew Wilcox (Oracle)
2022-02-14  7:02   ` John Hubbard
2022-02-14 14:12     ` Matthew Wilcox
2022-02-09 20:22 ` [PATCH 43/56] btrfs: Convert from set_page_dirty to dirty_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 44/56] fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 45/56] btrfs: Convert extent_range_redirty_for_io() to use folios Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 46/56] afs: Convert afs_dir_set_page_dirty() to afs_dir_dirty_folio() Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 47/56] f2fs: Convert f2fs_set_meta_page_dirty to f2fs_dirty_meta_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 48/56] f2fs: Convert f2fs_set_data_page_dirty to f2fs_dirty_data_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 49/56] f2fs: Convert f2fs_set_node_page_dirty to f2fs_dirty_node_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 50/56] ubifs: Convert ubifs_set_page_dirty to ubifs_dirty_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 51/56] mm: Convert swap_set_page_dirty() to swap_dirty_folio() Matthew Wilcox (Oracle)
2022-02-09 20:22 ` Matthew Wilcox (Oracle) [this message]
2022-02-09 20:22 ` [PATCH 53/56] fs: Convert __set_page_dirty_buffers to block_dirty_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 54/56] fs: Convert __set_page_dirty_no_writeback to noop_dirty_folio Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 55/56] fb_defio: Use noop_dirty_folio() Matthew Wilcox (Oracle)
2022-02-09 20:22 ` [PATCH 56/56] fs: Remove aops ->set_page_dirty Matthew Wilcox (Oracle)
2022-02-10  4:31 ` [PATCH 00/56] Filesystem folio conversions for 5.18 Damien Le Moal
2022-02-14 14:19 ` Matthew Wilcox
2022-02-25 14:52   ` Mike Marshall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220209202215.2055748-53-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.