Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2214675ybz; Thu, 30 Apr 2020 12:58:44 -0700 (PDT) X-Google-Smtp-Source: APiQypI/kSPTx1yOT86GCLBNyCvLRB6FiCf3APVlnyF7Zx2ULIRJHvkYO3SnGgCCOYC+rxae5HJ0 X-Received: by 2002:aa7:d3d1:: with SMTP id o17mr670319edr.200.1588276724523; Thu, 30 Apr 2020 12:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588276724; cv=none; d=google.com; s=arc-20160816; b=FAbrxvPN9b8gIXpYGN8puYBNVwewwbbbexSXMMKitQ7Mg5Tx8iFqvmK8ox5Kn/5uQZ hK2xnAw8u6gJfItSN5q9/eryvoqiTpg0kTiCexZ3Q8BoPkNTurNn5RCEIVO1Qc40Sath KkpV5fy/Y3YORVnpdom9cVfJL7LluAtEkAysShqf9AUm1qE7+YmdR14RY4HLLYDzlF1a +Fal4kwzvky2bi5RxU1vVyEYpECAm6HIDi9/VkS+8ISxmlixW/aWndvXj9RILM5csMb4 aMmaqE0gnzg1qYE1BuTmFnCdy45rFYTcn0RbphL5TfKuY7bPmGMnbTvivobMRGUbUeho CuMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=kPzmBEkauB3ZxlWoeL0oahZoxKT2pd5/ATvEYXXQ2xc=; b=XYFWtk5jnOCHH3ZNxogvUB84wLgn1UES2DwesRaorWTD4wnxqvWp5eoGfeMoYeebrr PriaN8MokmJ9D2PGulmloeJ9rvsCTN8XQaAxug1vhsjs13HCnv5wGw85d/8OGFjsWZQS 5L4CSYLa7f1t8GdrUbZs2lmCuoUNGBkt0TkvMzqVen4+eQIrSVfAv6n1q9JK6dcDx4QK NS3C+e90YJy7p/lRCLiUNJjTCKlZKkNwXJzmChElqJkVhnNNL2sOme3F7PVQb41xNdph BunUui0gGdSViGYLywzBIRBUbceObgYi3ZC1RctYc2xstRarodDuAaPDUOWa6K5kDK9Y puzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=cDz9M1OI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si365046edx.112.2020.04.30.12.58.20; Thu, 30 Apr 2020 12:58:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=cDz9M1OI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbgD3T47 (ORCPT + 99 others); Thu, 30 Apr 2020 15:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbgD3T46 (ORCPT ); Thu, 30 Apr 2020 15:56:58 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CFADC08E859 for ; Thu, 30 Apr 2020 12:56:58 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id f7so381951pfa.9 for ; Thu, 30 Apr 2020 12:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kPzmBEkauB3ZxlWoeL0oahZoxKT2pd5/ATvEYXXQ2xc=; b=cDz9M1OIiYUZDQy3cKKmDRnnZGONTni4S2ZJmbWsXQswsF3MB7iZ+K3PywbHI2cWbR Mf+XxDVUPKnyap5PXRKDqhPWc+/EwhWy6fZ8gUzzuRfmafcNZHlfXmJMNJPwQxVI6Bfg FCIoaX7FhQ+08qxE1xXh3e3gsMJ/niq0fcsb71m4Zqes5WHpzuG5w2aBQqkzMZXH7UBa KL30k1EahReJwjOt4M95T/dXETNQsy4A91l5/w+UKSYVkEgWNlSd0qxCviBLmgso/VVN aOyLbNNAbCghJ4VXC1lPu7rjzDYGWNO30XQuVsOWwxQESN5qpOewu37dyuqtrr1oPDRH X2wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kPzmBEkauB3ZxlWoeL0oahZoxKT2pd5/ATvEYXXQ2xc=; b=XjMKZK+RQWR4JQNZj+1WwRgO7Xm1fRblURnouUTvIDtBNM4+PkoaTk6HBYWOSRcZCG JDtexFwcLFh3zRT8mguztj6gnFqVhSr6deSEzbF3uBPBtNMQ3qeMGamtFWkXVnIPETHd VjOFY1WcFPxa0PxDwi7CdjDy7Kjo2nWtY05F3gEjeO6jZTb791wyJqML2oBC9LKMAIx+ YTRlKKAdEnQN6XCHNqrAHR9hF/z/Pzpl00zosNJE9FZ9e7OAD/jELAjjShThXUSeSxIE PIBClfE4aAXVG/Mk1sL6p3iPS7x40uaa2Na9Tm26xYFJ8JF4+R5SKwdw2A9jomsEY0JL IrXA== X-Gm-Message-State: AGi0PuZ+MOabY4WYJ2d0QVGA+n8yvImfS87I7GmTSnULIz0V6/Tpg5pC hjYY8LyJzPB2N3y6Ixh68WPpKvhV4ajnnA== X-Received: by 2002:a62:3006:: with SMTP id w6mr391270pfw.29.1588276617468; Thu, 30 Apr 2020 12:56:57 -0700 (PDT) Received: from [192.168.1.188] ([66.219.217.145]) by smtp.gmail.com with ESMTPSA id z1sm502198pjn.43.2020.04.30.12.56.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2020 12:56:56 -0700 (PDT) Subject: Re: [PATCH] pipe: read/write_iter() handler should check for IOCB_NOWAIT From: Jens Axboe To: Matthew Wilcox Cc: Alexander Viro , linux-fsdevel , "linux-kernel@vger.kernel.org" References: <273d8294-2508-a4c2-f96e-a6a394f94166@kernel.dk> <20200430175856.GX29705@bombadil.infradead.org> Message-ID: <82433793-07ed-ea65-5962-86c8e4c59afb@kernel.dk> Date: Thu, 30 Apr 2020 13:56:55 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/30/20 1:51 PM, Jens Axboe wrote: > On 4/30/20 12:47 PM, Jens Axboe wrote: >> On 4/30/20 11:58 AM, Matthew Wilcox wrote: >>> On Thu, Apr 30, 2020 at 10:24:46AM -0600, Jens Axboe wrote: >>>> Pipe read/write only checks for the file O_NONBLOCK flag, but we should >>>> also check for IOCB_NOWAIT for whether or not we should handle this read >>>> or write in a non-blocking fashion. If we don't, then we will block on >>>> data or space for iocbs that explicitly asked for non-blocking >>>> operation. This messes up callers that explicitly ask for non-blocking >>>> operations. >>>> >>>> Signed-off-by: Jens Axboe >>> >>> Wouldn't this be better? >> >> Yeah, that's probably a better idea. Care to send a "proper" patch? > > I take that back, running into issues going with a whole-sale conversion > like that: > > mkdir("/run/dhcpcd", 0755) = -1 EEXIST (File exists) > openat(AT_FDCWD, "/run/dhcpcd/ens7.pid", O_WRONLY|O_CREAT|O_NONBLOCK|O_CLOEXEC, 0644) = 4 > flock(4, LOCK_EX|LOCK_NB) = 0 > getpid() = 214 > ftruncate(4, 0) = 0 > lseek(4, 0, SEEK_SET) = 0 > fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 > lseek(4, 0, SEEK_CUR) = 0 > write(4, "214\n", 4) = -1 EINVAL (Invalid argument) > > which I don't know where is coming from yet, but it's definitely > breakage by auto setting IOCB_NOWAIT if O_NONBLOCK is set. > > I'd prefer to go your route, but I also would like this fixed for pipes > for 5.7. So I'd suggest we go with mine, and then investigate why this > is breaking stuff and go with the all-in approach for 5.8 if feasible. OK, it's the old classic in generic_write_checks(), is my guess: if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)) return -EINVAL; so we definitely can't just flip the switch on O_NONBLOCK -> IOCB_NOWAIT in general, at least not for writes. -- Jens Axboe