Messages in this thread | | | Date | Wed, 1 Dec 2021 20:15:59 -0800 | From | Eric Biggers <> | Subject | Re: [f2fs-dev] [PATCH 5/6] f2fs: implement iomap operations |
| |
On Thu, Dec 02, 2021 at 11:10:41AM +0800, Chao Yu wrote: > > +static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, > > + unsigned int flags, struct iomap *iomap, > > + struct iomap *srcmap) > > +{ > > + struct f2fs_map_blocks map = {}; > > + pgoff_t next_pgofs = 0; > > + int err; > > + > > + map.m_lblk = bytes_to_blks(inode, offset); > > + map.m_len = bytes_to_blks(inode, offset + length - 1) - map.m_lblk + 1; > > + map.m_next_pgofs = &next_pgofs; > > + map.m_seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint); > > + if (flags & IOMAP_WRITE) > > + map.m_may_create = true; > > + > > + err = f2fs_map_blocks(inode, &map, flags & IOMAP_WRITE, > > + F2FS_GET_BLOCK_DIO); > > + if (err) > > + return err; > > + > > + iomap->offset = blks_to_bytes(inode, map.m_lblk); > > + > > + if (map.m_flags & (F2FS_MAP_MAPPED | F2FS_MAP_UNWRITTEN)) { > > + iomap->length = blks_to_bytes(inode, map.m_len); > > + if (map.m_flags & F2FS_MAP_MAPPED) { > > + iomap->type = IOMAP_MAPPED; > > + iomap->flags |= IOMAP_F_MERGED; > > + } else { > > + iomap->type = IOMAP_UNWRITTEN; > > + } > > + if (WARN_ON_ONCE(!__is_valid_data_blkaddr(map.m_pblk))) > > + return -EINVAL; > > + iomap->addr = blks_to_bytes(inode, map.m_pblk); > > + > > + if (WARN_ON_ONCE(f2fs_is_multi_device(F2FS_I_SB(inode)))) > > + return -EINVAL; > > Why not relocating this check before f2fs_map_blocks()? > > Thanks, > > > + iomap->bdev = inode->i_sb->s_bdev;
Are you talking about the check for !f2fs_is_multi_device()? It could go in either location, but I think it makes the most sense to have it right before the line that uses 'inode->i_sb->s_bdev', since that is the place which makes the assumption that the filesystem has only one block device.
- Eric
| |