Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1340576ybe; Fri, 6 Sep 2019 16:13:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRPXcKEl/sKdUNKyRMk//z4Pcd2Hi+vbh9yNP2gKGWfoZ+XQhRbx2q7DKEI2WkqYSZlo0k X-Received: by 2002:aa7:953c:: with SMTP id c28mr13624711pfp.106.1567811625625; Fri, 06 Sep 2019 16:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567811625; cv=none; d=google.com; s=arc-20160816; b=d/yUuocMGxFcK8GOZ92bhZQwmHMBwL/Fot8ctT3qVPQtRmw/Ki0FM3HLMt02CbVtmv xqtdM4BNTcYO2DqtFHgvDSe52nCxG/nBRS6//0wI9I/qs42e/jeau23uFwWZogv4onQV hQCpim9808+1BH8bkNcjdrI/sulrs5x92dM8hnfiVKFeH7EsX11Mu549c4eLrenIjkrf PRjXB/f9kdnG3Hh9pmuNGBnAi5zFRkntOd+M146/ROx05yPWoOA8+pFQ2hYCySlrX3GX 6ozaDE/ryU/zYBgh9CGsKWk6KyJL+CXDkzzFv+kFsscuQhLViEYH5gkSWbAnncWF+yTM DDvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7W1h4jb9OR6H4E7B4ZzfIojbwERC9smSoENQ4vsrn6o=; b=LuFYA9L67ZfBOXb3bLzus+DoqCPXoPvPgMOcgqx/ggHw8LtIv6e10m80aBASsCdRdn HX/ofc9HE+2jHlPxk+3PvWTQHX/A6gWr5nAELrViUUbmP9VE5q7Pe7+y2qOwzLcHbeCF wNbpGCTg7OCk8c43NKm5UrNpwLp8H3bVTyEXqq8TFnnGKlrXya9H0lRdaI7e6cr+D0j3 Rfxbvf/GzXX2iXddZGwVfXfPiFh0Tz/1x70boJ+bXUTfhKMiW9WSfY5Kzs5GZwYbwx0U kY4ZdRzk3RCqFNFwiy25EI76eI/PHJQK6Q3OWzpkB9fhu9eQWy3nx17tslbB0rIub1gf jIVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si5524820pgv.21.2019.09.06.16.13.29; Fri, 06 Sep 2019 16:13:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394246AbfIFORR (ORCPT + 99 others); Fri, 6 Sep 2019 10:17:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51324 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394071AbfIFORQ (ORCPT ); Fri, 6 Sep 2019 10:17:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9DD910F23F8; Fri, 6 Sep 2019 14:17:16 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EE185D9D3; Fri, 6 Sep 2019 14:17:06 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 95BB4220292; Fri, 6 Sep 2019 10:17:05 -0400 (EDT) Date: Fri, 6 Sep 2019 10:17:05 -0400 From: Vivek Goyal To: Stefan Hajnoczi Cc: linux-fsdevel@vger.kernel.org, virtualization@lists.linux-foundation.org, miklos@szeredi.hu, linux-kernel@vger.kernel.org, virtio-fs@redhat.com, dgilbert@redhat.com, mst@redhat.com Subject: Re: [PATCH 08/18] virtiofs: Drain all pending requests during ->remove time Message-ID: <20190906141705.GF22083@redhat.com> References: <20190905194859.16219-1-vgoyal@redhat.com> <20190905194859.16219-9-vgoyal@redhat.com> <20190906105210.GP5900@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190906105210.GP5900@stefanha-x1.localdomain> User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Fri, 06 Sep 2019 14:17:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 06, 2019 at 11:52:10AM +0100, Stefan Hajnoczi wrote: > On Thu, Sep 05, 2019 at 03:48:49PM -0400, Vivek Goyal wrote: > > +static void virtio_fs_drain_queue(struct virtio_fs_vq *fsvq) > > +{ > > + WARN_ON(fsvq->in_flight < 0); > > + > > + /* Wait for in flight requests to finish.*/ > > + while (1) { > > + spin_lock(&fsvq->lock); > > + if (!fsvq->in_flight) { > > + spin_unlock(&fsvq->lock); > > + break; > > + } > > + spin_unlock(&fsvq->lock); > > + usleep_range(1000, 2000); > > + } > > I think all contexts that call this allow sleeping so we could avoid > usleep here. usleep_range() is supposed to be used from non-atomic context. https://github.com/torvalds/linux/blob/master/Documentation/timers/timers-howto.rst What construct you are thinking of? Vivek