Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

erofs: get rid of erofs_prepare_dio() helper

Fold in erofs_prepare_dio() in order to simplify the code.

Reviewed-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220720082229.12172-1-hsiangkao@linux.alibaba.com

+16 -25
+16 -25
fs/erofs/data.c
··· 366 366 return iomap_bmap(mapping, block, &erofs_iomap_ops); 367 367 } 368 368 369 - static int erofs_prepare_dio(struct kiocb *iocb, struct iov_iter *to) 370 - { 371 - struct inode *inode = file_inode(iocb->ki_filp); 372 - loff_t align = iocb->ki_pos | iov_iter_count(to) | 373 - iov_iter_alignment(to); 374 - struct block_device *bdev = inode->i_sb->s_bdev; 375 - unsigned int blksize_mask; 376 - 377 - if (bdev) 378 - blksize_mask = (1 << ilog2(bdev_logical_block_size(bdev))) - 1; 379 - else 380 - blksize_mask = (1 << inode->i_blkbits) - 1; 381 - 382 - if (align & blksize_mask) 383 - return -EINVAL; 384 - return 0; 385 - } 386 - 387 369 static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) 388 370 { 371 + struct inode *inode = file_inode(iocb->ki_filp); 372 + 389 373 /* no need taking (shared) inode lock since it's a ro filesystem */ 390 374 if (!iov_iter_count(to)) 391 375 return 0; 392 376 393 377 #ifdef CONFIG_FS_DAX 394 - if (IS_DAX(iocb->ki_filp->f_mapping->host)) 378 + if (IS_DAX(inode)) 395 379 return dax_iomap_rw(iocb, to, &erofs_iomap_ops); 396 380 #endif 397 381 if (iocb->ki_flags & IOCB_DIRECT) { 398 - int err = erofs_prepare_dio(iocb, to); 382 + struct block_device *bdev = inode->i_sb->s_bdev; 383 + unsigned int blksize_mask; 399 384 400 - if (!err) 401 - return iomap_dio_rw(iocb, to, &erofs_iomap_ops, 402 - NULL, 0, NULL, 0); 403 - if (err < 0) 404 - return err; 385 + if (bdev) 386 + blksize_mask = bdev_logical_block_size(bdev) - 1; 387 + else 388 + blksize_mask = (1 << inode->i_blkbits) - 1; 389 + 390 + if ((iocb->ki_pos | iov_iter_count(to) | 391 + iov_iter_alignment(to)) & blksize_mask) 392 + return -EINVAL; 393 + 394 + return iomap_dio_rw(iocb, to, &erofs_iomap_ops, 395 + NULL, 0, NULL, 0); 405 396 } 406 397 return filemap_read(iocb, to, 0); 407 398 }