On Tue, 2007-10-16 at 22:36 +0800, Yan Zheng wrote: > 2007/10/16, Chris Mason <[EMAIL PROTECTED]>: > > On Tue, 2007-10-16 at 20:32 +0800, Yan Zheng wrote: > > > Hello > > > > > > Some xxx_extent_buffer functions have codes like: > > > -- > > > offset = dst_offset & ((unsigned long)PAGE_CACHE_SIZE - 1); > > > if (i == 0) > > > offset += start_offset; > > > > > > I can't understand why these is a test. I feel the variable 'offset' > > > should be computed by code like: > > > -- > > > offset = (dst_offset + start_offset) & ((unsigned > > > long)PAGE_CACHE_SIZE - 1); > > It could be offset = (dst->start + dst_offset) & PAGE_CACHE_SIZE - 1, > > but start_offset is already the offset into the first page. So, we only > > want to add it on the first page. > > -chris > > > I'm sorry , I'm still confused by these codes. For example, when page > size is 4k, the start_offset of a extent buffer is 2048 and we want > to access the 4096th byte in the extent buffer(parameter start is > 4096). the data should be in the second page in the extent buffer and > offset from the start of the second page should be 2048. But if > compute variable 'offset' by codes: > --- codes from read_extent_buffer --- > offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1); > if (i == 0) > offset += start_offset; > > offset is 0. Please tell me where my mistake is, Thanks.
Sorry, I wasn't clear. I'll change it to (dst->start + dst_offset) & (PAGE_CACHE_SIZE - 1), which will be correct. It didn't show up in testing because the current code always uses blocksizes in multiples of the page size. -chris _______________________________________________ Btrfs-devel mailing list [email protected] http://oss.oracle.com/mailman/listinfo/btrfs-devel
