Commit 71eba7ff authored by zhenwei pi's avatar zhenwei pi Committed by Tomasz Zawadzki
Browse files

bdev/aio: support WRITE ZEROS



Support WRITE ZEROS by fallocate FALLOC_FL_ZERO_RANGE.

Change-Id: I2d660ad46f46c10ac77c16c71b9efcab07c35d84
Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20455


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 648a5414
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -276,6 +276,15 @@ bdev_aio_unmap(struct spdk_bdev_io *bdev_io)

	bdev_aio_fallocate(bdev_io, mode);
}


static void
bdev_aio_write_zeros(struct spdk_bdev_io *bdev_io)
{
	int mode = FALLOC_FL_ZERO_RANGE;

	bdev_aio_fallocate(bdev_io, mode);
}
#endif

static void
@@ -615,6 +624,10 @@ _bdev_aio_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
	case SPDK_BDEV_IO_TYPE_UNMAP:
		bdev_aio_unmap(bdev_io);
		return 0;

	case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
		bdev_aio_write_zeros(bdev_io);
		return 0;
#endif

	default:
@@ -643,6 +656,7 @@ bdev_aio_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
		return true;

	case SPDK_BDEV_IO_TYPE_UNMAP:
	case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
		return fdisk->fallocate;

	default:
+1 −1
Original line number Diff line number Diff line
@@ -494,7 +494,7 @@ def bdev_aio_create(client, filename, name, block_size=None, readonly=False, fal
        name: name of block device
        block_size: block size of device (optional; autodetected if omitted)
        readonly: set aio bdev as read-only
        fallocate: enable fallocate for UNMAP support (note that fallocate syscall would block reactor)
        fallocate: enable fallocate for UNMAP/WRITEZEROS support (note that fallocate syscall would block reactor)

    Returns:
        Name of created block device.
+1 −1
Original line number Diff line number Diff line
@@ -487,7 +487,7 @@ if __name__ == "__main__":
    p.add_argument('name', help='Block device name')
    p.add_argument('block_size', help='Block size for this bdev', type=int, nargs='?')
    p.add_argument("-r", "--readonly", action='store_true', help='Set this bdev as read-only')
    p.add_argument("--fallocate", action='store_true', help='Support unmap by fallocate')
    p.add_argument("--fallocate", action='store_true', help='Support unmap/writezeros by fallocate')
    p.set_defaults(func=bdev_aio_create)

    def bdev_aio_rescan(args):