Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp960526yba; Fri, 26 Apr 2019 11:36:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRrt2TAAvrhsXU0m+bq8mCKwlYEMgKpbz8HRHwP5PlS6ichHsx78VYF20+8bDgdWocCwtZ X-Received: by 2002:a62:be14:: with SMTP id l20mr12456895pff.241.1556303819746; Fri, 26 Apr 2019 11:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556303819; cv=none; d=google.com; s=arc-20160816; b=zZ4IIA+3KLhpkA5K+aJLbVaz285ZByzbtLZBjP8NEqiGaO1TXLBl67nVua62abcpuP N6mCMOfUBBbbC3NvV2LqUrlXzd6fRQvWSdj+dlpAdyDQ9gHXRo2I64gi2auKxSlHnJMC xVu41YPFJrEPm332pPBmVgY4xZRK2NlXDaTNVtrOjvzZDx/hJmQ3ThfI6/cWChuZ8OlN tKeIKr7vw2HfYmHwsvJYPD9H1KroUIKpb88FVVgw6FYQ94UKvkx2hWXJMwgGTcneLnXj qv0B8kPbc1/vHpjBru7fl9fqMuaUuM/f5ZyoXJMOIrv5BS2gmrwRQ2GfzWgyKgIJ26tb QKBg== 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:mime-version :date:in-reply-to:references:message-id:cc:to:subject:from :dkim-signature:dkim-signature; bh=5jb4sUuCN7HuD6js4ds8mUyrGlXnyKRVCnkhQDb/ce4=; b=RP/vQYlbrGZ4/2NbcSwn0+jjPhcPLV74gaje3PH4+CsHHSUgy/6Cr41tCi/RryIPU2 yLA2chQ7vkyRHklOv2AzTfx3IlSGkZCUQ7au7sYKtNaeAmWiTMqk4f7wngLImPt5/j0Z Sf4xUphT6MFvlB806+kRr6vZDcr5qShGOjTym82oYoJ1KsQKXSC4ftjfI/a8DvwBFdTO Mm8RGPwP6NbblpvKD7XLdiSFzXbmXwfzZxVLTdI+SU5OJwm+Az77WA1KgWxnpvXLYkJo h4E5zKgutEGVU/sd4JmYf4QBy0Qw+NzzhyL5hNd9//Y17liToX/Ow3RqgeN6IbixQOSY V/eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nexedi.com header.s=mandrill header.b=PSp3UPrE; dkim=pass header.i=@mandrillapp.com header.s=mandrill header.b="ANbIMsl/"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j25si25374401pgb.531.2019.04.26.11.36.44; Fri, 26 Apr 2019 11:36:59 -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; dkim=pass header.i=@nexedi.com header.s=mandrill header.b=PSp3UPrE; dkim=pass header.i=@mandrillapp.com header.s=mandrill header.b="ANbIMsl/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbfDZSf0 (ORCPT + 99 others); Fri, 26 Apr 2019 14:35:26 -0400 Received: from mail187-19.suw11.mandrillapp.com ([198.2.187.19]:12365 "EHLO mail187-19.suw11.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbfDZSf0 (ORCPT ); Fri, 26 Apr 2019 14:35:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=mandrill; d=nexedi.com; h=From:Subject:To:Cc:Message-Id:References:In-Reply-To:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; i=kirr@nexedi.com; bh=5jb4sUuCN7HuD6js4ds8mUyrGlXnyKRVCnkhQDb/ce4=; b=PSp3UPrECe/sX7q9+Y2+pNxk+L0tAGMJIIRnc5cgDILgBDcdfXvgXZPYoY8EcfdqcXI2aWjiq/gi bWoh/j4VXkSm1N6CBulHLq7Ur+R1T9+cmu6pmK+KADvz5kbJW+iavhRaJegWFveQeLZ8gnRpCiLb ICvHmbbvPfutnkYBvy4= Received: from pmta01.mandrill.prod.suw01.rsglab.com (127.0.0.1) by mail187-19.suw11.mandrillapp.com id hod7mq174i4r for ; Fri, 26 Apr 2019 18:20:24 +0000 (envelope-from ) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; i=@mandrillapp.com; q=dns/txt; s=mandrill; t=1556302824; h=From : Subject : To : Cc : Message-Id : References : In-Reply-To : Date : MIME-Version : Content-Type : Content-Transfer-Encoding : From : Subject : Date : X-Mandrill-User : List-Unsubscribe; bh=5jb4sUuCN7HuD6js4ds8mUyrGlXnyKRVCnkhQDb/ce4=; b=ANbIMsl/9Ky1KMv9kelgbaM0oj7grCVhgFy7eokRJA5StNTa/17s7uIU0ou+iNzXl/jZcy YFNYv0KyZN8JhCnvyDCHFvNSPUDf26Zz87G5WIIBOMOPOOUqFLPlKHPtSRHU9MVUk1pkprbr 72wJKM6OZZxdK2E+2Hm6PfXAGG8i8= From: Kirill Smelkov Subject: Re: [PATCH AUTOSEL 5.0 59/66] fs: stream_open - opener for stream-like files so that read and write can run simultaneously without deadlock Received: from [87.98.221.171] by mandrillapp.com id ae14908b32de417b8d25a92d1c9a77a2; Fri, 26 Apr 2019 18:20:24 +0000 To: David Laight Cc: Linus Torvalds , Sasha Levin , Greg Kroah-Hartman , Linux List Kernel Mailing , stable , Michael Kerrisk , Yongzhi Pan , Jonathan Corbet , David Vrabel , Juergen Gross , Miklos Szeredi , Tejun Heo , Kirill Tkhai , Arnd Bergmann , Christoph Hellwig , Julia Lawall , Nikolaus Rath , Han-Wen Nienhuys , linux-fsdevel Message-Id: <20190426182014.GA23128@deco.navytux.spb.ru> References: <20190424143341.27665-1-sashal@kernel.org> <20190424143341.27665-59-sashal@kernel.org> <20190424163415.GB21413@kroah.com> <20190424171926.GA17719@sasha-vm> <20190424183012.GB3798@deco.navytux.spb.ru> <4d366f81f90442cb9da7ad393680d004@AcuMS.aculab.com> <20190426074522.GA16247@deco.navytux.spb.ru> <073e5def9e654a1d80cdd79cdcf23361@AcuMS.aculab.com> In-Reply-To: <073e5def9e654a1d80cdd79cdcf23361@AcuMS.aculab.com> X-Report-Abuse: Please forward a copy of this message, including all headers, to abuse@mandrill.com X-Report-Abuse: You can also report abuse here: http://mandrillapp.com/contact/abuse?id=31050260.ae14908b32de417b8d25a92d1c9a77a2 X-Mandrill-User: md_31050260 Date: Fri, 26 Apr 2019 18:20:24 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 26, 2019 at 11:00:01AM +0000, David Laight wrote: > From: Kirill Smelkov > > Sent: 26 April 2019 08:46 > ... > > I'm not sure I understand your comment completely, but we convert to > > stream_open only drivers that actually do _not_ use position at all, and > > that were already using nonseekable_open, thus pread and pwrite were > > already returning -ESPIPE for them (nonseekable_open clears > > FMODE_{PREAD,PWRITE} and ksys_{pread,pwrite}64 check for that flag). We > > also convert only drivers that use no_llseek for .llseek, so lseek > > on those files is/was always returning -ESPIPE as well. > > > > If a driver uses position in its read and write and has support for > > pread/pwrite (FMODE_PREAD and FMODE_PWRITE), pread and pwrite are > > already working _without_ file->f_pos locking - because those system > > calls do not semantically update file->f_pos at all and thus do not take > > file->f_pos_lock - i.e. pread/pwrite can be run simultaneously already. > > Looks like I knew that once :-) > Mind you, 'man pread' on my system is somewhat uninformative. > > Maybe pread() should always be allowed at offset 0. > Then you wouldn't need all this extra logic. I'm not sure I understand. Do you propose any change? If yes - what is the change you are proposing? > > If libc implements pread as lseek+read it will work for a single > > user case (single thread, or fd not shared between processes), but it > > will break because of lseek+read non-atomicity if multiple preads are > > simultaneously used from several threads. And also for such emulation > > for multiple users case there is a chance for pread vs pwrite deadlock, > > since those system calls are using read and write and read and write > > take file->f_pos_lock. > > I'd actually rather the pread() failed to compile. Ok. > The actual implementation did 3 lseek()s (to save and restore the offset). > A user level emulation could usually get away with one lseek().