From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 5/7] gfs2: Align read and write chunks to the page cache
Date: Fri, 13 May 2022 22:48:08 +0200 [thread overview]
Message-ID: <20220513204810.4123139-6-agruenba@redhat.com> (raw)
In-Reply-To: <20220513204810.4123139-1-agruenba@redhat.com>
Align the chunks that reads and writes are carried out in to the page
cache rather than the user buffers. This will be more efficient in
general, especially for allocating writes. Optimizing the case that the
user buffer is gfs2 backed isn't very useful; we only need to make sure
we won't deadlock.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/file.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index ea87bef7314d..11c46407d4a8 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -771,6 +771,7 @@ static int gfs2_fsync(struct file *file, loff_t start, loff_t end,
}
static inline bool should_fault_in_pages(struct iov_iter *i,
+ struct kiocb *iocb,
size_t *prev_count,
size_t *window_size)
{
@@ -783,15 +784,13 @@ static inline bool should_fault_in_pages(struct iov_iter *i,
return false;
size = PAGE_SIZE;
- offs = offset_in_page(i->iov[0].iov_base + i->iov_offset);
+ offs = offset_in_page(iocb->ki_pos);
if (*prev_count != count || !*window_size) {
size_t nr_dirtied;
- size = ALIGN(offs + count, PAGE_SIZE);
- size = min_t(size_t, size, SZ_1M);
nr_dirtied = max(current->nr_dirtied_pause -
current->nr_dirtied, 8);
- size = min(size, nr_dirtied << PAGE_SHIFT);
+ size = min_t(size_t, SZ_1M, nr_dirtied << PAGE_SHIFT);
}
*prev_count = count;
@@ -845,7 +844,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
if (ret > 0)
read = ret;
- if (should_fault_in_pages(to, &prev_count, &window_size)) {
+ if (should_fault_in_pages(to, iocb, &prev_count, &window_size)) {
gfs2_holder_allow_demote(gh);
window_size -= fault_in_iov_iter_writeable(to, window_size);
gfs2_holder_disallow_demote(gh);
@@ -916,7 +915,7 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
if (ret > 0)
written = ret;
- if (should_fault_in_pages(from, &prev_count, &window_size)) {
+ if (should_fault_in_pages(from, iocb, &prev_count, &window_size)) {
gfs2_holder_allow_demote(gh);
window_size -= fault_in_iov_iter_readable(from, window_size);
gfs2_holder_disallow_demote(gh);
@@ -984,7 +983,7 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
if (ret > 0)
read += ret;
- if (should_fault_in_pages(to, &prev_count, &window_size)) {
+ if (should_fault_in_pages(to, iocb, &prev_count, &window_size)) {
gfs2_holder_allow_demote(&gh);
window_size -= fault_in_iov_iter_writeable(to, window_size);
gfs2_holder_disallow_demote(&gh);
@@ -1061,7 +1060,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
goto out_unlock;
from->count = orig_count - written;
- if (should_fault_in_pages(from, &prev_count, &window_size)) {
+ if (should_fault_in_pages(from, iocb, &prev_count, &window_size)) {
gfs2_holder_allow_demote(gh);
window_size -= fault_in_iov_iter_readable(from, window_size);
gfs2_holder_disallow_demote(gh);
--
2.35.1
next prev parent reply other threads:[~2022-05-13 20:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 20:48 [Cluster-devel] [PATCH 0/7] gfs2 fixes Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 1/7] gfs2: Fix filesystem block deallocation for short writes Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 2/7] gfs2: Variable rename Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 3/7] gfs2: Clean up use of fault_in_iov_iter_{read, write}able Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 4/7] gfs2: Pull return value test out of should_fault_in_pages Andreas Gruenbacher
2022-05-13 20:48 ` Andreas Gruenbacher [this message]
2022-05-13 20:48 ` [Cluster-devel] [PATCH 6/7] gfs2: buffered write prefaulting Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 7/7] gfs2: Stop using glock holder auto-demotion for now Andreas Gruenbacher
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=20220513204810.4123139-6-agruenba@redhat.com \
--to=agruenba@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).