From patchwork Fri Apr 2 15:54:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12181237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DB19C433ED for ; Fri, 2 Apr 2021 15:56:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F67F610CC for ; Fri, 2 Apr 2021 15:56:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F67F610CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lSM9S-0002lX-5q for qemu-devel@archiver.kernel.org; Fri, 02 Apr 2021 11:56:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSM81-0001V7-Tq; Fri, 02 Apr 2021 11:54:33 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:53969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lSM7x-0004yf-6D; Fri, 02 Apr 2021 11:54:33 -0400 Received: by mail-pj1-x102e.google.com with SMTP id t18so2877000pjs.3; Fri, 02 Apr 2021 08:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8TMGCO1ooIPpKsTuojQpj0eW+Ayh7TPtCvPU6SJHF/o=; b=RU2eDOjQjqrVIjmC/xUSh1RE/RPmwuy1i61SMfamf5X6ltlzqgxUWFRyt0OxSjnrpG uj9v7nlPBpKskVHpnkL5mSm8Vu+WFAOyqlUOiyvTaorAeKu8rWl2S1eQK1mGlbVTRa++ Puc0/JR/FcMkGo6EeqXVWbvZL1YL+qAj/JAgvki8UZfK7mgUxQNb7EfZt+BMTLvvqH/W 4g96W9yeItQBsISJJvghNMiXIKyhDobX3rlkD4mM5kOivP+aEluJ2sK2vlooLVx5FNGY b5pgk80ddV/6+AEYUXEhXER37VyMGb33Xr6EiQLx3GicJ9lGhAGjp7fV8mPTg/LP7sYj yh5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8TMGCO1ooIPpKsTuojQpj0eW+Ayh7TPtCvPU6SJHF/o=; b=Ano7TcP7bjCeSlh+rkXkMTF1nQEtcqGobSbsbOWIOlkOKSOjRwBC7jRVSxCvyYhuAu JZz7Dvacc9DYj4210bL6kp3crCcnFTAYNRn14pSH6SLfSn1K6l2LgwSZpNiNmxAyPDa5 aXNvZDO9vZhCxHecMU6yOIZIR9LxB6+bQ6GL02KC+NQ0HaFGX0Ifnm6LhICPlFdWb5Hw 3aphI+G1/TD5r5qhKk1mrzPyMtGDRL1Za9wzcAKtJb/+skxlRi0V13G5XGpyHNAkgPin jciQhYNA30z6eUDcT66NX+p9tU5UDTAvkX6sEDYH1/ify/4P7gh5zd7yztwAEOSU1oBw KmUw== X-Gm-Message-State: AOAM531ej1OQeyTQnU38zgu50XnxsXh/a4rWi2XFFE2xjwm2isKX3cFs bh3r3DwwxQFuZ+bdtRG5GBeWeOG6Dl7RJQ== X-Google-Smtp-Source: ABdhPJyP7AmqGE8Gn+8C4BrMJe1VY/NZaMvUmeCSxwmuJu6F6YrGMYy0jq0jy0ScRjCZcigKt/LUeA== X-Received: by 2002:a17:903:1cf:b029:e8:c4ca:be6d with SMTP id e15-20020a17090301cfb02900e8c4cabe6dmr2521829plh.39.1617378864053; Fri, 02 Apr 2021 08:54:24 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:3c79:94d8:55ff:9601]) by smtp.gmail.com with ESMTPSA id 138sm8540278pfv.192.2021.04.02.08.54.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Apr 2021 08:54:23 -0700 (PDT) From: Akihiko Odaki To: Subject: [v4 1/3] block/file-posix: Optimize for macOS Date: Sat, 3 Apr 2021 00:54:04 +0900 Message-Id: <20210402155406.31033-1-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , pkrempa@redhat.com, Akihiko Odaki , qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Konstantin Nazarov , Stefan Hajnoczi , John Snow , dgilbert@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This commit introduces "punch hole" operation and optimizes transfer block size for macOS. Thanks to Konstantin Nazarov for detailed analysis of a flaw in an old version of this change: https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3654667 Signed-off-by: Akihiko Odaki --- block/file-posix.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 05079b40cae..8f25e194fcd 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -44,6 +44,7 @@ #if defined(__APPLE__) && (__MACH__) #include #include +#include #include #include #include @@ -1248,6 +1249,15 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVRawState *s = bs->opaque; +#if defined(__APPLE__) && (__MACH__) + struct statfs buf; + + if (!fstatfs(s->fd, &buf)) { + bs->bl.opt_transfer = buf.f_iosize; + bs->bl.pdiscard_alignment = buf.f_bsize; + } +#endif + if (bs->sg) { int ret = sg_get_max_transfer_length(s->fd); @@ -1586,6 +1596,7 @@ out: } } +#if defined(CONFIG_FALLOCATE) || defined(BLKZEROOUT) static int translate_err(int err) { if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP || @@ -1594,6 +1605,7 @@ static int translate_err(int err) } return err; } +#endif #ifdef CONFIG_FALLOCATE static int do_fallocate(int fd, int mode, off_t offset, off_t len) @@ -1795,16 +1807,27 @@ static int handle_aiocb_discard(void *opaque) } } while (errno == EINTR); - ret = -errno; + ret = translate_err(-errno); #endif } else { #ifdef CONFIG_FALLOCATE_PUNCH_HOLE ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, aiocb->aio_offset, aiocb->aio_nbytes); + ret = translate_err(-errno); +#elif defined(__APPLE__) && (__MACH__) + fpunchhole_t fpunchhole; + fpunchhole.fp_flags = 0; + fpunchhole.reserved = 0; + fpunchhole.fp_offset = aiocb->aio_offset; + fpunchhole.fp_length = aiocb->aio_nbytes; + if (fcntl(s->fd, F_PUNCHHOLE, &fpunchhole) == -1) { + ret = errno == ENODEV ? -ENOTSUP : -errno; + } else { + ret = 0; + } #endif } - ret = translate_err(ret); if (ret == -ENOTSUP) { s->has_discard = false; } From patchwork Fri Apr 2 15:54:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12181239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F298FC433B4 for ; Fri, 2 Apr 2021 15:56:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9784961155 for ; Fri, 2 Apr 2021 15:56:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9784961155 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lSM9X-0002uw-OT for qemu-devel@archiver.kernel.org; Fri, 02 Apr 2021 11:56:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSM84-0001Xh-8I; Fri, 02 Apr 2021 11:54:36 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:54968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lSM82-00052w-Ff; Fri, 02 Apr 2021 11:54:35 -0400 Received: by mail-pj1-x102c.google.com with SMTP id w8so2874627pjf.4; Fri, 02 Apr 2021 08:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9+cB+4RWNjTMO5skPwNv/dthVhDglokW5cciULwl+L8=; b=oQiV7qM6ai+do6Dqq0sobSHaBLPL/eQ2YPmaReQPckOj+fn722OZyqXtBzw6PKCOQI ir6adq4fPl46rDLZSMyQEfmMClq+Pe6EhW4toMAfyuyhFbOiUreKPI7+9UgA2yyEzQnW 7qZr0q74W2fSbwTS+C1h+w0heu3zVUUrGjWmWwFoclncMFFV+l1LR66BsTtbBr1fTfrq 4u2DORIaxtD789VbA0pviyq7+gUdwz/qzfSm+7oyHda5EqRGV/ZisK/4IwGVbrp9tpgI tI4IZF4F8/aPevFQ6A6mK3qm7yTcSAlfynxDh+t8WIqRwgLMuHymC9iS3LRZTrWU+qoA 4f8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9+cB+4RWNjTMO5skPwNv/dthVhDglokW5cciULwl+L8=; b=k+NnyoT3Duvf8ukdw8FWAg0BYqV9bitELgnNQimjcixs5+gQNjlNb5h3boWZuW8e2H wF4u6e0Qk2lZ5IxbTyabh5wyRa/zyTVoaWC+lBaTQFHKbUucxrfhLYEOv2Whv3ix67CI Gpo4dpzR8lF333V44YEK4D8+ziJ8obuSZXnswcTwMQPNzW1dOVzpLIrWokqN2B5Uk3No oHAAPodFbJapo1+BBebk9zwG/qlm+EdFawUpTQL712+7baUXiO4d3ByP//LX4yfTBfBd VlSpTOWNLTamv3rn+SlJlU6JNNvT8kZmSYeuR+kFw30enkuK/xj+BzxLo5m0HkDrmEBr QK5A== X-Gm-Message-State: AOAM530ye2TfvHB2mdMhTDnWlNbpH2HGc5BGbi+SlNUC+O1nOEcEW/x2 CBUrtfGZSISKrhSmVNqBjeq+ro9SW4qDDg== X-Google-Smtp-Source: ABdhPJygTXcJUiuCRYfT3t+5IC7FHN2syqsF785hvablgXLDyOZZyyt43Ya3DHxuhwK2SGTIbJQ2Sw== X-Received: by 2002:a17:902:a505:b029:e6:7a98:691b with SMTP id s5-20020a170902a505b02900e67a98691bmr13427852plq.84.1617378872359; Fri, 02 Apr 2021 08:54:32 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:3c79:94d8:55ff:9601]) by smtp.gmail.com with ESMTPSA id 138sm8540278pfv.192.2021.04.02.08.54.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Apr 2021 08:54:31 -0700 (PDT) From: Akihiko Odaki To: Subject: [v4 2/3] block: Add backend_defaults property Date: Sat, 3 Apr 2021 00:54:05 +0900 Message-Id: <20210402155406.31033-2-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210402155406.31033-1-akihiko.odaki@gmail.com> References: <20210402155406.31033-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , pkrempa@redhat.com, Akihiko Odaki , qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Konstantin Nazarov , Stefan Hajnoczi , John Snow , dgilbert@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" backend_defaults property allow users to control if default block properties should be decided with backend information. If it is off, any backend information will be discarded, which is suitable if you plan to perform live migration to a different disk backend. If it is on, a block device may utilize backend information more aggressively. By default, it is auto, which uses backend information for block sizes and ignores the others, which is consistent with the older versions. Signed-off-by: Akihiko Odaki --- hw/block/block.c | 42 ++++++++++++++++++++++++++++++++++++---- include/hw/block/block.h | 3 +++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/hw/block/block.c b/hw/block/block.c index 1e34573da71..d47ebf005ad 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -65,24 +65,58 @@ bool blkconf_blocksizes(BlockConf *conf, Error **errp) { BlockBackend *blk = conf->blk; BlockSizes blocksizes; - int backend_ret; + BlockDriverState *bs; + bool use_blocksizes; + bool use_bs; + + switch (conf->backend_defaults) { + case ON_OFF_AUTO_AUTO: + use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes); + use_bs = false; + break; + + case ON_OFF_AUTO_ON: + use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes); + bs = blk_bs(blk); + use_bs = bs; + break; + + case ON_OFF_AUTO_OFF: + use_blocksizes = false; + use_bs = false; + break; + + default: + abort(); + } - backend_ret = blk_probe_blocksizes(blk, &blocksizes); /* fill in detected values if they are not defined via qemu command line */ if (!conf->physical_block_size) { - if (!backend_ret) { + if (use_blocksizes) { conf->physical_block_size = blocksizes.phys; } else { conf->physical_block_size = BDRV_SECTOR_SIZE; } } if (!conf->logical_block_size) { - if (!backend_ret) { + if (use_blocksizes) { conf->logical_block_size = blocksizes.log; } else { conf->logical_block_size = BDRV_SECTOR_SIZE; } } + if (use_bs) { + if (!conf->opt_io_size) { + conf->opt_io_size = bs->bl.opt_transfer; + } + if (conf->discard_granularity == -1) { + if (bs->bl.pdiscard_alignment) { + conf->discard_granularity = bs->bl.pdiscard_alignment; + } else if (bs->bl.request_alignment != 1) { + conf->discard_granularity = bs->bl.request_alignment; + } + } + } if (conf->logical_block_size > conf->physical_block_size) { error_setg(errp, diff --git a/include/hw/block/block.h b/include/hw/block/block.h index c172cbe65f1..5902c0440a5 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -19,6 +19,7 @@ typedef struct BlockConf { BlockBackend *blk; + OnOffAuto backend_defaults; uint32_t physical_block_size; uint32_t logical_block_size; uint32_t min_io_size; @@ -48,6 +49,8 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) } #define DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) \ + DEFINE_PROP_ON_OFF_AUTO("backend_defaults", _state, \ + _conf.backend_defaults, ON_OFF_AUTO_AUTO), \ DEFINE_PROP_BLOCKSIZE("logical_block_size", _state, \ _conf.logical_block_size), \ DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \ From patchwork Fri Apr 2 15:54:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12181241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30651C433B4 for ; Fri, 2 Apr 2021 15:56:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9A2061155 for ; Fri, 2 Apr 2021 15:56:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9A2061155 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lSMA0-00034B-P6 for qemu-devel@archiver.kernel.org; Fri, 02 Apr 2021 11:56:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSM89-0001f3-A4; Fri, 02 Apr 2021 11:54:41 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:36454) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lSM87-000570-Si; Fri, 02 Apr 2021 11:54:41 -0400 Received: by mail-pl1-x62e.google.com with SMTP id ay2so2698652plb.3; Fri, 02 Apr 2021 08:54:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0dthNCxoWM5R/u/5zvjAtyDLPaOOu/14OIq3l3c/fOY=; b=SeVKNFxF2UY7UUjOR9yoECqTzjlsJGXH8ZMQlueUiecGZEtCyOrSchr57nh+c1xC/D ajvvs2ktqN9HBBzOeViNJeBb41YJkT5f+67BuxPK5/iHIe5RMIDEcp5RqUJ69HxeoOVQ 1evCgcdkW6B+6fcbL+eTs9EB7p16gWg25XJZ33DiOA3BXp2QNS9VwmBc0XYSIp+CFezJ 3CSHFQGOUfyu8seWtFHQ6ciUrtpErScH/Ux5k7ThuhJ/6tRH74t/PgKC1QZxegFDENQS hdHhuU/nEvEFW/fb3377TgJiHg4wq5FFK4tkBrO+2jDAGDr7wCJr5F56GyKBmuvx4yo/ FfwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0dthNCxoWM5R/u/5zvjAtyDLPaOOu/14OIq3l3c/fOY=; b=j2rf7BkafyZsE1+yX7cQJYj5cICVRjPSPBpvV59I5c+VPVMImVl+iOz6kTI57ybTMx 0C4aBv+YZU9F7jkIUQxzzwqmGQK9d887xJRDFJHK8xk+pVVJ8nmcbIezTJvPUi9FIId6 uHmI7lsQhbvzhQb+bWt8d5wX4FsZPB1kWun8BLMKUWwBi4m6qHLjcIyIWmT8z0PwO0AC 25WSypATYMODhHl8uZigKwQFmfQ8FeVnnRg30xL+jjav5Yh5vQQ2H7CNymqd7acOxyRh 7uKtH8LpgWb7sBbDaL9Kkw5qvUekMXeyJopoVkRYg0IEBrwZZ1EMB8p7t6UTdTv36zXp Y+Nw== X-Gm-Message-State: AOAM531N6gPAp6qsEQuyK9e8zmIomtL8p4z8glJfKGT6xxepqevnMa7z zVGzDmSaf6XM8mH7EllHuyKVN71vGZcOPw== X-Google-Smtp-Source: ABdhPJybbvxUCSCYQWex6d6xze9pDEn2JQLrwVBgqkLXTHpiJh+7eSimXvvct5bNDudOJe74r4Z9sg== X-Received: by 2002:a17:902:a502:b029:e8:3a40:bc6d with SMTP id s2-20020a170902a502b02900e83a40bc6dmr11247250plq.14.1617378878130; Fri, 02 Apr 2021 08:54:38 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:3c79:94d8:55ff:9601]) by smtp.gmail.com with ESMTPSA id 138sm8540278pfv.192.2021.04.02.08.54.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Apr 2021 08:54:37 -0700 (PDT) From: Akihiko Odaki To: Subject: [v4 3/3] block/io: Merge discard request alignments Date: Sat, 3 Apr 2021 00:54:06 +0900 Message-Id: <20210402155406.31033-3-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210402155406.31033-1-akihiko.odaki@gmail.com> References: <20210402155406.31033-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=akihiko.odaki@gmail.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , pkrempa@redhat.com, Akihiko Odaki , qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Konstantin Nazarov , Stefan Hajnoczi , John Snow , dgilbert@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Akihiko Odaki --- block/io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/io.c b/block/io.c index ca2dca30070..aad74bd6714 100644 --- a/block/io.c +++ b/block/io.c @@ -124,6 +124,8 @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll) static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src) { + dst->pdiscard_alignment = MAX(dst->pdiscard_alignment, + src->pdiscard_alignment); dst->opt_transfer = MAX(dst->opt_transfer, src->opt_transfer); dst->max_transfer = MIN_NON_ZERO(dst->max_transfer, src->max_transfer); dst->opt_mem_alignment = MAX(dst->opt_mem_alignment,