On 10/11/15 11:37 PM, Wang, Zhiye wrote: > Hello everyone, > > After googled a bit, I got information that btrfs supports FIEMAP (as "cp" > needs it), but it's not valid for "write" operation.
cp should not be using fiemap any more. It was for a while, until they realized that copying based on fiemap output could lead to corruption because things changed between the fiemap call and the actual copy... > I guess we cannot write to block device directly after get block list using > FIEMAP. This is because: > > 1. COW feature of btrfs (but this can be disabled using NOCOW) > 2. File system rebalance > 3. Defragmentation > > Aren't item #2 and #3 also a problem for "read" operation? For example, after > "cp" get block list using FIEMAP, file system rebalance occurs, So, previous > result of FIEMAP is not valid anymore. > > Or maybe I misunderstood something. Please correct me. That all may be true for btrfs, but more fundamentally as dsterba said, nothing guarantees that the layout won't change *immediately* after your fiemap call. This is the case on any filesystem, not just btrfs. -Eric -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html