@@ -569,7 +569,10 @@ xfs_iomap_swapfile_activate(
struct file *swap_file,
sector_t *span)
{
- sis->bdev = xfs_inode_buftarg(XFS_I(file_inode(swap_file)))->bt_bdev;
+ struct xfs_inode *ip = XFS_I(file_inode(swap_file));
+ struct xfs_buftarg *btp = xfs_inode_buftarg(ip);
+
+ sis->bdev = xfs_buftarg_bdev(btp);
return iomap_swapfile_activate(sis, swap_file, span,
&xfs_read_iomap_ops);
}
@@ -62,10 +62,10 @@ xfs_zero_extent(
xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb);
sector_t block = XFS_BB_TO_FSBT(mp, sector);
- return blkdev_issue_zeroout(target->bt_bdev,
- block << (mp->m_super->s_blocksize_bits - 9),
- count_fsb << (mp->m_super->s_blocksize_bits - 9),
- GFP_NOFS, 0);
+ return xfs_buftarg_zeroout(target,
+ block << (mp->m_super->s_blocksize_bits - 9),
+ count_fsb << (mp->m_super->s_blocksize_bits - 9),
+ GFP_NOFS, 0);
}
#ifdef CONFIG_XFS_RT
@@ -378,8 +378,41 @@ extern void xfs_buftarg_wait(struct xfs_buftarg *);
extern void xfs_buftarg_drain(struct xfs_buftarg *);
extern int xfs_setsize_buftarg(struct xfs_buftarg *, unsigned int);
-#define xfs_getsize_buftarg(buftarg) block_size((buftarg)->bt_bdev)
-#define xfs_readonly_buftarg(buftarg) bdev_read_only((buftarg)->bt_bdev)
+static inline struct block_device *
+xfs_buftarg_bdev(struct xfs_buftarg *btp)
+{
+ return btp->bt_bdev;
+}
+
+static inline unsigned int
+xfs_getsize_buftarg(struct xfs_buftarg *btp)
+{
+ return block_size(btp->bt_bdev);
+}
+
+static inline bool
+xfs_readonly_buftarg(struct xfs_buftarg *btp)
+{
+ return bdev_read_only(btp->bt_bdev);
+}
+
+static inline int
+xfs_buftarg_flush(struct xfs_buftarg *btp)
+{
+ return blkdev_issue_flush(btp->bt_bdev);
+}
+
+static inline int
+xfs_buftarg_zeroout(
+ struct xfs_buftarg *btp,
+ sector_t sector,
+ sector_t nr_sects,
+ gfp_t gfp_mask,
+ unsigned flags)
+{
+ return blkdev_issue_zeroout(btp->bt_bdev, sector, nr_sects, gfp_mask,
+ flags);
+}
int xfs_buf_reverify(struct xfs_buf *bp, const struct xfs_buf_ops *ops);
bool xfs_verify_magic(struct xfs_buf *bp, __be32 dmagic);
@@ -29,7 +29,7 @@ xfs_trim_extents(
uint64_t *blocks_trimmed)
{
struct xfs_mount *mp = pag->pag_mount;
- struct block_device *bdev = mp->m_ddev_targp->bt_bdev;
+ struct block_device *bdev = xfs_buftarg_bdev(mp->m_ddev_targp);
struct xfs_btree_cur *cur;
struct xfs_buf *agbp;
struct xfs_agf *agf;
@@ -150,8 +150,8 @@ xfs_ioc_trim(
struct fstrim_range __user *urange)
{
struct xfs_perag *pag;
- unsigned int granularity =
- bdev_discard_granularity(mp->m_ddev_targp->bt_bdev);
+ struct block_device *bdev = xfs_buftarg_bdev(mp->m_ddev_targp);
+ unsigned int granularity = bdev_discard_granularity(bdev);
struct fstrim_range range;
xfs_daddr_t start, end, minlen;
xfs_agnumber_t agno;
@@ -160,7 +160,7 @@ xfs_ioc_trim(
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (!bdev_max_discard_sectors(mp->m_ddev_targp->bt_bdev))
+ if (!bdev_max_discard_sectors(bdev))
return -EOPNOTSUPP;
/*
@@ -164,9 +164,9 @@ xfs_file_fsync(
* inode size in case of an extending write.
*/
if (XFS_IS_REALTIME_INODE(ip))
- error = blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev);
+ error = xfs_buftarg_flush(mp->m_rtdev_targp);
else if (mp->m_logdev_targp != mp->m_ddev_targp)
- error = blkdev_issue_flush(mp->m_ddev_targp->bt_bdev);
+ error = xfs_buftarg_flush(mp->m_ddev_targp);
/*
* Any inode that has dirty modifications in the log is pinned. The
@@ -189,7 +189,7 @@ xfs_file_fsync(
*/
if (!log_flushed && !XFS_IS_REALTIME_INODE(ip) &&
mp->m_logdev_targp == mp->m_ddev_targp) {
- err2 = blkdev_issue_flush(mp->m_ddev_targp->bt_bdev);
+ err2 = xfs_buftarg_flush(mp->m_ddev_targp);
if (err2 && !error)
error = err2;
}
@@ -1762,6 +1762,7 @@ xfs_ioc_setlabel(
char __user *newlabel)
{
struct xfs_sb *sbp = &mp->m_sb;
+ struct block_device *bdev = xfs_buftarg_bdev(mp->m_ddev_targp);
char label[XFSLABEL_MAX + 1];
size_t len;
int error;
@@ -1808,7 +1809,7 @@ xfs_ioc_setlabel(
error = xfs_update_secondary_sbs(mp);
mutex_unlock(&mp->m_growlock);
- invalidate_bdev(mp->m_ddev_targp->bt_bdev);
+ invalidate_bdev(bdev);
out:
mnt_drop_write_file(filp);
@@ -129,7 +129,7 @@ xfs_bmbt_to_iomap(
if (mapping_flags & IOMAP_DAX)
iomap->dax_dev = target->bt_daxdev;
else
- iomap->bdev = target->bt_bdev;
+ iomap->bdev = xfs_buftarg_bdev(target);
iomap->flags = iomap_flags;
if (xfs_ipincount(ip) &&
@@ -154,7 +154,7 @@ xfs_hole_to_iomap(
iomap->type = IOMAP_HOLE;
iomap->offset = XFS_FSB_TO_B(ip->i_mount, offset_fsb);
iomap->length = XFS_FSB_TO_B(ip->i_mount, end_fsb - offset_fsb);
- iomap->bdev = target->bt_bdev;
+ iomap->bdev = xfs_buftarg_bdev(target);
iomap->dax_dev = target->bt_daxdev;
}
@@ -1938,7 +1938,7 @@ xlog_write_iclog(
* writeback throttle from throttling log writes behind background
* metadata writeback and causing priority inversions.
*/
- bio_init(&iclog->ic_bio, log->l_targ->bt_bdev, iclog->ic_bvec,
+ bio_init(&iclog->ic_bio, xfs_buftarg_bdev(log->l_targ), iclog->ic_bvec,
howmany(count, PAGE_SIZE),
REQ_OP_WRITE | REQ_META | REQ_SYNC | REQ_IDLE);
iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart + bno;
@@ -1959,7 +1959,7 @@ xlog_write_iclog(
* avoid shutdown re-entering this path and erroring out again.
*/
if (log->l_targ != log->l_mp->m_ddev_targp &&
- blkdev_issue_flush(log->l_mp->m_ddev_targp->bt_bdev)) {
+ xfs_buftarg_flush(log->l_mp->m_ddev_targp)) {
xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR);
return;
}
@@ -742,7 +742,8 @@ xlog_discard_busy_extents(
trace_xfs_discard_extent(mp, busyp->agno, busyp->bno,
busyp->length);
- error = __blkdev_issue_discard(mp->m_ddev_targp->bt_bdev,
+ error = __blkdev_issue_discard(
+ xfs_buftarg_bdev(mp->m_ddev_targp),
XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno),
XFS_FSB_TO_BB(mp, busyp->length),
GFP_NOFS, &bio);
@@ -137,7 +137,8 @@ xlog_do_io(
nbblks = round_up(nbblks, log->l_sectBBsize);
ASSERT(nbblks > 0);
- error = xfs_rw_bdev(log->l_targ->bt_bdev, log->l_logBBstart + blk_no,
+ error = xfs_rw_bdev(xfs_buftarg_bdev(log->l_targ),
+ log->l_logBBstart + blk_no,
BBTOB(nbblks), data, op);
if (error && !xlog_is_shutdown(log)) {
xfs_alert(log->l_mp,
@@ -408,13 +408,13 @@ xfs_close_devices(
struct xfs_mount *mp)
{
if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
- struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
+ struct block_device *logdev = xfs_buftarg_bdev(mp->m_logdev_targp);
xfs_free_buftarg(mp->m_logdev_targp);
xfs_blkdev_put(logdev);
}
if (mp->m_rtdev_targp) {
- struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
+ struct block_device *rtdev = xfs_buftarg_bdev(mp->m_rtdev_targp);
xfs_free_buftarg(mp->m_rtdev_targp);
xfs_blkdev_put(rtdev);