From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 72A3DC32771 for ; Tue, 27 Sep 2022 03:21:49 +0000 (UTC) Received: from localhost ([::1]:58546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od1AK-0001Mi-6L for qemu-devel@archiver.kernel.org; Mon, 26 Sep 2022 23:21:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od191-0008HU-4N; Mon, 26 Sep 2022 23:20:28 -0400 Received: from [106.39.185.58] (port=58704 helo=smtp.cecloud.com) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od18x-0001WQ-QX; Mon, 26 Sep 2022 23:20:26 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.cecloud.com (Postfix) with ESMTP id 8D9D917E0207; Tue, 27 Sep 2022 11:20:09 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ANTISPAM-LEVEL: 2 X-SKE-CHECKED: 1 X-ABS-CHECKED: 1 Received: from [10.32.181.78] (unknown [111.48.58.10]) by smtp.cecloud.com (postfix) whith ESMTP id P2473745T281457568379248S1664248808174425_; Tue, 27 Sep 2022 11:20:09 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: luzhipeng@cestc.cn X-SENDER: luzhipeng@cestc.cn X-LOGIN-NAME: luzhipeng@cestc.cn X-FST-TO: vsementsov@yandex-team.ru X-RCPT-COUNT: 5 X-SENDER-IP: 111.48.58.10 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 Message-ID: Date: Tue, 27 Sep 2022 11:20:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH] qemu-nbd: set timeout to qemu-nbd socket To: Vladimir Sementsov-Ogievskiy , "Denis V. Lunev" , qemu-devel Cc: Eric Blake , qemu-block@nongnu.org References: <20220925135308.481-1-luzhipeng@cestc.cn> <2718426c-dd89-5b50-29c4-63f0d6c9b25f@yandex-team.ru> <02a2279b-fcb2-c90d-7598-af029ea8261a@virtuozzo.com> <50b3e1ee-8bba-ae28-ca0e-4cb489a65ad5@yandex-team.ru> From: luzhipeng In-Reply-To: <50b3e1ee-8bba-ae28-ca0e-4cb489a65ad5@yandex-team.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 106.39.185.58 (failed) Received-SPF: pass client-ip=106.39.185.58; envelope-from=luzhipeng@cestc.cn; helo=smtp.cecloud.com 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, NICE_REPLY_A=-2.319, RCVD_IN_SBL_CSS=3.335, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 在 2022/9/26 20:44, Vladimir Sementsov-Ogievskiy 写道: > On 9/26/22 14:34, Denis V. Lunev wrote: >> On 9/26/22 12:05, Vladimir Sementsov-Ogievskiy wrote: >>> [+ Den] >>> >>> On 9/25/22 16:53, luzhipeng wrote: >>>> From: lu zhipeng >>>> >>>> Prevent the NBD socket stuck all the time, So >>>> set timeout. >>>> >>>> Signed-off-by: lu zhipeng >>>> --- >>>>   nbd/client.c | 8 ++++++++ >>>>   1 file changed, 8 insertions(+) >>>> >>>> diff --git a/nbd/client.c b/nbd/client.c >>>> index 30d5383cb1..89dde53a0f 100644 >>>> --- a/nbd/client.c >>>> +++ b/nbd/client.c >>>> @@ -24,6 +24,8 @@ >>>>   #include "nbd-internal.h" >>>>   #include "qemu/cutils.h" >>>>   +#define NBD_DEFAULT_TIMEOUT 30 >>>> + >>>>   /* Definitions for opaque data types */ >>>>     static QTAILQ_HEAD(, NBDExport) exports = >>>> QTAILQ_HEAD_INITIALIZER(exports); >>>> @@ -1301,6 +1303,12 @@ int nbd_init(int fd, QIOChannelSocket *sioc, >>>> NBDExportInfo *info, >>>>           } >>>>       } >>>>   +    if (ioctl(fd, NBD_SET_TIMEOUT, NBD_DEFAULT_TIMEOUT) < 0) { >>>> +        int serrno = errno; >>>> +        error_setg(errp, "Failed setting timeout"); >>>> +        return -serrno; >>>> +    } >>>> + >>>>       trace_nbd_init_finish(); >>>>         return 0; >>> >>> >>> Personally, I don't see a problem in enabling timeout by default.. >>> But probably we need a new option instead? >>> >>> >> I believe that this should be the same story as we have had with >> KEEPALIVE. This should be set as an option and downstream >> will change its default when necessary. >> > > It's also interesting, how NBD_SET_TIMEOUT would interfere with > keep-alive options set on the socket. Isn't existing keep-alive option > already enough, do we need both timeouts? > > (and yes, if we need both ways for different cases, we definitely should > keep a possibility for the user to enable only one timeout, so now I > agree, that we need an option for this new feature) > > keep-alive is only valid for tcp mode, unix domain is not valid