From: Mikulas Patocka <mpatocka@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
Chaitanya Kulkarni <chaitanyak@nvidia.com>,
Christoph Hellwig <hch@infradead.org>,
Li Nan <linan666@huaweicloud.com>,
dm-devel@redhat.com, Zdenek Kabelac <zkabelac@redhat.com>
Subject: [dm-devel] [PATCH v2 1/3] brd: extend the rcu regions to cover read and write
Date: Fri, 21 Jul 2023 15:49:29 +0200 (CEST) [thread overview]
Message-ID: <7d99fa-9c13-ab2a-acde-1f8bbc63bf3@redhat.com> (raw)
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();
}
}
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
next reply other threads:[~2023-07-21 13:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 13:49 Mikulas Patocka [this message]
[not found] ` <CGME20230727083159eucas1p1c4b907caac8371200bbd465143ac39fd@eucas1p1.samsung.com>
2023-07-27 8:31 ` [dm-devel] [PATCH v2 1/3] brd: extend the rcu regions to cover read and write Pankaj Raghav
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=7d99fa-9c13-ab2a-acde-1f8bbc63bf3@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;
as well as URLs for NNTP newsgroup(s).