+ /* + * No buffer_head is allocated. + * (1) bmap: It's enough to fill bh_result without I/O. + * (2) read: The unwritten part should be filled with 0 + * If a folio does not have any buffers, + * let's returns -EAGAIN to fallback to + * per-bh IO like block_read_full_folio(). + */ + if (!folio_buffers(bh_result->b_folio)) { + err = -EAGAIN; + goto done; + } bh_result is set as mapped by map_bh(), should we need to clear it if return an error? + + BUG_ON(size > sb->s_blocksize); This check is equivalent to the following condition and is not necessary. } else if (iblock == valid_blks && (ei->valid_size & (sb->s_blocksize - 1))) {