From: "Amit K. Arora" <aarora@linux.vnet.ibm.com>
To: linux-ext4@vger.kernel.org
Cc: suparna@in.ibm.com, cmm@us.ibm.com, suzuki@in.ibm.com,
alex@clusterfs.com
Subject: Re: [RFC][Patch 2/2] Persistent preallocation in ext4
Date: Tue, 19 Dec 2006 17:12:51 +0530 [thread overview]
Message-ID: <20061219114251.GA25086@amitarora.in.ibm.com> (raw)
In-Reply-To: <20061215123920.GB24572@amitarora.in.ibm.com>
I wrote a simple tool to test these patches. The tool takes four
arguments:
* command: It may have either of the two values - "prealloc" or "write"
* filename: This is the filename with relative path
* offset: The offset within the file from where the preallocation, or
the write should start.
* length: Total number of bytes to be allocated/written from offset.
Following cases were tested :
1. * preallocation from 0 to 32MB
* write to various parts of the preallocated space in sets
* observed that the extents get split and also get merged
2. * preallocate with holes at various places in the file
* write to blocks starting from a hole and ending into preallocated
blocks and vice-versa
* try to write to entire set of blocks (i.e. from 0 to the last
preallocated block) which has holes in between.
I also tried some random preallocation and write operations. They seem
to work fine. There is a patch also ready for e2fsprogs utils to
recognize uninitialized extents, which I used to verify the results of
the above testcases. I will post that patch in the next mail.
Here is the code for the simple tool :
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<errno.h>
#define EXT4_IOC_FALLOCATE 0x40106609
struct ext4_falloc_input {
unsigned long long offset;
unsigned long long len;
};
int do_prealloc(char* fname, struct ext4_falloc_input input)
{
int ret, fd = open(fname, O_CREAT|O_RDWR, 0666);
if(fd<0) {
printf("Error opening file %s\n", fname);
return 1;
}
printf("%s : Trying to preallocate blocks (offset=%llu, len=%llu)\n",
fname, input.offset, input.len);
ret = ioctl(fd, EXT4_IOC_FALLOCATE, &input);
if(ret <0) {
printf("IOCTL: received error %d, ret=%d\n", errno, ret);
close(fd);
exit(1);
}
printf("IOCTL succedded ! ret=%d\n", ret);
close(fd);
}
int do_write(char* fname, struct ext4_falloc_input input)
{
int ret, fd;
char *buf;
buf = (char *)malloc(input.len);
fd = open(fname, O_CREAT|O_RDWR, 0666);
if(fd<0) {
printf("Error opening file %s\n", fname);
return 1;
}
printf("%s : Trying to write to file (offset=%llu, len=%llu)\n",
fname, input.offset, input.len);
ret = lseek(fd, input.offset, SEEK_SET);
if(ret != input.offset) {
printf("lseek() failed error=%d, ret=%d\n", errno, ret);
close(fd);
return(1);
}
ret = write(fd, buf, input.len);
if(ret != input.len) {
printf("write() failed error=%d, ret=%d\n", errno, ret);
close(fd);
return(1);
}
printf("Write succedded ! Written %llu bytes ret=%d\n", input.len, ret);
close(fd);
}
int main(int argc, char **argv)
{
struct ext4_falloc_input input;
int ret = 1, fd;
char *fname;
if(argc<5) {
printf("%s <CMD: prealloc/write> <filename-with-path> <offset> <length>\n", argv[0]);
exit(1);
}
fname = argv[2];
input.offset=(unsigned long long)atol(argv[3]);;
input.len=(unsigned long long)atol(argv[4]);
if(input.offset<0 || input.len<= 0) {
printf("%s: Invalid arguments.\n", argv[0]);
exit(1);
}
if(!strcmp(argv[1], "prealloc"))
ret = do_prealloc(fname, input);
else if(!strcmp(argv[1], "write"))
ret = do_write(fname, input);
else
printf("%s: Invalid arguments.\n", argv[0]);
return ret;
}
next prev parent reply other threads:[~2006-12-19 11:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-05 13:43 [RFC][Patch 1/1] Persistent preallocation in ext4 Amit K. Arora
2006-12-06 5:58 ` Amit K. Arora
2006-12-12 1:28 ` Mingming Cao
2006-12-12 6:23 ` Amit K. Arora
2006-12-13 0:20 ` Mingming Cao
2006-12-13 10:01 ` Amit K. Arora
2006-12-13 13:36 ` Dave Kleikamp
2006-12-13 15:38 ` Suparna Bhattacharya
2006-12-13 15:54 ` Mingming Cao
2006-12-15 12:35 ` [RFC][Patch 1/2] " Amit K. Arora
2006-12-19 11:05 ` Amit K. Arora
[not found] ` <20061219211206.GO5937@schatzie.adilger.int>
2006-12-20 6:28 ` Amit K. Arora
2006-12-27 23:30 ` Mingming Cao
2007-01-02 11:04 ` Amit K. Arora
2007-01-02 22:47 ` Mingming Cao
2007-01-09 9:05 ` Amit K. Arora
2006-12-15 12:39 ` [RFC][Patch 2/2] " Amit K. Arora
2006-12-15 23:02 ` Andreas Dilger
2006-12-16 4:30 ` Amit K. Arora
2006-12-19 11:42 ` Amit K. Arora [this message]
2006-12-19 11:54 ` Amit K. Arora
2006-12-19 21:14 ` Andreas Dilger
2006-12-19 21:23 ` Eric Sandeen
2006-12-20 8:19 ` Amit K. Arora
2006-12-22 15:16 ` Amit K. Arora
2006-12-22 15:31 ` Alex Tomas
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=20061219114251.GA25086@amitarora.in.ibm.com \
--to=aarora@linux.vnet.ibm.com \
--cc=alex@clusterfs.com \
--cc=cmm@us.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=suparna@in.ibm.com \
--cc=suzuki@in.ibm.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).