Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1189912pxk; Fri, 18 Sep 2020 06:17:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDt3S5BbFtvK0Yk5uDP4f/ABNxqA+L5hh5bWrIlQydd3X7M/hHADrpvCkxOGh+1B9++Yki X-Received: by 2002:a17:906:c1c3:: with SMTP id bw3mr35325976ejb.516.1600435036608; Fri, 18 Sep 2020 06:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600435036; cv=none; d=google.com; s=arc-20160816; b=sogDp59J2/UH0dzdMfg0eWC1jeX24WL4zGbJ8824KTZSBn8zhNhv+df2YVrWLCx6uc 4gBtDxlFvqmU5ZloeFakoSoffEUesmnv32ZjNmmUIPZtdw9CyVOlMEpXPBBqiTg3LjNY xInt5Ur1ILHpb4/v7YQN0N8K9V+zKMO4aiQINXPuC+EfkPQfQtXphugC2NDkPaacHEez wDQZAgwYe9D+JvJ+ZyzR4fHR+T4cxejjpOkhQ41r29GzOlmHtz2w1TQV5ez+lLpktbPX yfpcq763VbXKPmsZpfOngk229brVDofL0WeqZwjkSjcGwqQEONwSewtde3JfRuXkTaD3 lW7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=6pcfAtRnWbAcOPaHfD3rsmHNs9cLL8YbPKn/xhVYAo8=; b=NLe1g21ZWM1ga1m8OfdxPtPnpWgC3SPvGLWkExphz62xuEc2SNEKK79qHFIToymfb3 xql7t6TmfQ9424g87SaSyn+RR4V9+dI46jAPRNGRyDtG8+624HoBDgZso1UGc/u7zlUg dEhYVnTvrdKlZi4iRqi5XEHvzYIRxRIE8JcoqDXFymBCWXJY1EZGIA8jvO779NY9+GDY PQZEcFoFJBK+WKv8I6cCrx6uIm3E13gSmU2GAR0wPgnyGT9BUXSy8fuKA8N8+sBD9aXF UPM8r8DNPjM38ZOQZPuRO5O+4lMXl9bHkF6aLiUbYBsw/KFZ9kfuRzW4BiSUQQFFCZV0 5Lew== ARC-Authentication-Results: i=1; mx.google.com; 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 ga5si2639960ejb.547.2020.09.18.06.16.53; Fri, 18 Sep 2020 06:17:16 -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; 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 S1726697AbgIRNNV (ORCPT + 99 others); Fri, 18 Sep 2020 09:13:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:39982 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbgIRNNT (ORCPT ); Fri, 18 Sep 2020 09:13:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2A077ABF4; Fri, 18 Sep 2020 13:13:52 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id ABB001E12E1; Fri, 18 Sep 2020 15:13:17 +0200 (CEST) Date: Fri, 18 Sep 2020 15:13:17 +0200 From: Jan Kara To: Mikulas Patocka Cc: Dan Williams , Linus Torvalds , Alexander Viro , Andrew Morton , Matthew Wilcox , Jan Kara , Eric Sandeen , Dave Chinner , Linux Kernel Mailing List , linux-fsdevel Subject: Re: the "read" syscall sees partial effects of the "write" syscall Message-ID: <20200918131317.GH18920@quack2.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 18-09-20 08:25:28, Mikulas Patocka wrote: > I'd like to ask about this problem: when we write to a file, the kernel > takes the write inode lock. When we read from a file, no lock is taken - > thus the read syscall can read data that are halfway modified by the write > syscall. > > The standard specifies the effects of the write syscall are atomic - see > this: > https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_07 Yes, but no Linux filesystem (except for XFS AFAIK) follows the POSIX spec in this regard. Mostly because the mixed read-write performance sucks when you follow it (not that it would absolutely have to suck - you can use clever locking with range locks but nobody does it currently). In practice, the read-write atomicity works on Linux only on per-page basis for buffered IO. Honza -- Jan Kara SUSE Labs, CR