Messages in this thread | | | From | "Hua Zhong" <> | Subject | RE: Is there a "make hole" (truncate in middle) syscall? | Date | Thu, 11 Dec 2003 11:15:28 -0800 |
| |
> The abstract interface for make_hole() is simple, but it turns into a > pretty expensive filesystem operation, I think. After many cycles of > free/allocate, your file would be badly fragmented across the > filesystem.
Understood. Two filesystems we are using: tmpfs and ext3. For the former, fragmentation doesn't matter.
Hey, I think when I get some cycles I can try to implement this for tmpfs (since it's simpler) myself, and post a patch. :-) But before that, I want to make sure it's doable.
> You'll probably get better overall performance by keeping > track of how "sparse" your file is (you could compare st_blocks versus > how many blocks you have allocated in your tree structure) > and re-write > it when you're wasting more than, say, 20% of the allocated space. > > It turns into an interesting problem if you don't want to double your > space requirements during the re-write process. You could write the > new file "backwards", one MB at a time, truncating the > previous file at > each step to free up the blocks. You'd end up with contiguous 1MB > chunks, which given your tree organization is probably good > enough. If > you wanted really good streaming performance you'd want to do bigger > chunks (or just write the file from the beginning, or use the > pre-allocation APIs that I think XFS provides). > > -andy >
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |