From patchwork Wed Apr 20 10:18:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 92169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D25B5B6F7A for ; Wed, 20 Apr 2011 20:22:05 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1QCUTc-0007WE-3H; Wed, 20 Apr 2011 10:17:40 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1QCUTa-0006H3-E3; Wed, 20 Apr 2011 10:17:38 +0000 Received: from smtp.nokia.com ([147.243.1.47] helo=mgw-sa01.nokia.com) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1QCURt-00065o-Qy for linux-mtd@lists.infradead.org; Wed, 20 Apr 2011 10:16:03 +0000 Received: from nokia.com (localhost [127.0.0.1]) by mgw-sa01.nokia.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id p3KAFnal009530 for ; Wed, 20 Apr 2011 13:15:52 +0300 Received: from eru.research.nokia.com ([[172.21.24.121]]) by mgw-sa01.nokia.com with ESMTP id p3KAFTS5009198 ; Wed, 20 Apr 2011 13:15:35 +0300 From: Artem Bityutskiy To: MTD list Subject: [PATCH 12/35] fs-tests: integck: rename BUFFER_SIZE Date: Wed, 20 Apr 2011 13:18:45 +0300 Message-Id: <1303294748-5492-13-git-send-email-dedekind1@gmail.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1303294748-5492-1-git-send-email-dedekind1@gmail.com> References: <1303294748-5492-1-git-send-email-dedekind1@gmail.com> X-Nokia-AV: Clean X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110420_061554_529964_B9A88189 X-CRM114-Status: GOOD ( 12.17 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [147.243.1.47 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (dedekind1[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 2.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: Adrian Hunter X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Artem Bityutskiy Rename 'BUFFER_SIZE' constant into 'IO_BUFFER_SIZE' to reflect what is the buffer this constant is about. Signed-off-by: Artem Bityutskiy --- tests/fs-tests/integrity/integck.c | 59 +++++++++++++++++------------------ 1 files changed, 29 insertions(+), 30 deletions(-) diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 67085ec..9eddc0b 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -46,6 +46,9 @@ /* The pattern for the top directory where we run the test */ #define TEST_DIR_PATTERN "integck_test_dir_%u" +/* Maximum buffer size for a single read/write operation */ +#define IO_BUFFER_SIZE 32768 + /* * Check if a condition is true and die if not. */ @@ -727,8 +730,6 @@ static struct fd_info *file_open(struct file_info *file) return add_fd(file, fd); } -#define BUFFER_SIZE 32768 - /* * Write random 'size' bytes of random data to offset 'offset'. Seed the random * gererator with 'seed'. Return amount of written data on success and -1 on @@ -739,25 +740,25 @@ static ssize_t file_write_data(struct file_info *file, int fd, { size_t remains, actual, block; ssize_t written; - char buf[BUFFER_SIZE]; + char buf[IO_BUFFER_SIZE]; srand(seed); CHECK(lseek(fd, offset, SEEK_SET) != (off_t)-1); remains = size; actual = 0; - written = BUFFER_SIZE; + written = IO_BUFFER_SIZE; while (remains) { /* Fill up buffer with random data */ - if (written < BUFFER_SIZE) { - memmove(buf, buf + written, BUFFER_SIZE - written); - written = BUFFER_SIZE - written; + if (written < IO_BUFFER_SIZE) { + memmove(buf, buf + written, IO_BUFFER_SIZE - written); + written = IO_BUFFER_SIZE - written; } else written = 0; - for (; written < BUFFER_SIZE; ++written) + for (; written < IO_BUFFER_SIZE; ++written) buf[written] = rand(); /* Write a block of data */ - if (remains > BUFFER_SIZE) - block = BUFFER_SIZE; + if (remains > IO_BUFFER_SIZE) + block = IO_BUFFER_SIZE; else block = remains; written = write(fd, buf, block); @@ -1180,18 +1181,18 @@ static void file_rewrite_data(int fd, struct write_info *w, char *buf) rand(); CHECK(lseek(fd, w->offset, SEEK_SET) != (off_t)-1); remains = w->size; - written = BUFFER_SIZE; + written = IO_BUFFER_SIZE; while (remains) { /* Fill up buffer with random data */ - if (written < BUFFER_SIZE) - memmove(buf, buf + written, BUFFER_SIZE - written); + if (written < IO_BUFFER_SIZE) + memmove(buf, buf + written, IO_BUFFER_SIZE - written); else written = 0; - for (; written < BUFFER_SIZE; ++written) + for (; written < IO_BUFFER_SIZE; ++written) buf[written] = rand(); /* Write a block of data */ - if (remains > BUFFER_SIZE) - block = BUFFER_SIZE; + if (remains > IO_BUFFER_SIZE) + block = IO_BUFFER_SIZE; else block = remains; written = write(fd, buf, block); @@ -1204,7 +1205,7 @@ static void save_file(int fd, struct file_info *file) { int w_fd; struct write_info *w; - char buf[BUFFER_SIZE]; + char buf[IO_BUFFER_SIZE]; char name[256]; /* Open file to save contents to */ @@ -1219,7 +1220,7 @@ static void save_file(int fd, struct file_info *file) CHECK(lseek(fd, 0, SEEK_SET) != (off_t)-1); for (;;) { - ssize_t r = read(fd, buf, BUFFER_SIZE); + ssize_t r = read(fd, buf, IO_BUFFER_SIZE); CHECK(r != -1); if (!r) break; @@ -1241,18 +1242,17 @@ static void save_file(int fd, struct file_info *file) CHECK(close(w_fd) == 0); } -static void file_check_hole( struct file_info *file, - int fd, off_t offset, - size_t size) +static void file_check_hole(struct file_info *file, int fd, off_t offset, + size_t size) { size_t remains, block, i; - char buf[BUFFER_SIZE]; + char buf[IO_BUFFER_SIZE]; CHECK(lseek(fd, offset, SEEK_SET) != (off_t)-1); remains = size; while (remains) { - if (remains > BUFFER_SIZE) - block = BUFFER_SIZE; + if (remains > IO_BUFFER_SIZE) + block = IO_BUFFER_SIZE; else block = remains; CHECK(read(fd, buf, block) == block); @@ -1271,13 +1271,12 @@ static void file_check_hole( struct file_info *file, } } -static void file_check_data( struct file_info *file, - int fd, - struct write_info *w) +static void file_check_data(struct file_info *file, int fd, + struct write_info *w) { size_t remains, block, i; off_t r; - char buf[BUFFER_SIZE]; + char buf[IO_BUFFER_SIZE]; srand(w->random_seed); for (r = 0; r < w->random_offset; ++r) @@ -1285,8 +1284,8 @@ static void file_check_data( struct file_info *file, CHECK(lseek(fd, w->offset, SEEK_SET) != (off_t)-1); remains = w->size; while (remains) { - if (remains > BUFFER_SIZE) - block = BUFFER_SIZE; + if (remains > IO_BUFFER_SIZE) + block = IO_BUFFER_SIZE; else block = remains; CHECK(read(fd, buf, block) == block);