From: Artem Bityutskiy <dedekind1@gmail.com>
To: MTD list <linux-mtd@lists.infradead.org>
Cc: Adrian Hunter <adrian.hunter@nokia.com>
Subject: [PATCH 05/27] fs-tests: integck: shrink write_info even more
Date: Wed, 13 Apr 2011 18:18:45 +0300 [thread overview]
Message-ID: <1302707947-6143-6-git-send-email-dedekind1@gmail.com> (raw)
In-Reply-To: <1302707947-6143-1-git-send-email-dedekind1@gmail.com>
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
The 'struct write_info' data strucutre records information about
truncation, and has a separate integer field to specify if this is
a truncation or not. But it is too wasteful because we have huge
amount of these objects.
But it is easy to notice that the 'random_seed' field is not used
for truncation records, so we can use that as the truncation flag.
This patch introduces MAX_RANDOM_SEED macro and when the 'random_seed'
field is greater than that, we treat it as the truncation flag.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
tests/fs-tests/integrity/integck.c | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index eff7274..92e37a1 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -35,6 +35,8 @@
#define PROGRAM_NAME "integck"
#include "common.h"
+#define MAX_RANDOM_SEED 10000000
+
/* Structures to store data written to the test file system,
so that we can check whether the file system is correct. */
@@ -42,13 +44,14 @@ struct write_info /* Record of random data written into a file */
{
struct write_info *next;
off_t offset; /* Where in the file the data was written */
- size_t size; /* Number of bytes written */
- unsigned random_seed; /* Seed for rand() to create random data */
union {
off_t random_offset; /* Call rand() this number of times first */
off_t new_length; /* For truncation records new file length */
};
- int trunc; /* Records a truncation (raw_writes only) */
+ size_t size; /* Number of bytes written */
+ unsigned int random_seed; /* Seed for rand() to create random data. If
+ greater than MAX_RANDOM_SEED then this is
+ a truncation record (raw_writes only) */
};
struct dir_entry_info;
@@ -140,6 +143,14 @@ static long mem_page_size; /* Page size for mmap */
static unsigned int check_run_no;
/*
+ * Is this 'struct write_info' actually holds information about a truncation?
+ */
+static int is_truncation(struct write_info *w)
+{
+ return w->random_seed > MAX_RANDOM_SEED;
+}
+
+/*
* Allocate a buffer of 'size' bytes and fill it with zeroes.
*/
static void *zalloc(size_t size)
@@ -569,7 +580,7 @@ static void file_info_display(struct file_info *file)
wcnt = 0;
w = file->raw_writes;
while (w) {
- if (w->trunc)
+ if (is_truncation(w))
normsg(" Trunc from %u to %u",
(unsigned) w->offset, (unsigned) w->new_length);
else
@@ -834,7 +845,7 @@ static void file_mmap_write(struct file_info *file)
offset = w->offset + tests_random_no(w->size - size);
/* Write it */
- seed = tests_random_no(10000000);
+ seed = tests_random_no(MAX_RANDOM_SEED);
srand(seed);
waddr = addr + (offset - offs);
for (i = 0; i < size; i++)
@@ -860,7 +871,7 @@ static void file_write(struct file_info *file, int fd)
}
get_offset_and_size(file, &offset, &size);
- seed = tests_random_no(10000000);
+ seed = tests_random_no(MAX_RANDOM_SEED);
actual = file_write_data(file, fd, offset, size, seed);
if (offset + actual <= file->length && shrink)
@@ -924,7 +935,7 @@ static void file_truncate_info(struct file_info *file, size_t new_length)
w->next = file->raw_writes;
w->offset = file->length;
w->new_length = new_length;
- w->trunc = 1;
+ w->random_seed = MAX_RANDOM_SEED + 1;
file->raw_writes = w;
/* Update file length */
file->length = new_length;
--
1.7.2.3
next prev parent reply other threads:[~2011-04-13 15:15 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-13 15:18 [PATCH 00/27] mtd-utils: make integck test independent Artem Bityutskiy
2011-04-13 15:16 ` Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 01/27] fs-tests: integck: shrink dir_entry_info structure size Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 02/27] fs-tests: integck: shrink file_info " Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 03/27] fs-tests: integck: srink file_info structure even more Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 04/27] fs-tests: integck: abuse random_offset field nicer Artem Bityutskiy
2011-04-13 15:18 ` Artem Bityutskiy [this message]
2011-04-13 15:18 ` [PATCH 06/27] fs-tests: integck: change tests defaults Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 07/27] fs-tests: integck: implement own parameters parsing Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 08/27] fs-tests: integck: clean-up copy_string Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 09/27] fs-tests: integck: get rid of tests_check_test_file_system Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 10/27] fs-tests: integck: make integck function return error Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 11/27] fs-tests: integck: move mem_page_size to fsinfo Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 12/27] fs-tests: integck: move more variables " Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 13/27] fs-tests: integck: add own get_free_space function Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 14/27] fs-tests: integck: move log10_initial_free to fsinfo Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 15/27] fs-tests: integck: remove trailing backslashes from mount point Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 16/27] fs-tests: integck: do not use tests_cat_pid Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 17/27] fs-tests: integck: clean up test directory creation Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 18/27] fs-tests: integck: do not use tests_clear_dir Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 19/27] fs-tests: integck: do not use space after cast Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 20/27] fs-tests: integck: prefer to check for success Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 21/27] fs-tests: integck: do not use tests_fs_is_rootfs Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 22/27] fs-tests: integck: do not use tests_remount Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 23/27] fs-tests: integck: do not use tests_get_total_space Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 24/27] fs-tests: integck: do not use global common variables Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 25/27] fs-tests: integck: do not use tests_random_no Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 26/27] fs-tests: integck: implement own version of CHECK Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 27/27] fs-tests: integck: do not expect max name length to be 256 Artem Bityutskiy
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=1302707947-6143-6-git-send-email-dedekind1@gmail.com \
--to=dedekind1@gmail.com \
--cc=adrian.hunter@nokia.com \
--cc=linux-mtd@lists.infradead.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 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.