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.

ublk: rename auto buffer registration helpers

Rename the auto buffer registration functions for clarity:

- __ublk_do_auto_buf_reg() -> ublk_auto_buf_register()
- ublk_prep_auto_buf_reg_io() -> ublk_auto_buf_io_setup()
- ublk_do_auto_buf_reg() -> ublk_auto_buf_dispatch()

Add comments documenting the locking requirements for each function.

No functional change.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Ming Lei and committed by
Jens Axboe
f50af896 e4d3fc6a

+26 -13
+26 -13
drivers/block/ublk_drv.c
··· 1509 1509 AUTO_BUF_REG_OK, 1510 1510 }; 1511 1511 1512 - static void ublk_prep_auto_buf_reg_io(const struct ublk_queue *ubq, 1513 - struct request *req, struct ublk_io *io, 1514 - struct io_uring_cmd *cmd, 1515 - enum auto_buf_reg_res res) 1512 + /* 1513 + * Setup io state after auto buffer registration. 1514 + * 1515 + * Must be called after ublk_auto_buf_register() is done. 1516 + * Caller must hold io->lock in batch context. 1517 + */ 1518 + static void ublk_auto_buf_io_setup(const struct ublk_queue *ubq, 1519 + struct request *req, struct ublk_io *io, 1520 + struct io_uring_cmd *cmd, 1521 + enum auto_buf_reg_res res) 1516 1522 { 1517 1523 if (res == AUTO_BUF_REG_OK) { 1518 1524 io->task_registered_buffers = 1; ··· 1529 1523 __ublk_prep_compl_io_cmd(io, req); 1530 1524 } 1531 1525 1526 + /* Register request bvec to io_uring for auto buffer registration. */ 1532 1527 static enum auto_buf_reg_res 1533 - __ublk_do_auto_buf_reg(const struct ublk_queue *ubq, struct request *req, 1528 + ublk_auto_buf_register(const struct ublk_queue *ubq, struct request *req, 1534 1529 struct ublk_io *io, struct io_uring_cmd *cmd, 1535 1530 unsigned int issue_flags) 1536 1531 { ··· 1551 1544 return AUTO_BUF_REG_OK; 1552 1545 } 1553 1546 1554 - static void ublk_do_auto_buf_reg(const struct ublk_queue *ubq, struct request *req, 1555 - struct ublk_io *io, struct io_uring_cmd *cmd, 1556 - unsigned int issue_flags) 1547 + /* 1548 + * Dispatch IO to userspace with auto buffer registration. 1549 + * 1550 + * Only called in non-batch context from task work, io->lock not held. 1551 + */ 1552 + static void ublk_auto_buf_dispatch(const struct ublk_queue *ubq, 1553 + struct request *req, struct ublk_io *io, 1554 + struct io_uring_cmd *cmd, 1555 + unsigned int issue_flags) 1557 1556 { 1558 - enum auto_buf_reg_res res = __ublk_do_auto_buf_reg(ubq, req, io, cmd, 1557 + enum auto_buf_reg_res res = ublk_auto_buf_register(ubq, req, io, cmd, 1559 1558 issue_flags); 1560 1559 1561 1560 if (res != AUTO_BUF_REG_FAIL) { 1562 - ublk_prep_auto_buf_reg_io(ubq, req, io, cmd, res); 1561 + ublk_auto_buf_io_setup(ubq, req, io, cmd, res); 1563 1562 io_uring_cmd_done(cmd, UBLK_IO_RES_OK, issue_flags); 1564 1563 } 1565 1564 } ··· 1640 1627 return; 1641 1628 1642 1629 if (ublk_support_auto_buf_reg(ubq) && ublk_rq_has_data(req)) { 1643 - ublk_do_auto_buf_reg(ubq, req, io, io->cmd, issue_flags); 1630 + ublk_auto_buf_dispatch(ubq, req, io, io->cmd, issue_flags); 1644 1631 } else { 1645 1632 ublk_init_req_ref(ubq, io); 1646 1633 ublk_complete_io_cmd(io, req, UBLK_IO_RES_OK, issue_flags); ··· 1661 1648 return false; 1662 1649 1663 1650 if (ublk_support_auto_buf_reg(ubq) && ublk_rq_has_data(req)) { 1664 - res = __ublk_do_auto_buf_reg(ubq, req, io, cmd, 1651 + res = ublk_auto_buf_register(ubq, req, io, cmd, 1665 1652 data->issue_flags); 1666 1653 1667 1654 if (res == AUTO_BUF_REG_FAIL) ··· 1669 1656 } 1670 1657 1671 1658 ublk_io_lock(io); 1672 - ublk_prep_auto_buf_reg_io(ubq, req, io, cmd, res); 1659 + ublk_auto_buf_io_setup(ubq, req, io, cmd, res); 1673 1660 ublk_io_unlock(io); 1674 1661 1675 1662 return true;