在 2011-4-18,下午6:03, Joerg Schilling 写道:

> "jeff.liu" <jeff....@oracle.com> wrote:
> 
>> Hello List,
>> 
>> I am trying to fetch the data/hole info of a sparse file through the 
>> lseek(SEEK_HOLE/SEEK_DATA)
>> stuff, the result of fpathconf(..., _PC_MIN_HOLE_SIZE) is ok, so I think 
>> this interface is supported
>> on my testing ZFS, but SEEK_HOLE always return the sparse file total size 
>> instead of the desired
>> first hole start offset.
> 
> Maybe you did not create the file correctly.
> 
> If you like to create a file of a specific size that only contains one single 
> hole, there is a way to do this using star:
> 
> mkfile <size> some-file                       # create a file of the desired 
> size
> star -c f=xx.tar -meta some-file      # archive the meta data only
> rm some-file                          # remove original file
> star -x -xmeta -force-hole f=xx.tar   # let star create an empty file of the 
>                                       # same size
> 
> This will try to create a file that has one hole but no data in case the 
> filesystem supports to do this.
> 
> For UFS, such a file e.g. needs to be a multiple of 8k in size. This is 
> because 
> holes in UFS need to be aligned at 8k boundaries and need to be a multiple of 
> 8k in size.
> 
> 
> A recent star can be found in the schily source consolidation:
> 
> ftp://ftp.berlios.de/pub/schily/
> 
> 
> star is part of Schillix-ON (a free OpenSolaris fork).

Thanks for your info!
Actually, I'd like to create a sparse file with both data and holes to test a 
patch I am working on, it was wrote for Coreutils to optimize sparse file 
reading, especially for cp(1).

I had took a look at the source code of Star before, and I was wondering of  
comments at start/hole.c: sparse_file(fp, info) at that time,
line: 1240        if (pos >= info->f_size) {              /* Definitely not 
sparse */ 

Now, I am still not sure why the returned 'pos' could  larger than 
'info->f_size' in some cases, I guess it should be equal to the f_size if the 
target file is not sparse, Am I missing something here?

For the sparse file I created via python -c "f=open('sparse', 'w'); 
f.seek(40960); f.write('BYE'); f.close()",  IMHO,  it is a right way to create 
a sparse file conventionally, but it is too small to spanning across
multiple blocks, so ZFS allocate it as an non-sparse single block file just as 
Victor's response. 


Regards,
-Jeff


> 
> Jörg
> 
> -- 
> EMail:jo...@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
>       j...@cs.tu-berlin.de                (uni)  
>       joerg.schill...@fokus.fraunhofer.de (work) Blog: 
> http://schily.blogspot.com/
> URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily



_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to