Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp372825ybh; Thu, 12 Mar 2020 03:43:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuPEzq70PCNjDun5CPuOA7NMwvHcLUDrDlyYnvKTLYDduo5U8NKoAQFZa6/Fxqk3e7OvAA5 X-Received: by 2002:a4a:e5c3:: with SMTP id r3mr3530660oov.67.1584009781921; Thu, 12 Mar 2020 03:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584009781; cv=none; d=google.com; s=arc-20160816; b=IAAjws1Wuf0E98mI0/yjatJdggRJc0siNTCHgrSzeNyjLXBmBSiGZKEm4i+o7Bwx7h sqiHDyi6+5L8XZIbWcDGV7dm3vwf13W5RTU5FhoC33UdWh/o3M7DOj6xuW7jCpY4J7di J2O57+V+CrZmczJdrIcBqe2ANYvUmFKWTznXtd5oykqhPiAHfMLgOO3FfDq59ZzoO17/ zcgcj6ny+GyeZxbiVPGC/FusLZczVgrg6Rh+sGIB4yu2yMTrMYwwS2gCRnu/M4y9pKXD kbOUcV/iEVbQCzASsl5s7Z0oblwj/YL6FKTaaoTgFKjsWQdnpRno2Nv7DNsfWeFfJ7ok oUXw== 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=T9nE1zpa5SyJTYwzJjySBplN2q7SLVgJELYct51/pxk=; b=kb8fDbDTADrW4RZ+UBMKrZ5/BeiGJWIsBelGvVzeINHctS2nsZfxWF+UU1/xgA6vNH NY9lEh/oPFKSJdk3EAkCqT/8ExtwfXtO6lOXnY34RIZSR1fT7J0xZwOOugx+Cn+pPYlg yiWVoeNTsi5w7J9hl1hVsnQmOkJRowZdr7mSa0rQQzqBlw4hQC6rugOitQBqIWtESoF+ 0KDjkNXJ10AjNS8zflLNOTAzrTENDI6mmK2EqdVAZtctqajzRlc9ArEJzF1V7Jl/VEXV N6iraXxKuF1Cfz7aw+Vv2Zu7gHXpOXXw02TyDl+4hDWs3SXfixDXOyEO0sB5/9NZgmen 4OMA== 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 u207si2441062oia.176.2020.03.12.03.42.47; Thu, 12 Mar 2020 03:43:01 -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 S1726845AbgCLKmm (ORCPT + 99 others); Thu, 12 Mar 2020 06:42:42 -0400 Received: from verein.lst.de ([213.95.11.211]:36158 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgCLKmm (ORCPT ); Thu, 12 Mar 2020 06:42:42 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 3E5C768C4E; Thu, 12 Mar 2020 11:42:39 +0100 (CET) Date: Thu, 12 Mar 2020 11:42:39 +0100 From: Christoph Hellwig To: David Howells Cc: mbobrowski@mbobrowski.org, darrick.wong@oracle.com, jack@suse.cz, hch@lst.de, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: Is ext4_dio_read_iter() broken? - and xfs_file_dio_aio_read() Message-ID: <20200312104239.GA13235@lst.de> References: <969260.1584004779@warthog.procyon.org.uk> <1015227.1584007677@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1015227.1584007677@warthog.procyon.org.uk> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Mar 12, 2020 at 10:07:57AM +0000, David Howells wrote: > David Howells wrote: > > > Is ext4_dio_read_iter() broken? It calls: > > > > file_accessed(iocb->ki_filp); > > > > at the end of the function - but surely iocb should be expected to have been > > freed when iocb->ki_complete() was called? The iocb is refcounted and only completed when the refcount hits zero, and an extra reference is held until the submission has completed. Take a look at iocb_put(). > I think it's actually worse than that. You also can't call > inode_unlock_shared(inode) because you no longer own a ref on the inode since > ->ki_complete() is expected to call fput() on iocb->ki_filp. the file reference also hold an inode reference. > > Yes, you own a shared lock on it, but unless somewhere along the > fput-dput-iput chain the inode lock is taken exclusively, the inode can be > freed whilst you're still holding the lock. > > Oh - and ext4_dax_read_iter() is also similarly broken. In addition to that DAX never executes asynchronously. > And xfs_file_dio_aio_read() appears to be broken as it touches the inode after > calling iomap_dio_rw() to unlock it. Same as above.