* two small raid5 cache updates
@ 2015-12-02 16:06 Christoph Hellwig
2015-12-02 16:06 ` [PATCH 1/2] raid5-cache: simplify r5l_move_io_unit_list Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Christoph Hellwig @ 2015-12-02 16:06 UTC (permalink / raw)
To: shli, neilb; +Cc: linux-raid
The first is a trival cleanup, the second a similarly trivial reduction
in memory usage.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] raid5-cache: simplify r5l_move_io_unit_list
2015-12-02 16:06 two small raid5 cache updates Christoph Hellwig
@ 2015-12-02 16:06 ` Christoph Hellwig
2015-12-02 16:06 ` [PATCH 2/2] raid5-cache: free meta_page earlier Christoph Hellwig
2015-12-03 4:47 ` two small raid5 cache updates Shaohua Li
2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2015-12-02 16:06 UTC (permalink / raw)
To: shli, neilb; +Cc: linux-raid
It's only used for one kind of move, so make that explicit. Also clean
up the code a bit by using list_for_each_safe.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/raid5-cache.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index b887e04..3699c47 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -156,21 +156,6 @@ static void r5l_free_io_unit(struct r5l_log *log, struct r5l_io_unit *io)
kmem_cache_free(log->io_kc, io);
}
-static void r5l_move_io_unit_list(struct list_head *from, struct list_head *to,
- enum r5l_io_unit_state state)
-{
- struct r5l_io_unit *io;
-
- while (!list_empty(from)) {
- io = list_first_entry(from, struct r5l_io_unit, log_sibling);
- /* don't change list order */
- if (io->state >= state)
- list_move_tail(&io->log_sibling, to);
- else
- break;
- }
-}
-
static void __r5l_set_io_unit_state(struct r5l_io_unit *io,
enum r5l_io_unit_state state)
{
@@ -206,6 +191,20 @@ static void r5l_log_run_stripes(struct r5l_log *log)
}
}
+static void r5l_move_to_end_ios(struct r5l_log *log)
+{
+ struct r5l_io_unit *io, *next;
+
+ assert_spin_locked(&log->io_list_lock);
+
+ list_for_each_entry_safe(io, next, &log->running_ios, log_sibling) {
+ /* don't change list order */
+ if (io->state < IO_UNIT_IO_END)
+ break;
+ list_move_tail(&io->log_sibling, &log->io_end_ios);
+ }
+}
+
static void r5l_log_endio(struct bio *bio)
{
struct r5l_io_unit *io = bio->bi_private;
@@ -220,8 +219,7 @@ static void r5l_log_endio(struct bio *bio)
spin_lock_irqsave(&log->io_list_lock, flags);
__r5l_set_io_unit_state(io, IO_UNIT_IO_END);
if (log->need_cache_flush)
- r5l_move_io_unit_list(&log->running_ios, &log->io_end_ios,
- IO_UNIT_IO_END);
+ r5l_move_to_end_ios(log);
else
r5l_log_run_stripes(log);
spin_unlock_irqrestore(&log->io_list_lock, flags);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] raid5-cache: free meta_page earlier
2015-12-02 16:06 two small raid5 cache updates Christoph Hellwig
2015-12-02 16:06 ` [PATCH 1/2] raid5-cache: simplify r5l_move_io_unit_list Christoph Hellwig
@ 2015-12-02 16:06 ` Christoph Hellwig
2015-12-03 4:47 ` two small raid5 cache updates Shaohua Li
2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2015-12-02 16:06 UTC (permalink / raw)
To: shli, neilb; +Cc: linux-raid
Once the I/O completed we don't need the meta page anymore. As the iounits
can live on for a long time this reduces memory pressure a bit.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/raid5-cache.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 3699c47..668e973 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -150,12 +150,6 @@ static bool r5l_has_free_space(struct r5l_log *log, sector_t size)
return log->device_size > used_size + size;
}
-static void r5l_free_io_unit(struct r5l_log *log, struct r5l_io_unit *io)
-{
- __free_page(io->meta_page);
- kmem_cache_free(log->io_kc, io);
-}
-
static void __r5l_set_io_unit_state(struct r5l_io_unit *io,
enum r5l_io_unit_state state)
{
@@ -215,6 +209,7 @@ static void r5l_log_endio(struct bio *bio)
md_error(log->rdev->mddev, log->rdev);
bio_put(bio);
+ __free_page(io->meta_page);
spin_lock_irqsave(&log->io_list_lock, flags);
__r5l_set_io_unit_state(io, IO_UNIT_IO_END);
@@ -552,7 +547,7 @@ static bool r5l_complete_finished_ios(struct r5l_log *log)
log->next_cp_seq = io->seq;
list_del(&io->log_sibling);
- r5l_free_io_unit(log, io);
+ kmem_cache_free(log->io_kc, io);
found = true;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: two small raid5 cache updates
2015-12-02 16:06 two small raid5 cache updates Christoph Hellwig
2015-12-02 16:06 ` [PATCH 1/2] raid5-cache: simplify r5l_move_io_unit_list Christoph Hellwig
2015-12-02 16:06 ` [PATCH 2/2] raid5-cache: free meta_page earlier Christoph Hellwig
@ 2015-12-03 4:47 ` Shaohua Li
2015-12-08 22:57 ` NeilBrown
2 siblings, 1 reply; 5+ messages in thread
From: Shaohua Li @ 2015-12-03 4:47 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: neilb, linux-raid
On Wed, Dec 02, 2015 at 05:06:37PM +0100, Christoph Hellwig wrote:
> The first is a trival cleanup, the second a similarly trivial reduction
> in memory usage.
Looks good, thanks!
Reviewed-by: Shaohua Li <shli@fb.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: two small raid5 cache updates
2015-12-03 4:47 ` two small raid5 cache updates Shaohua Li
@ 2015-12-08 22:57 ` NeilBrown
0 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2015-12-08 22:57 UTC (permalink / raw)
To: Shaohua Li, Christoph Hellwig; +Cc: linux-raid
[-- Attachment #1: Type: text/plain, Size: 304 bytes --]
On Thu, Dec 03 2015, Shaohua Li wrote:
> On Wed, Dec 02, 2015 at 05:06:37PM +0100, Christoph Hellwig wrote:
>> The first is a trival cleanup, the second a similarly trivial reduction
>> in memory usage.
>
> Looks good, thanks!
>
> Reviewed-by: Shaohua Li <shli@fb.com>
Both applied, thanks.
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-12-08 22:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-02 16:06 two small raid5 cache updates Christoph Hellwig
2015-12-02 16:06 ` [PATCH 1/2] raid5-cache: simplify r5l_move_io_unit_list Christoph Hellwig
2015-12-02 16:06 ` [PATCH 2/2] raid5-cache: free meta_page earlier Christoph Hellwig
2015-12-03 4:47 ` two small raid5 cache updates Shaohua Li
2015-12-08 22:57 ` NeilBrown
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).