From: Neil Brown <neilb@suse.de>
To: Shaohua Li <shli@fb.com>, linux-raid@vger.kernel.org
Cc: Kernel-team@fb.com, songliubraving@fb.com, hch@infradead.org,
dan.j.williams@intel.com
Subject: Re: [PATCH 8/8] raid5-cache: add trim support for log
Date: Wed, 30 Sep 2015 14:14:58 +1000 [thread overview]
Message-ID: <874micmtkt.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <4ac2b019b16111478c46ea6decb672d5a4de7de3.1441221530.git.shli@fb.com>
[-- Attachment #1: Type: text/plain, Size: 2320 bytes --]
Shaohua Li <shli@fb.com> writes:
> Since superblock is updated infrequently, we do a simple trim of log
> disk (a synchronous trim)
>
> Signed-off-by: Shaohua Li <shli@fb.com>
> ---
> drivers/md/raid5-cache.c | 30 +++++++++++++++++++++++++++++-
> 1 file changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
> index 27fb513..410b85b 100644
> --- a/drivers/md/raid5-cache.c
> +++ b/drivers/md/raid5-cache.c
> @@ -639,6 +639,34 @@ static void r5l_kick_io_unit(struct r5l_log *log)
> }
>
> static void r5l_write_super(struct r5l_log *log, sector_t cp);
> +static void r5l_write_super_and_discard_space(struct r5l_log *log,
> + sector_t end)
> +{
> + struct block_device *bdev = log->rdev->bdev;
> +
> + r5l_write_super(log, end);
> +
> + if (!blk_queue_discard(bdev_get_queue(bdev)))
> + return;
> +
> + /* discard destroy old data in log, so force a super update */
> + md_update_sb(log->rdev->mddev, 1);
I don't think this can go here.
md_update_sb() is currently always called with ->reconfig_mutex held,
and I think that should stay.
Instead you could:
set_bit(MD_CHANGE_PENDING, &mddev->flags);
md_wakeup_thread(mddev->thread);
wait_event(mddev->sb_wait,
!test_bit(MD_CHANGE_PENDING, &mddev->flags));
a bit like md_write_start().
Thanks,
NeilBrown
> +
> + if (log->last_checkpoint < end) {
> + blkdev_issue_discard(bdev,
> + log->last_checkpoint + log->rdev->data_offset,
> + end - log->last_checkpoint, GFP_NOIO, 0);
> + } else {
> + blkdev_issue_discard(bdev,
> + log->last_checkpoint + log->rdev->data_offset,
> + log->device_size - log->last_checkpoint,
> + GFP_NOIO, 0);
> + blkdev_issue_discard(bdev, log->rdev->data_offset, end,
> + GFP_NOIO, 0);
> + }
> +}
> +
> +
> static void r5l_do_reclaim(struct r5l_log *log)
> {
> struct r5l_io_unit *io, *last;
> @@ -694,7 +722,7 @@ static void r5l_do_reclaim(struct r5l_log *log)
> * here, because the log area might be reused soon and we don't want to
> * confuse recovery
> * */
> - r5l_write_super(log, last->log_start);
> + r5l_write_super_and_discard_space(log, last->log_start);
>
> mutex_lock(&log->io_mutex);
> log->last_checkpoint = last->log_start;
> --
> 1.8.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
next prev parent reply other threads:[~2015-09-30 4:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-02 20:49 [PATCH 0/8] raid5-cache fixes Shaohua Li
2015-09-02 20:49 ` [PATCH 1/8] md: fix feature map check Shaohua Li
2015-09-02 20:49 ` [PATCH 2/8] raid5: fix build error Shaohua Li
2015-09-02 20:49 ` [PATCH 3/8] raid5-cache: switching to state machine for log disk cache flush Shaohua Li
2015-09-02 20:49 ` [PATCH 4/8] raid5-cache: fix a user-after-free bug Shaohua Li
2015-09-02 20:49 ` [PATCH 5/8] raid5-cache: move functionality out of __r5l_set_io_unit_state Shaohua Li
2015-09-02 20:49 ` [PATCH 6/8] raid5-cache: optimize FLUSH IO with log enabled Shaohua Li
2015-09-02 20:49 ` [PATCH 7/8] md: skip resync for raid array with journal Shaohua Li
2015-09-30 4:24 ` Neil Brown
2015-10-01 17:47 ` Song Liu
2015-10-01 23:50 ` Neil Brown
2015-09-02 20:49 ` [PATCH 8/8] raid5-cache: add trim support for log Shaohua Li
2015-09-30 4:14 ` Neil Brown [this message]
2015-09-30 5:36 ` [PATCH 0/8] raid5-cache fixes Neil Brown
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=874micmtkt.fsf@notabene.neil.brown.name \
--to=neilb@suse.de \
--cc=Kernel-team@fb.com \
--cc=dan.j.williams@intel.com \
--cc=hch@infradead.org \
--cc=linux-raid@vger.kernel.org \
--cc=shli@fb.com \
--cc=songliubraving@fb.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 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.