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

xfs: add a xfs_inode_buftarg helper

Add a new xfs_inode_buftarg helper that gets the data I/O buftarg for a
given inode. Replace the existing xfs_find_bdev_for_inode and
xfs_find_daxdev_for_inode helpers with this new general one and cleanup
some of the callers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

authored by

Christoph Hellwig and committed by
Darrick J. Wong
30fa529e 25a40957

+38 -55
+5 -29
fs/xfs/xfs_aops.c
··· 30 30 return container_of(ctx, struct xfs_writepage_ctx, ctx); 31 31 } 32 32 33 - struct block_device * 34 - xfs_find_bdev_for_inode( 35 - struct inode *inode) 36 - { 37 - struct xfs_inode *ip = XFS_I(inode); 38 - struct xfs_mount *mp = ip->i_mount; 39 - 40 - if (XFS_IS_REALTIME_INODE(ip)) 41 - return mp->m_rtdev_targp->bt_bdev; 42 - else 43 - return mp->m_ddev_targp->bt_bdev; 44 - } 45 - 46 - struct dax_device * 47 - xfs_find_daxdev_for_inode( 48 - struct inode *inode) 49 - { 50 - struct xfs_inode *ip = XFS_I(inode); 51 - struct xfs_mount *mp = ip->i_mount; 52 - 53 - if (XFS_IS_REALTIME_INODE(ip)) 54 - return mp->m_rtdev_targp->bt_daxdev; 55 - else 56 - return mp->m_ddev_targp->bt_daxdev; 57 - } 58 - 59 33 /* 60 34 * Fast and loose check if this write could update the on-disk inode size. 61 35 */ ··· 583 609 struct address_space *mapping, 584 610 struct writeback_control *wbc) 585 611 { 586 - xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); 612 + struct xfs_inode *ip = XFS_I(mapping->host); 613 + 614 + xfs_iflags_clear(ip, XFS_ITRUNCATED); 587 615 return dax_writeback_mapping_range(mapping, 588 - xfs_find_bdev_for_inode(mapping->host), wbc); 616 + xfs_inode_buftarg(ip)->bt_bdev, wbc); 589 617 } 590 618 591 619 STATIC sector_t ··· 637 661 struct file *swap_file, 638 662 sector_t *span) 639 663 { 640 - sis->bdev = xfs_find_bdev_for_inode(file_inode(swap_file)); 664 + sis->bdev = xfs_inode_buftarg(XFS_I(file_inode(swap_file)))->bt_bdev; 641 665 return iomap_swapfile_activate(sis, swap_file, span, 642 666 &xfs_read_iomap_ops); 643 667 }
-3
fs/xfs/xfs_aops.h
··· 11 11 12 12 int xfs_setfilesize(struct xfs_inode *ip, xfs_off_t offset, size_t size); 13 13 14 - extern struct block_device *xfs_find_bdev_for_inode(struct inode *); 15 - extern struct dax_device *xfs_find_daxdev_for_inode(struct inode *); 16 - 17 14 #endif /* __XFS_AOPS_H__ */
+8 -7
fs/xfs/xfs_bmap_util.c
··· 53 53 */ 54 54 int 55 55 xfs_zero_extent( 56 - struct xfs_inode *ip, 57 - xfs_fsblock_t start_fsb, 58 - xfs_off_t count_fsb) 56 + struct xfs_inode *ip, 57 + xfs_fsblock_t start_fsb, 58 + xfs_off_t count_fsb) 59 59 { 60 - struct xfs_mount *mp = ip->i_mount; 61 - xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb); 62 - sector_t block = XFS_BB_TO_FSBT(mp, sector); 60 + struct xfs_mount *mp = ip->i_mount; 61 + struct xfs_buftarg *target = xfs_inode_buftarg(ip); 62 + xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb); 63 + sector_t block = XFS_BB_TO_FSBT(mp, sector); 63 64 64 - return blkdev_issue_zeroout(xfs_find_bdev_for_inode(VFS_I(ip)), 65 + return blkdev_issue_zeroout(target->bt_bdev, 65 66 block << (mp->m_super->s_blocksize_bits - 9), 66 67 count_fsb << (mp->m_super->s_blocksize_bits - 9), 67 68 GFP_NOFS, 0);
+7 -7
fs/xfs/xfs_file.c
··· 1229 1229 1230 1230 STATIC int 1231 1231 xfs_file_mmap( 1232 - struct file *filp, 1233 - struct vm_area_struct *vma) 1232 + struct file *file, 1233 + struct vm_area_struct *vma) 1234 1234 { 1235 - struct dax_device *dax_dev; 1235 + struct inode *inode = file_inode(file); 1236 + struct xfs_buftarg *target = xfs_inode_buftarg(XFS_I(inode)); 1236 1237 1237 - dax_dev = xfs_find_daxdev_for_inode(file_inode(filp)); 1238 1238 /* 1239 1239 * We don't support synchronous mappings for non-DAX files and 1240 1240 * for DAX files if underneath dax_device is not synchronous. 1241 1241 */ 1242 - if (!daxdev_mapping_supported(vma, dax_dev)) 1242 + if (!daxdev_mapping_supported(vma, target->bt_daxdev)) 1243 1243 return -EOPNOTSUPP; 1244 1244 1245 - file_accessed(filp); 1245 + file_accessed(file); 1246 1246 vma->vm_ops = &xfs_file_vm_ops; 1247 - if (IS_DAX(file_inode(filp))) 1247 + if (IS_DAX(inode)) 1248 1248 vma->vm_flags |= VM_HUGEPAGE; 1249 1249 return 0; 1250 1250 }
+7
fs/xfs/xfs_inode.h
··· 220 220 } 221 221 222 222 /* 223 + * Return the buftarg used for data allocations on a given inode. 224 + */ 225 + #define xfs_inode_buftarg(ip) \ 226 + (XFS_IS_REALTIME_INODE(ip) ? \ 227 + (ip)->i_mount->m_rtdev_targp : (ip)->i_mount->m_ddev_targp) 228 + 229 + /* 223 230 * In-core inode flags. 224 231 */ 225 232 #define XFS_IRECLAIM (1 << 0) /* started reclaiming this inode */
+3 -4
fs/xfs/xfs_ioctl.c
··· 1311 1311 * have to check the device for dax support or flush pagecache. 1312 1312 */ 1313 1313 if (fa->fsx_xflags & FS_XFLAG_DAX) { 1314 - if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) 1315 - return -EINVAL; 1316 - if (!bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)), 1317 - sb->s_blocksize)) 1314 + struct xfs_buftarg *target = xfs_inode_buftarg(ip); 1315 + 1316 + if (!bdev_dax_supported(target->bt_bdev, sb->s_blocksize)) 1318 1317 return -EINVAL; 1319 1318 } 1320 1319
+7 -4
fs/xfs/xfs_iomap.c
··· 57 57 u16 flags) 58 58 { 59 59 struct xfs_mount *mp = ip->i_mount; 60 + struct xfs_buftarg *target = xfs_inode_buftarg(ip); 60 61 61 62 if (unlikely(!xfs_valid_startblock(ip, imap->br_startblock))) 62 63 return xfs_alert_fsblock_zero(ip, imap); ··· 78 77 } 79 78 iomap->offset = XFS_FSB_TO_B(mp, imap->br_startoff); 80 79 iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount); 81 - iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip)); 82 - iomap->dax_dev = xfs_find_daxdev_for_inode(VFS_I(ip)); 80 + iomap->bdev = target->bt_bdev; 81 + iomap->dax_dev = target->bt_daxdev; 83 82 iomap->flags = flags; 84 83 85 84 if (xfs_ipincount(ip) && ··· 95 94 xfs_fileoff_t offset_fsb, 96 95 xfs_fileoff_t end_fsb) 97 96 { 97 + struct xfs_buftarg *target = xfs_inode_buftarg(ip); 98 + 98 99 iomap->addr = IOMAP_NULL_ADDR; 99 100 iomap->type = IOMAP_HOLE; 100 101 iomap->offset = XFS_FSB_TO_B(ip->i_mount, offset_fsb); 101 102 iomap->length = XFS_FSB_TO_B(ip->i_mount, end_fsb - offset_fsb); 102 - iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip)); 103 - iomap->dax_dev = xfs_find_daxdev_for_inode(VFS_I(ip)); 103 + iomap->bdev = target->bt_bdev; 104 + iomap->dax_dev = target->bt_daxdev; 104 105 } 105 106 106 107 static inline xfs_fileoff_t
+1 -1
fs/xfs/xfs_iops.c
··· 1227 1227 return false; 1228 1228 1229 1229 /* Device has to support DAX too. */ 1230 - return xfs_find_daxdev_for_inode(VFS_I(ip)) != NULL; 1230 + return xfs_inode_buftarg(ip)->bt_daxdev != NULL; 1231 1231 } 1232 1232 1233 1233 STATIC void