Skip to content

Commit 5b5abbe

Browse files
Christoph Hellwigdjbw
authored andcommitted
xfs: move dax device handling into xfs_{alloc,free}_buftarg
Hide the DAX device lookup from the xfs_super.c code. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Dan Williams <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 89b93a7 commit 5b5abbe

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

fs/xfs/xfs_buf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,7 @@ xfs_free_buftarg(
18921892
list_lru_destroy(&btp->bt_lru);
18931893

18941894
blkdev_issue_flush(btp->bt_bdev);
1895+
fs_put_dax(btp->bt_daxdev);
18951896

18961897
kmem_free(btp);
18971898
}
@@ -1932,11 +1933,10 @@ xfs_setsize_buftarg_early(
19321933
return xfs_setsize_buftarg(btp, bdev_logical_block_size(bdev));
19331934
}
19341935

1935-
xfs_buftarg_t *
1936+
struct xfs_buftarg *
19361937
xfs_alloc_buftarg(
19371938
struct xfs_mount *mp,
1938-
struct block_device *bdev,
1939-
struct dax_device *dax_dev)
1939+
struct block_device *bdev)
19401940
{
19411941
xfs_buftarg_t *btp;
19421942

@@ -1945,7 +1945,7 @@ xfs_alloc_buftarg(
19451945
btp->bt_mount = mp;
19461946
btp->bt_dev = bdev->bd_dev;
19471947
btp->bt_bdev = bdev;
1948-
btp->bt_daxdev = dax_dev;
1948+
btp->bt_daxdev = fs_dax_get_by_bdev(bdev);
19491949

19501950
/*
19511951
* Buffer IO error rate limiting. Limit it to no more than 10 messages

fs/xfs/xfs_buf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ xfs_buf_update_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
338338
/*
339339
* Handling of buftargs.
340340
*/
341-
extern struct xfs_buftarg *xfs_alloc_buftarg(struct xfs_mount *,
342-
struct block_device *, struct dax_device *);
341+
struct xfs_buftarg *xfs_alloc_buftarg(struct xfs_mount *mp,
342+
struct block_device *bdev);
343343
extern void xfs_free_buftarg(struct xfs_buftarg *);
344344
extern void xfs_buftarg_wait(struct xfs_buftarg *);
345345
extern void xfs_buftarg_drain(struct xfs_buftarg *);

fs/xfs/xfs_super.c

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -391,26 +391,19 @@ STATIC void
391391
xfs_close_devices(
392392
struct xfs_mount *mp)
393393
{
394-
struct dax_device *dax_ddev = mp->m_ddev_targp->bt_daxdev;
395-
396394
if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
397395
struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
398-
struct dax_device *dax_logdev = mp->m_logdev_targp->bt_daxdev;
399396

400397
xfs_free_buftarg(mp->m_logdev_targp);
401398
xfs_blkdev_put(logdev);
402-
fs_put_dax(dax_logdev);
403399
}
404400
if (mp->m_rtdev_targp) {
405401
struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
406-
struct dax_device *dax_rtdev = mp->m_rtdev_targp->bt_daxdev;
407402

408403
xfs_free_buftarg(mp->m_rtdev_targp);
409404
xfs_blkdev_put(rtdev);
410-
fs_put_dax(dax_rtdev);
411405
}
412406
xfs_free_buftarg(mp->m_ddev_targp);
413-
fs_put_dax(dax_ddev);
414407
}
415408

416409
/*
@@ -428,8 +421,6 @@ xfs_open_devices(
428421
struct xfs_mount *mp)
429422
{
430423
struct block_device *ddev = mp->m_super->s_bdev;
431-
struct dax_device *dax_ddev = fs_dax_get_by_bdev(ddev);
432-
struct dax_device *dax_logdev = NULL, *dax_rtdev = NULL;
433424
struct block_device *logdev = NULL, *rtdev = NULL;
434425
int error;
435426

@@ -439,8 +430,7 @@ xfs_open_devices(
439430
if (mp->m_logname) {
440431
error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
441432
if (error)
442-
goto out;
443-
dax_logdev = fs_dax_get_by_bdev(logdev);
433+
return error;
444434
}
445435

446436
if (mp->m_rtname) {
@@ -454,25 +444,24 @@ xfs_open_devices(
454444
error = -EINVAL;
455445
goto out_close_rtdev;
456446
}
457-
dax_rtdev = fs_dax_get_by_bdev(rtdev);
458447
}
459448

460449
/*
461450
* Setup xfs_mount buffer target pointers
462451
*/
463452
error = -ENOMEM;
464-
mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev, dax_ddev);
453+
mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev);
465454
if (!mp->m_ddev_targp)
466455
goto out_close_rtdev;
467456

468457
if (rtdev) {
469-
mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev, dax_rtdev);
458+
mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev);
470459
if (!mp->m_rtdev_targp)
471460
goto out_free_ddev_targ;
472461
}
473462

474463
if (logdev && logdev != ddev) {
475-
mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev, dax_logdev);
464+
mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev);
476465
if (!mp->m_logdev_targp)
477466
goto out_free_rtdev_targ;
478467
} else {
@@ -488,14 +477,9 @@ xfs_open_devices(
488477
xfs_free_buftarg(mp->m_ddev_targp);
489478
out_close_rtdev:
490479
xfs_blkdev_put(rtdev);
491-
fs_put_dax(dax_rtdev);
492480
out_close_logdev:
493-
if (logdev && logdev != ddev) {
481+
if (logdev && logdev != ddev)
494482
xfs_blkdev_put(logdev);
495-
fs_put_dax(dax_logdev);
496-
}
497-
out:
498-
fs_put_dax(dax_ddev);
499483
return error;
500484
}
501485

0 commit comments

Comments
 (0)