On Mon, Jul 26, 2021 at 2:51 PM Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx> wrote: > Hi Andreas, Christoph, > > On Mon, Jul 26, 2021 at 02:27:12PM +0200, Andreas Grünbacher wrote: > > Am Mo., 26. Juli 2021 um 14:17 Uhr schrieb Christoph Hellwig <hch@xxxxxx>: > > > > > > > Subject: iomap: Support tail packing > > > > > > I can't say I like this "tail packing" language here when we have the > > > perfectly fine inline wording. Same for various comments in the actual > > > code. > > > > > > > + /* inline and tail-packed data must start page aligned in the file */ > > > > + if (WARN_ON_ONCE(offset_in_page(iomap->offset))) > > > > + return -EIO; > > > > + if (WARN_ON_ONCE(size > PAGE_SIZE - offset_in_page(iomap->inline_data))) > > > > + return -EIO; > > > > > > Why can't we use iomap_inline_data_size_valid here? > > > > We can now. Gao, can you change that? > > Thank you all taking so much time on this! much appreciated. > > I'm fine to update that. > > > > > > That is how can size be different from iomap->length? > > > > Quoting from my previous reply, > > > > "In the iomap_readpage case (iomap_begin with flags == 0), > > iomap->length will be the amount of data up to the end of the inode. > > For tail-packing cases, iomap->length is just the length of tail-packing > inline extent. > > > In the iomap_file_buffered_write case (iomap_begin with flags == > > IOMAP_WRITE), iomap->length will be the size of iomap->inline_data. > > (For extending writes, we need to write beyond the current end of > > inode.) So iomap->length isn't all that useful for > > iomap_read_inline_data." > > Ok, now it seems I get your point. For the current gfs2 inline cases: > iomap_write_begin > iomap_write_begin_inline > iomap_read_inline_data > > here, gfs2 passes a buffer instead with "iomap->length", maybe it > could be larger than i_size_read(inode) for gfs2. Is that correct? > > loff_t max_size = gfs2_max_stuffed_size(ip); > > iomap->length = max_size; > > If that is what gfs2 currently does, I think it makes sense to > temporarily use as this, but IMO, iomap->inline_bufsize is not > iomap->length. These are 2 different concepts. > > > > > > Shouldn't the offset_in_page also go into iomap_inline_data_size_valid, > > > which should probably be called iomap_inline_data_valid then? > > > > Hmm, not sure what you mean: iomap_inline_data_size_valid does take > > offset_in_page(iomap->inline_data) into account. > > > > > > if (iomap->type == IOMAP_INLINE) { > > > > + int ret = iomap_read_inline_data(inode, page, iomap); > > > > + return ret ?: PAGE_SIZE; > > > > > The ?: expression without the first leg is really confuing. Especially > > > if a good old if is much more readable here. > > > > I'm sure Gao can change this. > > > > > int ret = iomap_read_inline_data(inode, page, iomap); > > > > > > if (ret) > > > return ret; > > > return PAGE_SIZE; > > I'm fine to update it if no strong opinion. > > > > > > > > + copied = copy_from_iter(iomap_inline_data(iomap, pos), length, iter); > > > > > > > > > > + copied = copy_to_iter(iomap_inline_data(iomap, pos), length, iter); > > > > > > Pleae avoid the overly long lines. > > > > I thought people were okay with 80 character long lines? > > Christoph mentioned before as below: > https://lore.kernel.org/linux-fsdevel/YPVe41YqpfGLNsBS@xxxxxxxxxxxxx/ > > We also need to take the offset into account for the write side. > I guess it would be nice to have a local variable for the inline > address to not duplicate that calculation multiple times. Fair enough, we could add a local variable: void *inline_data = iomap_inline_data(iomap, pos); and use that in the copy_from_iter and copy_to_iter. Why not. Thanks, Andreas