From patchwork Mon Mar 22 09:25:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChangLimin X-Patchwork-Id: 1456442 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 ozlabs.org (Postfix) with ESMTPS id 4F3q0744G0z9s1l for ; Mon, 22 Mar 2021 20:27:19 +1100 (AEDT) Received: from localhost ([::1]:45178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOGqD-0007co-IP for incoming@patchwork.ozlabs.org; Mon, 22 Mar 2021 05:27:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOGot-0007Ir-RN; Mon, 22 Mar 2021 05:25:57 -0400 Received: from prt-mail.chinatelecom.cn ([42.123.76.219]:34059 helo=chinatelecom.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOGoq-0001qX-Mz; Mon, 22 Mar 2021 05:25:55 -0400 HMM_SOURCE_IP: 172.18.0.92:23091.1148938065 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-106.120.101.58?logid-904cfd7ec8f04a0a81bcb2780626ce66 (unknown [172.18.0.92]) by chinatelecom.cn (HERMES) with SMTP id 626142800DD; Mon, 22 Mar 2021 17:25:37 +0800 (CST) X-189-SAVE-TO-SEND: 71112636@chinatelecom.cn Received: from ([172.18.0.92]) by App0021 with ESMTP id 904cfd7ec8f04a0a81bcb2780626ce66 for qemu-block@nongnu.org; Mon Mar 22 17:25:44 2021 X-Transaction-ID: 904cfd7ec8f04a0a81bcb2780626ce66 X-filter-score: filter<0> X-Real-From: changlm@chinatelecom.cn X-Receive-IP: 172.18.0.92 X-MEDUSA-Status: 0 Date: Mon, 22 Mar 2021 17:25:32 +0800 From: ChangLimin To: qemu-block Subject: [PATCH V4] file-posix: allow -EBUSY error during ioctl(fd, BLKZEROOUT, range) on block X-Priority: 3 X-GUID: E740AFB9-7C56-4866-AAD4-515CE2C1B725 X-Has-Attach: no X-Mailer: Foxmail 7.2.17.58[cn] Mime-Version: 1.0 Message-ID: <2021032217253258728710@chinatelecom.cn> Received-SPF: pass client-ip=42.123.76.219; envelope-from=changlm@chinatelecom.cn; helo=chinatelecom.cn X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, HTML_MESSAGE=0.001, MIME_BASE64_TEXT=1.741, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_KAM_HTML_FONT_INVALID=0.01 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: kwolf , Vladimir Sementsov-Ogievskiy , qemu-devel , mreitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" For Linux 5.10/5.11, qemu write zeros to a multipath device using ioctl(fd, BLKZEROOUT, range) with cache none or directsync return -EBUSY permanently. Fallback to pwritev instead of exit for -EBUSY error. The issue was introduced in Linux 5.10: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02 Fixed in Linux 5.12: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56887cffe946bb0a90c74429fa94d6110a73119d Signed-off-by: ChangLimin --- block/file-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/block/file-posix.c b/block/file-posix.c index 20e14f8e96..d4054ac9cb 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1624,8 +1624,12 @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) } while (errno == EINTR); ret = translate_err(-errno); - if (ret == -ENOTSUP) { - s->has_write_zeroes = false; + switch (ret) { + case -ENOTSUP: + s->has_write_zeroes = false; /* fall through */ + case -EBUSY: /* Linux 5.10/5.11 may return -EBUSY for multipath devices */ + return -ENOTSUP; + break; } } #endif