From mboxrd@z Thu Jan 1 00:00:00 1970 From: greg.freemyer@gmail.com (Greg Freemyer) Date: Thu, 5 Jan 2012 14:35:15 -0500 Subject: Snapshot in ext4 In-Reply-To: References: Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Wed, Jan 4, 2012 at 4:55 AM, Swapnil Gaikwad wrote: > If we store snapshot on other partition and assign new inode to each file's > snapshot. Then datablocks of that partition where we store snapshot is > wasted ? If not how? That's effectively what a device mapper snapshot does. Since only _changed_ blocks (inodes, pointer blocks, and data blocks) are maintained in the snapshot volume, the snapshot volume can be much smaller than the original volume. I haven't studied the code, but obviously they have something like: struct { boolean virgin; int alt_location; } map[max_blocks]; So a read from the snapshot is just: if (map[block].virgin) read(primary_volume, block) else read(snapshot_volume,map[block].alt_location) And write to the primary volume becomes if (map[block].virgin) { alt_loc=alloc_block_in_snapshot() map[block].alt_location = alt_loc map[block].virgin = false copy(block,alt_loc) } write(primary_volume, block) Then when your snapshot volume fills up, you have to discard it because it can't hold anymore changes. So if your snapshot volume is only 10% of the size of the primary volume, you can only support having 10% of the original volume written to. Greg