From: Jens Axboe <axboe@kernel.dk>
To: linux-block@vger.kernel.org, linux-mm@kvack.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 1/2] mm: move filemap_range_needs_writeback() into header
Date: Fri, 3 Dec 2021 08:38:28 -0700 [thread overview]
Message-ID: <20211203153829.298893-2-axboe@kernel.dk> (raw)
In-Reply-To: <20211203153829.298893-1-axboe@kernel.dk>
No functional changes in this patch, just in preparation for efficiently
calling this light function from the block O_DIRECT handling.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
include/linux/fs.h | 35 +++++++++++++++++++++++++++++++++++
mm/filemap.c | 38 +++-----------------------------------
2 files changed, 38 insertions(+), 35 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index bbf812ce89a8..0cc4f5fd4cfe 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2845,6 +2845,41 @@ static inline int filemap_fdatawait(struct address_space *mapping)
return filemap_fdatawait_range(mapping, 0, LLONG_MAX);
}
+/* Returns true if writeback might be needed or already in progress. */
+static inline bool mapping_needs_writeback(struct address_space *mapping)
+{
+ return mapping->nrpages;
+}
+
+bool filemap_range_has_writeback(struct address_space *mapping,
+ loff_t start_byte, loff_t end_byte);
+
+/**
+ * filemap_range_needs_writeback - check if range potentially needs writeback
+ * @mapping: address space within which to check
+ * @start_byte: offset in bytes where the range starts
+ * @end_byte: offset in bytes where the range ends (inclusive)
+ *
+ * Find at least one page in the range supplied, usually used to check if
+ * direct writing in this range will trigger a writeback. Used by O_DIRECT
+ * read/write with IOCB_NOWAIT, to see if the caller needs to do
+ * filemap_write_and_wait_range() before proceeding.
+ *
+ * Return: %true if the caller should do filemap_write_and_wait_range() before
+ * doing O_DIRECT to a page in this range, %false otherwise.
+ */
+static inline bool filemap_range_needs_writeback(struct address_space *mapping,
+ loff_t start_byte,
+ loff_t end_byte)
+{
+ if (!mapping_needs_writeback(mapping))
+ return false;
+ if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) &&
+ !mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
+ return false;
+ return filemap_range_has_writeback(mapping, start_byte, end_byte);
+}
+
extern bool filemap_range_has_page(struct address_space *, loff_t lstart,
loff_t lend);
extern bool filemap_range_needs_writeback(struct address_space *,
diff --git a/mm/filemap.c b/mm/filemap.c
index daa0e23a6ee6..65238440fa0a 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -640,14 +640,8 @@ int filemap_fdatawait_keep_errors(struct address_space *mapping)
}
EXPORT_SYMBOL(filemap_fdatawait_keep_errors);
-/* Returns true if writeback might be needed or already in progress. */
-static bool mapping_needs_writeback(struct address_space *mapping)
-{
- return mapping->nrpages;
-}
-
-static bool filemap_range_has_writeback(struct address_space *mapping,
- loff_t start_byte, loff_t end_byte)
+bool filemap_range_has_writeback(struct address_space *mapping,
+ loff_t start_byte, loff_t end_byte)
{
XA_STATE(xas, &mapping->i_pages, start_byte >> PAGE_SHIFT);
pgoff_t max = end_byte >> PAGE_SHIFT;
@@ -667,34 +661,8 @@ static bool filemap_range_has_writeback(struct address_space *mapping,
}
rcu_read_unlock();
return page != NULL;
-
-}
-
-/**
- * filemap_range_needs_writeback - check if range potentially needs writeback
- * @mapping: address space within which to check
- * @start_byte: offset in bytes where the range starts
- * @end_byte: offset in bytes where the range ends (inclusive)
- *
- * Find at least one page in the range supplied, usually used to check if
- * direct writing in this range will trigger a writeback. Used by O_DIRECT
- * read/write with IOCB_NOWAIT, to see if the caller needs to do
- * filemap_write_and_wait_range() before proceeding.
- *
- * Return: %true if the caller should do filemap_write_and_wait_range() before
- * doing O_DIRECT to a page in this range, %false otherwise.
- */
-bool filemap_range_needs_writeback(struct address_space *mapping,
- loff_t start_byte, loff_t end_byte)
-{
- if (!mapping_needs_writeback(mapping))
- return false;
- if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) &&
- !mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
- return false;
- return filemap_range_has_writeback(mapping, start_byte, end_byte);
}
-EXPORT_SYMBOL_GPL(filemap_range_needs_writeback);
+EXPORT_SYMBOL_GPL(filemap_range_has_writeback);
/**
* filemap_write_and_wait_range - write out & wait on a file range
--
2.34.1
next prev parent reply other threads:[~2021-12-03 15:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-03 15:38 [PATCHSET 0/2] Avoid unnecessary indirect calls for bdev dio Jens Axboe
2021-12-03 15:38 ` Jens Axboe [this message]
2021-12-03 16:16 ` [PATCH 1/2] mm: move filemap_range_needs_writeback() into header Matthew Wilcox
2021-12-03 16:24 ` Jens Axboe
2021-12-03 16:31 ` Jens Axboe
2021-12-03 16:35 ` Jens Axboe
2021-12-03 16:38 ` Jens Axboe
2021-12-03 17:46 ` Matthew Wilcox
2021-12-03 17:57 ` Jens Axboe
2021-12-03 18:01 ` Jens Axboe
2021-12-03 18:14 ` Matthew Wilcox
2021-12-03 19:09 ` Jens Axboe
2021-12-03 15:38 ` [PATCH 2/2] block: move direct_IO into our own read_iter handler Jens Axboe
2021-12-06 6:58 ` Christoph Hellwig
2021-12-06 16:33 ` Jens Axboe
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=20211203153829.298893-2-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-mm@kvack.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.