On 2017年12月07日 15:32, Marat Khalili wrote: > On 07/12/17 08:27, Qu Wenruo wrote: >> When doing snapshot, btrfs only needs to increase reference of 2nd >> highest level tree blocks of original snapshot, other than "walking the >> tree". >> (If tree root level is 2, then level 2 node is copied, while all >> reference of level 1 tree blocks get increased) > > Out of curiosity, how does it interacts with nocow files? Does every > write to these files involves backref walk? For details I need to check the code. But at least, partial backref walk must be done. For "partial" I mean it doesn't need to get every root referring to the file extent, it only needs to check if the extent is only referred by current inode and offset. If any other inode (or even the same inode with different offset) is found, then the walk is finished. (The same walk we do to determine the FIEMAP_EXTENT_SHARED flag) In contract, for qgroup and balance, the full backref walk is done, where btrfs needs every root involved (for qgroup) or even every inode and offset involved (for balance). Thanks, Qu > > -- > > With Best Regards, > Marat Khalili