Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp85950iof; Sun, 5 Jun 2022 21:56:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1TyZcqSVDyeR4zEdWbNbtseJyHAul3you+M97kRLyiU/AsFw5JeLHCdXahBOmo+TBaJXy X-Received: by 2002:a17:902:a517:b0:161:e5f2:9a26 with SMTP id s23-20020a170902a51700b00161e5f29a26mr22856584plq.132.1654491368073; Sun, 05 Jun 2022 21:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654491368; cv=none; d=google.com; s=arc-20160816; b=pg2KEZA86yXC/YH9yl0/kuwYUYsSMIUgUvSExfNdpzrUnjHAh9KECIGoTYAgBuCBcg BMBx5ps3onyFrLFyXejWtFcyvKqvITyEJ9yY/1Mr7i2pg48Q4Z8H1WcipjivudVqrznx H7woPuMvOyHWiyt4ASVcIBW2yf6/LUTVRLjVuy6O0vDBBWNc7+Lwkqi30RYtDSrJ/bSa 1qVDP3QXp8VCLcIrdtUr/hvJnaCIa5kR7R+d8CUfnAe1G5oeOR28+gBp75DwPggB7sLH Eim+v2XcngRaB9zYMSlQuecXlHQvlQmUbVUr0DBlfqSe/o+MPnGViaTw3jcsDClQn6Xm U09w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=TmyorOiCBNFyJywm0YNoFpNXpnMoJO1EzHfMDsgnfNU=; b=BVU4KiEDmJsi2KTWxGuYUhV4BYAbofZZ8PQXou/f/iZlwbiSXTFReorVEvnEt/GmMu fnMAWUWJbLvacvaB3H96Ynl/jGf/TnjMw8NGBUlRk34hNdy/9hHVSwu0Uoo4FOyTXEBy yP5d3UXmJiWECAsTJCAs0H3vWJNCndPaVdMkiU+JCuuHzTvpElMPqIZd87zxWlF1LCcz ithlCmozDxp+zSXtAPAeDnQ+fC+JDrTbqjVmQVYgKRAD5ovftuXbHHdpTc3cpJJNTy+I aJw6dH0oICxC/5EO/Hc3u7l6HbMC4cc2A6M4S0Rgy3C/YruNhewOJLS2YBBklY8DpQfg iiZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z10-20020a170902ccca00b0016413da7b8bsi19854424ple.621.2022.06.05.21.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:56:08 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0DCF0D6807; Sun, 5 Jun 2022 21:09:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352095AbiFFCPn (ORCPT + 99 others); Sun, 5 Jun 2022 22:15:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232360AbiFFCPm (ORCPT ); Sun, 5 Jun 2022 22:15:42 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2332D366A4; Sun, 5 Jun 2022 19:15:39 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R541e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VFPsTeZ_1654481735; Received: from B-P7TQMD6M-0146.local(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VFPsTeZ_1654481735) by smtp.aliyun-inc.com(127.0.0.1); Mon, 06 Jun 2022 10:15:37 +0800 Date: Mon, 6 Jun 2022 10:15:35 +0800 From: Gao Xiang To: Ming Lei Cc: Pavel Machek , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Gabriel Krisman Bertazi , ZiyangZhang , Xiaoguang Wang Subject: Re: [RFC PATCH] ubd: add io_uring based userspace block driver Message-ID: Mail-Followup-To: Ming Lei , Pavel Machek , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Gabriel Krisman Bertazi , ZiyangZhang , Xiaoguang Wang References: <20220509092312.254354-1-ming.lei@redhat.com> <20220530070700.GF1363@bug> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 02, 2022 at 11:19:42AM +0800, Ming Lei wrote: > Hello Pavel, > > On Mon, May 30, 2022 at 09:07:00AM +0200, Pavel Machek wrote: > > Hi! > > > > > This is the driver part of userspace block driver(ubd driver), the other > > > part is userspace daemon part(ubdsrv)[1]. > > > > > @@ -0,0 +1,1193 @@ > > > +// SPDX-License-Identifier: GPL-2.0-or-later > > > +/* > > > + * Userspace block device - block device which IO is handled from userspace > > > + * > > > + * Take full use of io_uring passthrough command for communicating with > > > + * ubd userspace daemon(ubdsrvd) for handling basic IO request. > > > > > + > > > +static inline unsigned int ubd_req_build_flags(struct request *req) > > > +{ > > ... > > > + if (req->cmd_flags & REQ_SWAP) > > > + flags |= UBD_IO_F_SWAP; > > > + > > > + return flags; > > > +} > > > > Does it work? How do you guarantee operation will be deadlock-free with swapping and > > writebacks going on? > > The above is just for providing command flags to user side, so that the > user side can understand/handle the request better. > > prtrl(PR_SET_IO_FLUSHER) has been merged for avoiding the deadlock. > I've pointed out a case before that (I think) PR_SET_IO_FLUSHER doesn't work: https://lore.kernel.org/all/YhbYOeMUv5+U1XdQ@B-P7TQMD6M-0146.local I don't think handling writeback in the userspace under the direct reclaim context is _safe_ honestly. Because userspace program can call any system call under direct reclaim, which can interconnect to another process context and wait for it. yet I don't look into ubd implementation. Thanks, Gao Xiang