On Thu, Apr 7, 2022 at 11:05 PM Shiyang Ruan <ruansy.fnst@xxxxxxxxxxx> wrote: > > > > 在 2022/3/30 14:00, Christoph Hellwig 写道: > >> @@ -1892,6 +1893,8 @@ xfs_free_buftarg( > >> list_lru_destroy(&btp->bt_lru); > >> > >> blkdev_issue_flush(btp->bt_bdev); > >> + if (btp->bt_daxdev) > >> + dax_unregister_holder(btp->bt_daxdev, btp->bt_mount); > >> fs_put_dax(btp->bt_daxdev); > >> > >> kmem_free(btp); > >> @@ -1939,6 +1942,7 @@ xfs_alloc_buftarg( > >> struct block_device *bdev) > >> { > >> xfs_buftarg_t *btp; > >> + int error; > >> > >> btp = kmem_zalloc(sizeof(*btp), KM_NOFS); > >> > >> @@ -1946,6 +1950,14 @@ xfs_alloc_buftarg( > >> btp->bt_dev = bdev->bd_dev; > >> btp->bt_bdev = bdev; > >> btp->bt_daxdev = fs_dax_get_by_bdev(bdev, &btp->bt_dax_part_off); > >> + if (btp->bt_daxdev) { > >> + error = dax_register_holder(btp->bt_daxdev, mp, > >> + &xfs_dax_holder_operations); > >> + if (error) { > >> + xfs_err(mp, "DAX device already in use?!"); > >> + goto error_free; > >> + } > >> + } > > > > It seems to me that just passing the holder and holder ops to > > fs_dax_get_by_bdev and the holder to dax_unregister_holder would > > significantly simply the interface here. > > > > Dan, what do you think? > > Hi Dan, > > Could you give some advise on this API? Is it needed to move > dax_register_holder's job into fs_dax_get_by_bdev()? Yes, works for me to just add them as optional arguments.