From: Denis Mukhin <[email protected]> Introduce `flush` subcommand for all blk devices to allow committing dirty data explicitly to the given block device.
Signed-off-by: Denis Mukhin <[email protected]> --- Changes since v1: - updated commit message - updated blk commands to enable flush --- cmd/blk_common.c | 14 ++++++++++++++ cmd/ide.c | 1 + cmd/nvme.c | 1 + cmd/pvblock.c | 1 + cmd/sata.c | 1 + cmd/scsi.c | 1 + cmd/usb.c | 1 + cmd/virtio.c | 1 + 8 files changed, 21 insertions(+) diff --git a/cmd/blk_common.c b/cmd/blk_common.c index 56529702a470..d3b00e10f17c 100644 --- a/cmd/blk_common.c +++ b/cmd/blk_common.c @@ -37,6 +37,20 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id, printf("\nno %s partition table available\n", if_name); return CMD_RET_SUCCESS; + } else if (strncmp(argv[1], "flush", 5) == 0) { + struct blk_desc *desc; + int ret; + + ret = blk_get_desc(uclass_id, *cur_devnump, &desc); + if (ret) + return CMD_RET_FAILURE; + + if (blk_dflush(desc)) { + printf("\nfailed to flush device %s\n", if_name); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; } return CMD_RET_USAGE; case 3: diff --git a/cmd/ide.c b/cmd/ide.c index f99fb6f58246..16833e30319c 100644 --- a/cmd/ide.c +++ b/cmd/ide.c @@ -63,6 +63,7 @@ U_BOOT_CMD(ide, 5, 1, do_ide, "IDE sub-system", "reset - reset IDE controller\n" "ide info - show available IDE devices\n" + "ide flush - commit all dirty data to the current IDE device\n" "ide device [dev] - show or set current device\n" "ide part [dev] - print partition table of one or all IDE devices\n" "ide read addr blk# cnt\n" diff --git a/cmd/nvme.c b/cmd/nvme.c index f2c9acba5c32..dbccb69042bc 100644 --- a/cmd/nvme.c +++ b/cmd/nvme.c @@ -47,6 +47,7 @@ U_BOOT_CMD( "scan - scan NVMe devices\n" "nvme detail - show details of current NVMe device\n" "nvme info - show all available NVMe devices\n" + "nvme flush - commit all dirty data to the current NVMe device\n" "nvme device [dev] - show or set current NVMe device\n" "nvme part [dev] - print partition table of one or all NVMe devices\n" "nvme read addr blk# cnt - read `cnt' blocks starting at block\n" diff --git a/cmd/pvblock.c b/cmd/pvblock.c index 3a83ac9cd92c..5e4a98a6b13b 100644 --- a/cmd/pvblock.c +++ b/cmd/pvblock.c @@ -20,6 +20,7 @@ int do_pvblock(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) U_BOOT_CMD(pvblock, 5, 1, do_pvblock, "Xen para-virtualized block device", "info - show available block devices\n" + "pvblock flush - commit all dirty data to the current device\n" "pvblock device [dev] - show or set current device\n" "pvblock part [dev] - print partition table of one or all devices\n" "pvblock read addr blk# cnt\n" diff --git a/cmd/sata.c b/cmd/sata.c index 8b923f9378b2..417e027cba4f 100644 --- a/cmd/sata.c +++ b/cmd/sata.c @@ -119,6 +119,7 @@ U_BOOT_CMD( "init - init SATA sub system\n" "sata stop [dev] - disable SATA sub system or device\n" "sata info - show available SATA devices\n" + "sata flush - commit all dirty data to the current SATA device\n" "sata device [dev] - show or set current device\n" "sata part [dev] - print partition table\n" "sata read addr blk# cnt\n" diff --git a/cmd/scsi.c b/cmd/scsi.c index ad7d8a4b6644..39be208f337a 100644 --- a/cmd/scsi.c +++ b/cmd/scsi.c @@ -47,6 +47,7 @@ U_BOOT_CMD( "SCSI sub-system", "scsi info - show available SCSI devices\n" "scsi scan - (re-)scan SCSI bus\n" + "scsi flush - commit all dirty data to the current SCSI device\n" "scsi device [dev] - show or set current device\n" "scsi part [dev] - print partition table of one or all SCSI devices\n" "scsi read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n" diff --git a/cmd/usb.c b/cmd/usb.c index 13a2996c1f00..3e156f54c50b 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -706,6 +706,7 @@ U_BOOT_CMD( " Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]\n" #ifdef CONFIG_USB_STORAGE "usb storage - show details of USB storage devices\n" + "usb flush - commit all dirty data to the current USB storage\n" "usb dev [dev] - show or set current USB storage device\n" "usb part [dev] - print partition table of one or all USB storage" " devices\n" diff --git a/cmd/virtio.c b/cmd/virtio.c index a42a563ab727..94f1e82cc902 100644 --- a/cmd/virtio.c +++ b/cmd/virtio.c @@ -44,6 +44,7 @@ U_BOOT_CMD( "virtio block devices sub-system", "scan - initialize virtio bus\n" "virtio info - show all available virtio block devices\n" + "virtio flush - commit all dirty data to the current virtio block device\n" "virtio device [dev] - show or set current virtio block device\n" "virtio part [dev] - print partition table of one or all virtio block devices\n" "virtio read addr blk# cnt - read `cnt' blocks starting at block\n" -- 2.54.0

