From: Shaohua Li <shli@kernel.org>
To: Song Liu <songliubraving@fb.com>
Cc: linux-raid@vger.kernel.org, neilb@suse.com, shli@fb.com,
kernel-team@fb.com, dan.j.williams@intel.com, hch@infradead.org,
liuzhengyuang521@gmail.com, liuzhengyuan@kylinos.cn
Subject: Re: [PATCH v6 06/11] md/r5cache: sysfs entry r5c_journal_mode
Date: Tue, 15 Nov 2016 15:35:03 -0800 [thread overview]
Message-ID: <20161115233503.amnrvlwp6cy3nequ@kernel.org> (raw)
In-Reply-To: <20161110204623.3484694-7-songliubraving@fb.com>
On Thu, Nov 10, 2016 at 12:46:18PM -0800, Song Liu wrote:
> With write cache, r5c_journal_mode is the knob to switch between
> write-back and write-through.
I'd prefer the name is journal_mode
> Below is an example:
>
> root@virt-test:~/# cat /sys/block/md0/md/r5c_state
> [write-through] write-back
> root@virt-test:~/# echo write-back > /sys/block/md0/md/r5c_state
> root@virt-test:~/# cat /sys/block/md0/md/r5c_state
this doesn't match the code, please update
> write-through [write-back]
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> ---
> drivers/md/raid5-cache.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
> drivers/md/raid5.c | 1 +
> drivers/md/raid5.h | 1 +
> 3 files changed, 62 insertions(+)
>
> diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
> index 8330053..d2acb69 100644
> --- a/drivers/md/raid5-cache.c
> +++ b/drivers/md/raid5-cache.c
> @@ -60,6 +60,8 @@ enum r5c_journal_mode {
> R5C_JOURNAL_MODE_WRITE_BACK = 1,
> };
>
> +static char *r5c_journal_mode_str[] = {"write-through",
> + "write-back"};
> /*
> * raid5 cache state machine
> *
> @@ -1602,6 +1604,64 @@ static void r5l_write_super(struct r5l_log *log, sector_t cp)
> set_bit(MD_CHANGE_DEVS, &mddev->flags);
> }
>
> +static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
> +{
> + struct r5conf *conf = mddev->private;
> + int ret;
> +
> + if (!conf->log)
> + return 0;
> +
> + switch (conf->log->r5c_journal_mode) {
> + case R5C_JOURNAL_MODE_WRITE_THROUGH:
> + ret = snprintf(page, PAGE_SIZE, "[%s] %s\n",
> + r5c_journal_mode_str[R5C_JOURNAL_MODE_WRITE_THROUGH],
> + r5c_journal_mode_str[R5C_JOURNAL_MODE_WRITE_BACK]);
Limiting these lines within 80 character width doesn't impact readability
> + break;
> + case R5C_JOURNAL_MODE_WRITE_BACK:
> + ret = snprintf(page, PAGE_SIZE, "%s [%s]\n",
> + r5c_journal_mode_str[R5C_JOURNAL_MODE_WRITE_THROUGH],
> + r5c_journal_mode_str[R5C_JOURNAL_MODE_WRITE_BACK]);
> + break;
> + default:
> + ret = 0;
> + }
> + return ret;
> +}
> +
> +static ssize_t r5c_journal_mode_store(struct mddev *mddev,
> + const char *page, size_t len)
> +{
> + struct r5conf *conf = mddev->private;
> + struct r5l_log *log = conf->log;
> + int val = -1, i;
> +
> + if (!log)
> + return -ENODEV;
> +
> + for (i = 0; i < sizeof(r5c_journal_mode_str) / sizeof(r5c_journal_mode_str[0]); i++)
use ARRAY_SIZE
Thanks,
Shaohua
next prev parent reply other threads:[~2016-11-15 23:35 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-10 20:46 [PATCH v6 00/11] raid5-cache: enabling cache features Song Liu
2016-11-10 20:46 ` [PATCH v6 01/11] md/r5cache: Check array size in r5l_init_log Song Liu
2016-11-10 20:46 ` [PATCH v6 02/11] md/r5cache: move some code to raid5.h Song Liu
2016-11-10 20:46 ` [PATCH v6 03/11] md/r5cache: State machine for raid5-cache write back mode Song Liu
2016-11-15 1:22 ` Shaohua Li
2016-11-15 1:36 ` Song Liu
2016-11-15 1:38 ` Shaohua Li
2016-11-16 0:17 ` NeilBrown
2016-11-16 5:18 ` Song Liu
2016-11-17 0:28 ` NeilBrown
2016-11-10 20:46 ` [PATCH v6 04/11] md/r5cache: caching mode of r5cache Song Liu
2016-11-15 17:03 ` Shaohua Li
2016-11-15 19:08 ` Song Liu
2016-11-15 21:49 ` Shaohua Li
2016-11-16 19:55 ` Song Liu
2016-11-17 17:25 ` Song Liu
2016-11-16 1:08 ` NeilBrown
2016-11-16 5:23 ` Song Liu
2016-11-10 20:46 ` [PATCH v6 05/11] md/r5cache: write-out mode and reclaim support Song Liu
2016-11-17 0:28 ` NeilBrown
2016-11-17 0:57 ` Song Liu
2016-11-10 20:46 ` [PATCH v6 06/11] md/r5cache: sysfs entry r5c_journal_mode Song Liu
2016-11-15 23:35 ` Shaohua Li [this message]
2016-11-17 0:29 ` NeilBrown
2016-11-10 20:46 ` [PATCH v6 07/11] md/r5cache: refactoring journal recovery code Song Liu
2016-11-10 20:46 ` [PATCH v6 08/11] md/r5cache: r5cache recovery: part 1 Song Liu
2016-11-16 0:33 ` Shaohua Li
2016-11-10 20:46 ` [PATCH v6 09/11] md/r5cache: r5cache recovery: part 2 Song Liu
2016-11-16 0:37 ` Shaohua Li
2016-11-10 20:46 ` [PATCH v6 10/11] md/r5cache: handle SYNC and FUA Song Liu
2016-11-10 20:46 ` [PATCH v6 11/11] md/r5cache: handle alloc_page failure Song Liu
2016-11-16 6:54 ` Shaohua Li
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=20161115233503.amnrvlwp6cy3nequ@kernel.org \
--to=shli@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=hch@infradead.org \
--cc=kernel-team@fb.com \
--cc=linux-raid@vger.kernel.org \
--cc=liuzhengyuan@kylinos.cn \
--cc=liuzhengyuang521@gmail.com \
--cc=neilb@suse.com \
--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 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).