On Fri, May 24, 2019 at 09:17:26AM +1000, Dave Chinner wrote: > > +/* > > + * Bump the cycle numbers at the start of each block in the part of the iclog > > + * that ends up in the buffer that gets written to the start of the log. > > + * > > + * Watch out for the header magic number case, though. > > Can we update this comment to be easier to parse? > > /* > * We need to bump cycle number for the part of the iclog that is > * written to the start of the log. Watch out for the header magic > * number case, though. > */ Sure. > > + for (i = split_offset; i < count; i += BBSIZE) { > > + uint32_t cycle = get_unaligned_be32(data + i); > > + > > + if (++cycle == XLOG_HEADER_MAGIC_NUM) > > + cycle++; > > + put_unaligned_be32(cycle, data + i); > > Is the location we read from/write to ever unaligned? The cycle > should always be 512 byte aligned to the start of the iclog data > buffer, which should always be at least 4 byte aligned in memory... I don't think it is unaligned, but the get_unaligned_* and put_unaligned_* helpers are just really nice ways to read big/little endian fields from arbitrary char pointers, which is what we do here.