lkml.org 
[lkml]   [2021]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2021-12-02 05:17    [W:0.099 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site