Messages in this thread | | | From | Andi Kleen <> | Subject | Re: Patch to loop device (loop.c) | Date | Fri, 4 Dec 1998 16:25:21 +0100 |
| |
In muc.lists.linux-kernel, you wrote: >On Thu, Dec 03, 1998 at 05:24:12PM +0100, Andi Kleen wrote: > >> >First of all, I found out that the "create_missing_block" function >> >doesn't seem to work, at least it didn't work on my system. >> >(If you tried to create a file system with 1024 blocks (1meg) on >> > a file which was only 1 Byte long it didn't work...) >> >> That is because it is not supposed to extend the file length, but >> to fill in holes in the file (unallocated blocks in the middle of a >> file) >> >> I don't think the loop device should try to extend the file, a block >> device with varying length does not look like a good idea for me. > >Ahh, so I misunderstood the comment, because I didn't know that >this would be possible (that a backing file containged blocks >which are not mapped to the block device). Just out of interest, >how can such a situation happen ? > >(Do you open a file and then write to position 100000 for example? )
Yes.
fd = creat(file, mode); lseek(fd, 100000, SEEK_SET); write(fd, "x", 1); close(fd);
now you have a file with a hole. For some databases that use the file offset as hash key it is very useful. When the kernel sees a hole it simply returns zeros.
-Andi
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |