From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19745C4320A for ; Fri, 23 Jul 2021 01:52:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E89DE60ED3 for ; Fri, 23 Jul 2021 01:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233135AbhGWBMA (ORCPT ); Thu, 22 Jul 2021 21:12:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:58554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230318AbhGWBMA (ORCPT ); Thu, 22 Jul 2021 21:12:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D60160E9A; Fri, 23 Jul 2021 01:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627005154; bh=dubo8niTm2fAph2AV70T+l7jUyaRlEBWVCODXsuymHs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c8rOmcNFq6dVUMpNu9SxM6DzJMyst3LN3ufi73N+zsM7d12ZgHatlfR7cgZ/fy0i6 UkMx1ZSt2deeQV/WhcR3DmQ1tFmA88bh+/5HsYEUO0L/tKgbq4e6h1vdz6cHl6Sg4Y UByeKuoFIh2LBpzC40H7E8cedR/pY8VLEbmWPQajXI5cJU7TbYNSb5fEfWRIAOXCu5 4B4AtgfcgElSc+jmbP1Ru4A9jvHlT+sEvOXG1Up4bKSCww3RphljdQeES5GWl9h401 Mi+4O0r6VI4rlaFlY/bu7iGQtLRd/rXRLsqJzof8eGgNg1u8d843jzSDIm9nAlr/Ev cJqgvM0mTz49Q== Date: Thu, 22 Jul 2021 18:52:33 -0700 From: Eric Biggers To: Christoph Hellwig Cc: linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , Chao Yu , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, Satya Tangirala , Changheun Lee , Matthew Bobrowski Subject: Re: [PATCH 6/9] f2fs: implement iomap operations Message-ID: References: <20210716143919.44373-1-ebiggers@kernel.org> <20210716143919.44373-7-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Hi Christoph, On Mon, Jul 19, 2021 at 10:59:10AM +0200, Christoph Hellwig wrote: > On Fri, Jul 16, 2021 at 09:39:16AM -0500, Eric Biggers wrote: > > +static blk_qc_t f2fs_dio_submit_bio(struct inode *inode, struct iomap *iomap, > > + struct bio *bio, loff_t file_offset) > > +{ > > + struct f2fs_private_dio *dio; > > + bool write = (bio_op(bio) == REQ_OP_WRITE); > > + > > + dio = f2fs_kzalloc(F2FS_I_SB(inode), > > + sizeof(struct f2fs_private_dio), GFP_NOFS); > > + if (!dio) > > + goto out; > > + > > + dio->inode = inode; > > + dio->orig_end_io = bio->bi_end_io; > > + dio->orig_private = bio->bi_private; > > + dio->write = write; > > + > > + bio->bi_end_io = f2fs_dio_end_io; > > + bio->bi_private = dio; > > + > > + inc_page_count(F2FS_I_SB(inode), > > + write ? F2FS_DIO_WRITE : F2FS_DIO_READ); > > + > > + return submit_bio(bio); > > I don't think there is any need for this mess. The F2FS_DIO_WRITE / > F2FS_DIO_READ counts are only used to check if there is any inflight > I/O at all. So instead we can increment them once before calling > iomap_dio_rw, and decrement them in ->end_io or for a failure/noop > exit from iomap_dio_rw. Untested patch below. Note that all this > would be much simpler to review if the last three patches were folded > into a single one. > I am trying to do this, but unfortunately I don't see a way to make it work correctly in all cases. The main problem is that when iomap_dio_rw() returns an error (other than -EIOCBQUEUED), there is no way to know whether ->end_io() has been called or not. This is because iomap_dio_rw() can fail either early, before "starting" the I/O (in which case ->end_io() won't have been called), or later, after "starting" the I/O (in which case ->end_io() will have been called). Note that this can't be worked around by checking whether the iov_iter has been advanced or not, since a failure could occur between "starting" the I/O and the iov_iter being advanced for the first time. Would you be receptive to adding a ->begin_io() callback to struct iomap_dio_ops in order to allow filesystems to maintain counters like this? Either way, given the problem here, I think I should leave this out of the initial conversion and just do a dumb translation of the existing f2fs logic to start with, like I have in this patch. - Eric From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7859C4338F for ; Fri, 23 Jul 2021 01:52:49 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6CD7A60E9A for ; Fri, 23 Jul 2021 01:52:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6CD7A60E9A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1m6kMp-0004pN-Tu; Fri, 23 Jul 2021 01:52:47 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6kMo-0004pD-C5 for linux-f2fs-devel@lists.sourceforge.net; Fri, 23 Jul 2021 01:52:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=A65beS4JXUYlPHrYbyfXEa22bq9Y8ieWNVimOMdFqaw=; b=clhcABZNkRGLAwvL2DutArfFhU 7D5DlCEZRBcmfy9F4ZusRXUMVuDJR0SzEWaSydSqFHH+f31821JuoZ1aW1McBHu7ri1LX9bMFTmiZ mU5WzCV8Plpeo2/45i7yExM31T7bLzpwMt+otASUr1//j8u9/ZZuact+6XgItzag3S0I=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=A65beS4JXUYlPHrYbyfXEa22bq9Y8ieWNVimOMdFqaw=; b=doM8l1Es5mQlU6AoeMF+H9nsZS F3wsMXX3GZh3EZGPAgb6uzWph2IyayXKvY8l3b+WZyOaNl/eD7u/GoHfTCj7gVJAW981z1oupKDzW IkTFJF5yciqiWt7ZMXkU4at55WoDQLhrjs4IqpG4eTPgM2TGJI1qyWRWHyRmvm4JBDso=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1m6kMn-0007Zv-4M for linux-f2fs-devel@lists.sourceforge.net; Fri, 23 Jul 2021 01:52:46 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D60160E9A; Fri, 23 Jul 2021 01:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627005154; bh=dubo8niTm2fAph2AV70T+l7jUyaRlEBWVCODXsuymHs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c8rOmcNFq6dVUMpNu9SxM6DzJMyst3LN3ufi73N+zsM7d12ZgHatlfR7cgZ/fy0i6 UkMx1ZSt2deeQV/WhcR3DmQ1tFmA88bh+/5HsYEUO0L/tKgbq4e6h1vdz6cHl6Sg4Y UByeKuoFIh2LBpzC40H7E8cedR/pY8VLEbmWPQajXI5cJU7TbYNSb5fEfWRIAOXCu5 4B4AtgfcgElSc+jmbP1Ru4A9jvHlT+sEvOXG1Up4bKSCww3RphljdQeES5GWl9h401 Mi+4O0r6VI4rlaFlY/bu7iGQtLRd/rXRLsqJzof8eGgNg1u8d843jzSDIm9nAlr/Ev cJqgvM0mTz49Q== Date: Thu, 22 Jul 2021 18:52:33 -0700 From: Eric Biggers To: Christoph Hellwig Message-ID: References: <20210716143919.44373-1-ebiggers@kernel.org> <20210716143919.44373-7-ebiggers@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1m6kMn-0007Zv-4M Subject: Re: [f2fs-dev] [PATCH 6/9] f2fs: implement iomap operations X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Satya Tangirala , linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, Matthew Bobrowski , Changheun Lee , linux-fsdevel@vger.kernel.org, Jaegeuk Kim Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Hi Christoph, On Mon, Jul 19, 2021 at 10:59:10AM +0200, Christoph Hellwig wrote: > On Fri, Jul 16, 2021 at 09:39:16AM -0500, Eric Biggers wrote: > > +static blk_qc_t f2fs_dio_submit_bio(struct inode *inode, struct iomap *iomap, > > + struct bio *bio, loff_t file_offset) > > +{ > > + struct f2fs_private_dio *dio; > > + bool write = (bio_op(bio) == REQ_OP_WRITE); > > + > > + dio = f2fs_kzalloc(F2FS_I_SB(inode), > > + sizeof(struct f2fs_private_dio), GFP_NOFS); > > + if (!dio) > > + goto out; > > + > > + dio->inode = inode; > > + dio->orig_end_io = bio->bi_end_io; > > + dio->orig_private = bio->bi_private; > > + dio->write = write; > > + > > + bio->bi_end_io = f2fs_dio_end_io; > > + bio->bi_private = dio; > > + > > + inc_page_count(F2FS_I_SB(inode), > > + write ? F2FS_DIO_WRITE : F2FS_DIO_READ); > > + > > + return submit_bio(bio); > > I don't think there is any need for this mess. The F2FS_DIO_WRITE / > F2FS_DIO_READ counts are only used to check if there is any inflight > I/O at all. So instead we can increment them once before calling > iomap_dio_rw, and decrement them in ->end_io or for a failure/noop > exit from iomap_dio_rw. Untested patch below. Note that all this > would be much simpler to review if the last three patches were folded > into a single one. > I am trying to do this, but unfortunately I don't see a way to make it work correctly in all cases. The main problem is that when iomap_dio_rw() returns an error (other than -EIOCBQUEUED), there is no way to know whether ->end_io() has been called or not. This is because iomap_dio_rw() can fail either early, before "starting" the I/O (in which case ->end_io() won't have been called), or later, after "starting" the I/O (in which case ->end_io() will have been called). Note that this can't be worked around by checking whether the iov_iter has been advanced or not, since a failure could occur between "starting" the I/O and the iov_iter being advanced for the first time. Would you be receptive to adding a ->begin_io() callback to struct iomap_dio_ops in order to allow filesystems to maintain counters like this? Either way, given the problem here, I think I should leave this out of the initial conversion and just do a dumb translation of the existing f2fs logic to start with, like I have in this patch. - Eric _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel