lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20061219114251.GA25086@amitarora.in.ibm.com>
Date:	Tue, 19 Dec 2006 17:12:51 +0530
From:	"Amit K. Arora" <aarora@...ux.vnet.ibm.com>
To:	linux-ext4@...r.kernel.org
Cc:	suparna@...ibm.com, cmm@...ibm.com, suzuki@...ibm.com,
	alex@...sterfs.com
Subject: Re: [RFC][Patch 2/2] Persistent preallocation in ext4

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;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ