From: Mikulas Patocka <mpatocka@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Li Nan <linan666@huaweicloud.com>,
Zdenek Kabelac <zkabelac@redhat.com>,
Christoph Hellwig <hch@infradead.org>,
Chaitanya Kulkarni <chaitanyak@nvidia.com>,
linux-block@vger.kernel.org, dm-devel@redhat.com
Subject: [PATCH v3 2/4] brd: extend the rcu regions to cover read and write
Date: Thu, 10 Aug 2023 12:09:11 +0200 (CEST) [thread overview]
Message-ID: <2ae7f7aa-add7-a7f5-e73e-443fc97a0d9@redhat.com> (raw)
In-Reply-To: <2dacc73-854-e71c-1746-99b017401c9a@redhat.com>
This patch extends the rcu regions, so that lookup followed by a read or
write of a page is done inside rcu read lock. This is needed for the
following patch that enables discard.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/block/brd.c | 8 ++++++++
1 file changed, 8 insertions(+)
Index: linux-2.6/drivers/block/brd.c
===================================================================
--- linux-2.6.orig/drivers/block/brd.c
+++ linux-2.6/drivers/block/brd.c
@@ -150,23 +150,27 @@ static void copy_to_brd(struct brd_devic
size_t copy;
copy = min_t(size_t, n, PAGE_SIZE - offset);
+ rcu_read_lock();
page = brd_lookup_page(brd, sector);
BUG_ON(!page);
dst = kmap_atomic(page);
memcpy(dst + offset, src, copy);
kunmap_atomic(dst);
+ rcu_read_unlock();
if (copy < n) {
src += copy;
sector += copy >> SECTOR_SHIFT;
copy = n - copy;
+ rcu_read_lock();
page = brd_lookup_page(brd, sector);
BUG_ON(!page);
dst = kmap_atomic(page);
memcpy(dst, src, copy);
kunmap_atomic(dst);
+ rcu_read_unlock();
}
}
@@ -182,6 +186,7 @@ static void copy_from_brd(void *dst, str
size_t copy;
copy = min_t(size_t, n, PAGE_SIZE - offset);
+ rcu_read_lock();
page = brd_lookup_page(brd, sector);
if (page) {
src = kmap_atomic(page);
@@ -189,11 +194,13 @@ static void copy_from_brd(void *dst, str
kunmap_atomic(src);
} else
memset(dst, 0, copy);
+ rcu_read_unlock();
if (copy < n) {
dst += copy;
sector += copy >> SECTOR_SHIFT;
copy = n - copy;
+ rcu_read_lock();
page = brd_lookup_page(brd, sector);
if (page) {
src = kmap_atomic(page);
@@ -201,6 +208,7 @@ static void copy_from_brd(void *dst, str
kunmap_atomic(src);
} else
memset(dst, 0, copy);
+ rcu_read_unlock();
}
}
next prev parent reply other threads:[~2023-08-10 10:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 10:07 [PATCH v3 0/4] brd discard patches Mikulas Patocka
2023-08-10 10:08 ` [PATCH v3 1/4] brd: use a switch statement in brd_submit_bio Mikulas Patocka
2023-08-10 10:09 ` Mikulas Patocka [this message]
2023-08-10 10:09 ` [PATCH v3 3/4] brd: enable discard Mikulas Patocka
2023-08-10 10:10 ` [PATCH v3 4/4] brd: implement write zeroes Mikulas Patocka
2023-11-10 1:22 ` [PATCH v3 0/4] brd discard patches Li Nan
2023-11-14 13:59 ` Mikulas Patocka
2024-01-19 8:41 ` Ming Lei
2024-01-22 16:30 ` Mikulas Patocka
2024-01-23 2:49 ` Ming Lei
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=2ae7f7aa-add7-a7f5-e73e-443fc97a0d9@redhat.com \
--to=mpatocka@redhat.com \
--cc=axboe@kernel.dk \
--cc=chaitanyak@nvidia.com \
--cc=dm-devel@redhat.com \
--cc=hch@infradead.org \
--cc=linan666@huaweicloud.com \
--cc=linux-block@vger.kernel.org \
--cc=zkabelac@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