Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1731763ybn; Thu, 26 Sep 2019 01:05:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkAfU88g5OLiqS5rxdTXovgxATsgC3KqGFDAhuHJpzpdxJ0h8bh4Xb6D0KgejKU7LN9CD8 X-Received: by 2002:a17:906:d922:: with SMTP id rn2mr1944831ejb.124.1569485139057; Thu, 26 Sep 2019 01:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569485139; cv=none; d=google.com; s=arc-20160816; b=gIOZyfHZSQiFMw5kJv1J+1Kfoce/IK6ZDXRKuRXIZgFSy3SOeWi4FJbKvmouyMLq3t gQlQru/8Rwmrnram0xk1tAveV4s16ELU9Nhhlq0C5t3YgCoArX+Zpg+M3kE2kzkEdw+P zDYlCabtLTgODhHkkWd4MPrDVLHBvATB5/9NtF7WVftWZGJ9GyPE4UR9av53bP+OcnZR vfBbjc4Wb5baVlWHKfTaM9Zy6CWtiK+rl13gI13xgWvPzLoCHwwp6wnc6hPbHGrC6Ern 5OTJrAV+WeglG609WE3EHr/me9XkldHNJJbLvGuwL21IWVjy89Uwo7np6Dd842yIvDrO HZ5w== 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=gs7h1lCt6Bl6shZa8MyL3dccaWPONANnOJ7iycNQ85U=; b=yC/vQZhdOjShBErng3DjziZd7YsfLSwDdul9JDPXMG8IJnH6ZjsuDvlXSoNZUO4FuQ h1RAh+WBdBajFNm+LyXDtZ+uxTOLkvJLtpWb87uxK4MovjKF1eg/dDEDHwNfXcEi1zbR Rzk+vthKUBsdVfZ+CLqCZI3TMOHPVmqhL/w8gCToGTPv0kg0a7MtNc3QFaHgtrIkbB9V 2u3EedL3XhY+fuyaAvRuxalNX6jOzKw5XyCBAyUAgX4eP4ncEE4wi7E0cIHx31L71WI2 7m1RMhKklJUv9q0E/stdENyK268RVuCRLn5QPLV72+tVenvgJN7d22/nOVvLI9+DwR7y gK4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 w43si875262edd.332.2019.09.26.01.05.14; Thu, 26 Sep 2019 01:05:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440990AbfIXNNa (ORCPT + 99 others); Tue, 24 Sep 2019 09:13:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:46978 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440971AbfIXNNa (ORCPT ); Tue, 24 Sep 2019 09:13:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A7591AE5C; Tue, 24 Sep 2019 13:13:28 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id D51991E4427; Tue, 24 Sep 2019 15:13:43 +0200 (CEST) Date: Tue, 24 Sep 2019 15:13:43 +0200 From: Jan Kara To: Matthew Bobrowski Cc: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, david@fromorbit.com, hch@infradead.org, darrick.wong@oracle.com Subject: Re: [PATCH v3 2/6] ext4: move inode extension/truncate code out from ext4_iomap_end() Message-ID: <20190924131343.GB11819@quack2.suse.cz> References: <784214745d589dd2bdcde2d69a69e837e6980592.1568282664.git.mbobrowski@mbobrowski.org> <20190923162115.GG20367@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190923162115.GG20367@quack2.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 23-09-19 18:21:15, Jan Kara wrote: > On Thu 12-09-19 21:04:00, Matthew Bobrowski wrote: > So I'd just call ext4_handle_inode_extension() unconditionally like: > > error = ext4_handle_inode_extension(inode, offset, ret, len); > > and have a quick check at the beginning of that function to avoid starting > transaction when there isn't anything to do. Something like: > > /* > * DIO and DAX writes get exclusion from truncate (i_rwsem) and > * page writeback (i_rwsem and flushing all dirty pages). > */ > WARN_ON_ONCE(i_size_read(inode) != EXT4_I(inode)->i_disksize); > if (offset + count <= i_size_read(inode)) > return 0; One correction here. With commit 45d8ec4d9fd54 in mind this should be: /* * DIO and DAX writes get exclusion from truncate (i_rwsem). There * can be pending delalloc writeback beyond the range written by * DIO though. */ WARN_ON_ONCE(i_size_read(inode) < EXT4_I(inode)->i_disksize); if (offset + count <= EXT4_I(inode)->i_disksize) return 0; Honza > if (len < 0) > goto truncate; > > ... do the heavylifting with transaction start, inode size update, > and orphan handling... > > if (truncate) { > truncate: > ext4_truncate_failed_write(inode); > orphan_del: > /* > * If the truncate operation failed early the inode > * may still be on the orphan list. In that case, we > * need try remove the inode from the linked list in > * memory. > */ > if (inode->i_nlink) > ext4_orphan_del(NULL, inode); > } -- Jan Kara SUSE Labs, CR