From: Eryu Guan <eguan@redhat.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Josef Bacik <jbacik@fb.com>,
"Darrick J . Wong" <darrick.wong@oracle.com>,
Christoph Hellwig <hch@lst.de>,
fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2 12/14] replay-log: add support for replaying ops in target device sector range
Date: Tue, 5 Sep 2017 19:07:37 +0800 [thread overview]
Message-ID: <20170905110737.GD8034@eguan.usersys.redhat.com> (raw)
In-Reply-To: <1504104706-11965-13-git-send-email-amir73il@gmail.com>
On Wed, Aug 30, 2017 at 05:51:44PM +0300, Amir Goldstein wrote:
> Using command line options --start-sector and --end-sector, only
> operations acting on the specified target device range will be
> replayed.
>
> Single vebbose mode (-v) prints out only replayed operations.
> Double verbose mode (-vv) prints out also skipped operations.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> src/log-writes/log-writes.c | 33 +++++++++++++++++++++++++++++++--
> src/log-writes/log-writes.h | 2 ++
> src/log-writes/replay-log.c | 31 +++++++++++++++++++++++++++++++
> 3 files changed, 64 insertions(+), 2 deletions(-)
>
> diff --git a/src/log-writes/log-writes.c b/src/log-writes/log-writes.c
> index ba66a5c..d832c2a 100644
> --- a/src/log-writes/log-writes.c
> +++ b/src/log-writes/log-writes.c
> @@ -119,6 +119,24 @@ int log_discard(struct log *log, struct log_write_entry *entry)
>
> /*
> * @log: the log we are replaying.
> + * @entry: entry to be replayed.
> + *
> + * @return: 0 if we should replay the entry, > 0 if we should skip it.
> + *
> + * Should we skip the entry in our log or replay onto the replay device.
> + */
> +int log_should_skip(struct log *log, struct log_write_entry *entry)
> +{
> + if (!entry->nr_sectors)
> + return 0;
> + if (entry->sector + entry->nr_sectors < log->start_sector ||
> + entry->sector > log->end_sector)
Seems values from entry can't be used directly, need le64_to_cpu first I
think.
> + return 1;
> + return 0;
> +}
> +
> +/*
> + * @log: the log we are replaying.
> * @entry: where we put the entry.
> * @read_data: read the entry data as well, entry must be log->sectorsize sized
> * if this is set.
> @@ -137,6 +155,7 @@ int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
> char *buf;
> ssize_t ret;
> off_t offset;
> + u64 skip = 0;
int skip? and log_should_skip returns int too.
Thanks,
Eryu
>
> if (log->cur_entry >= log->nr_entries)
> return 1;
> @@ -158,9 +177,11 @@ int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
> }
> }
>
> - if (log_writes_verbose) {
> + skip = log_should_skip(log, entry);
> + if (log_writes_verbose > 1 || (log_writes_verbose && !skip)) {
> offset = lseek(log->logfd, 0, SEEK_CUR);
> - printf("replaying %d@%llu: sector %llu, size %llu, flags %llu\n",
> + printf("%s %d@%llu: sector %llu, size %llu, flags %llu\n",
> + skip ? "skipping" : "replaying",
> (int)log->cur_entry - 1, offset / log->sectorsize,
> (unsigned long long)le64_to_cpu(entry->sector),
> (unsigned long long)size,
> @@ -173,6 +194,14 @@ int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
> if (flags & LOG_DISCARD_FLAG)
> return log_discard(log, entry);
>
> + if (skip) {
> + if (lseek(log->logfd, size, SEEK_CUR) == (off_t)-1) {
> + fprintf(stderr, "Error seeking in log: %d\n", errno);
> + return -1;
> + }
> + return 0;
> + }
> +
> buf = malloc(size);
> if (!buf) {
> fprintf(stderr, "Error allocating buffer %llu entry %llu\n", (unsigned long long)size, (unsigned long long)log->cur_entry - 1);
> diff --git a/src/log-writes/log-writes.h b/src/log-writes/log-writes.h
> index 13f98ff..fc84acf 100644
> --- a/src/log-writes/log-writes.h
> +++ b/src/log-writes/log-writes.h
> @@ -53,6 +53,8 @@ struct log {
> int replayfd;
> unsigned long flags;
> u64 sectorsize;
> + u64 start_sector;
> + u64 end_sector;
> u64 nr_entries;
> u64 cur_entry;
> u64 max_zero_size;
> diff --git a/src/log-writes/replay-log.c b/src/log-writes/replay-log.c
> index 87c03a2..971974b 100644
> --- a/src/log-writes/replay-log.c
> +++ b/src/log-writes/replay-log.c
> @@ -20,6 +20,8 @@ enum option_indexes {
> FSCK,
> CHECK,
> START_MARK,
> + START_SECTOR,
> + END_SECTOR,
> };
>
> static struct option long_options[] = {
> @@ -37,6 +39,8 @@ static struct option long_options[] = {
> {"fsck", required_argument, NULL, 0},
> {"check", required_argument, NULL, 0},
> {"start-mark", required_argument, NULL, 0},
> + {"start-sector", required_argument, NULL, 0},
> + {"end-sector", required_argument, NULL, 0},
> { NULL, 0, NULL, 0 },
> };
>
> @@ -61,6 +65,12 @@ static void usage(void)
> "--check\n");
> fprintf(stderr, "\t--check [<number>|flush|fua] when to check the "
> "file system, mush specify --fsck\n");
> + fprintf(stderr, "\t--start-sector <sector> - replay ops on region "
> + "from <sector> onto <device>\n");
> + fprintf(stderr, "\t--end-sector <sector> - replay ops on region "
> + "to <sector> onto <device>\n");
> + fprintf(stderr, "\t-v or --verbose - print replayed ops\n");
> + fprintf(stderr, "\t-vv - print also skipped ops\n");
> exit(1);
> }
>
> @@ -120,6 +130,8 @@ int main(int argc, char **argv)
> struct log_write_entry *entry;
> u64 stop_flags = 0;
> u64 start_entry = 0;
> + u64 start_sector = 0;
> + u64 end_sector = -1ULL;
> u64 run_limit = 0;
> u64 num_entries = 0;
> u64 check_number = 0;
> @@ -240,6 +252,22 @@ int main(int argc, char **argv)
> tmp = NULL;
> }
> break;
> + case START_SECTOR:
> + start_sector = strtoull(optarg, &tmp, 0);
> + if (tmp && *tmp != '\0') {
> + fprintf(stderr, "Invalid sector number\n");
> + exit(1);
> + }
> + tmp = NULL;
> + break;
> + case END_SECTOR:
> + end_sector = strtoull(optarg, &tmp, 0);
> + if (tmp && *tmp != '\0') {
> + fprintf(stderr, "Invalid sector number\n");
> + exit(1);
> + }
> + tmp = NULL;
> + break;
> default:
> usage();
> }
> @@ -257,6 +285,9 @@ int main(int argc, char **argv)
> if (!discard)
> log->flags |= LOG_IGNORE_DISCARD;
>
> + log->start_sector = start_sector;
> + log->end_sector = end_sector;
> +
> entry = malloc(log->sectorsize);
> if (!entry) {
> fprintf(stderr, "Couldn't allocate buffer\n");
> --
> 2.7.4
>
next prev parent reply other threads:[~2017-09-05 11:07 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-30 14:51 [PATCH v2 00/14] Crash consistency xfstest using dm-log-writes Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 01/14] common/rc: convert some egrep to grep Amir Goldstein
2017-08-30 15:45 ` Darrick J. Wong
2017-08-30 14:51 ` [PATCH v2 02/14] common/rc: fix _require_xfs_io_command params check Amir Goldstein
2017-08-30 16:17 ` Darrick J. Wong
2017-08-30 14:51 ` [PATCH v2 03/14] fsx: fixes to random seed Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 04/14] fsx: fix path of .fsx* files Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 05/14] fsx: fix compile warnings Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 06/14] fsx: add support for integrity check with dm-log-writes target Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 07/14] fsx: add optional logid prefix to log messages Amir Goldstein
2017-09-05 10:46 ` Eryu Guan
2017-09-05 11:24 ` Amir Goldstein
2017-09-05 11:31 ` Eryu Guan
2017-09-07 7:10 ` Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 08/14] fsx: add support for --record-ops Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 09/14] fsx: add support for -g filldata Amir Goldstein
2017-09-05 10:50 ` Eryu Guan
2017-09-05 11:29 ` Amir Goldstein
2017-09-05 11:33 ` Eryu Guan
2017-08-30 14:51 ` [PATCH v2 10/14] log-writes: add replay-log program to replay dm-log-writes target Amir Goldstein
2017-09-05 11:03 ` Eryu Guan
2017-09-05 13:40 ` Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 11/14] replay-log: output log replay offset in verbose mode Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 12/14] replay-log: add support for replaying ops in target device sector range Amir Goldstein
2017-09-05 11:07 ` Eryu Guan [this message]
2017-09-05 11:41 ` Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 13/14] fstests: add support for working with dm-log-writes target Amir Goldstein
2017-09-05 11:22 ` Eryu Guan
2017-09-05 15:15 ` Amir Goldstein
2017-08-30 14:51 ` [PATCH v2 14/14] fstests: add crash consistency fsx test using dm-log-writes Amir Goldstein
2017-09-05 11:28 ` Eryu Guan
2017-09-05 11:52 ` Amir Goldstein
2017-08-30 15:04 ` [PATCH v2 00/14] Crash consistency xfstest " Amir Goldstein
2017-08-30 15:23 ` Josef Bacik
2017-08-30 18:39 ` Amir Goldstein
2017-08-30 18:55 ` Josef Bacik
2017-08-30 19:43 ` Amir Goldstein
2017-08-31 3:38 ` Eryu Guan
2017-09-01 7:29 ` Amir Goldstein
2017-09-01 7:45 ` Eryu Guan
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=20170905110737.GD8034@eguan.usersys.redhat.com \
--to=eguan@redhat.com \
--cc=amir73il@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=fstests@vger.kernel.org \
--cc=hch@lst.de \
--cc=jbacik@fb.com \
--cc=linux-xfs@vger.kernel.org \
/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).