Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5041694rwl; Mon, 10 Apr 2023 22:48:47 -0700 (PDT) X-Google-Smtp-Source: AKy350Z2ISTBWG4xF5biffpRlWNiyqeyEYgiGHRXLlJTjXf9YlYlLrW1nAY2bJt8mTQdActzjbf9 X-Received: by 2002:a17:906:3b84:b0:94a:8b35:f15d with SMTP id u4-20020a1709063b8400b0094a8b35f15dmr5850535ejf.45.1681192126947; Mon, 10 Apr 2023 22:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681192126; cv=none; d=google.com; s=arc-20160816; b=O+4Dun+Fbs+vjvdFaWPQkvPWbpy+qV9d27GjlWrDs6T2cjxG13w8S1ZPGvaPgV9+wj v9Mt8VQBbjAoTyYyZhpIX73dUKYLNyDiYtCZubPE0QsElPmlUza26C1H5vpSyp1e97ag YfYvB764p94mX/sy42u03bhZIleB8WAE5+zfIKBIrWX3RRu9l6crkjBFDK0aj/yMtFx5 y1aQrxwcn2gigxdL5R72BJTmLbxYvbueEno4o+e/zVr9SfnSDNLeCGWKM+w/eSj7AtOq k888tyvTcDDChv1lnv1QlFHXa7+3oLkJRix8qTEToMS2mF6aOe/FyUAmWxvXdljwDPBR Sarw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nvM8pxlJ1Talzo7VMGNpTDLLNruDc+YtSG3z16ERgm0=; b=SG/KdQzZSyHqJBVz90cV1CgDEg0oORwJjmu2qpgFj6htKNm57yhFRO3QCBr0eO5M9D 7QCVIxolHLfZwCg3p+efsFAVOOxogLYGT3KLUBEWdB+OR/Ce4AEh6sn0xw4EJfooQHO5 dYw9cWtQjByQQXraS3JmHMt8g2kEavSCnWB8n4rG4LWSCmpPPP5BWgS4SvUh6Cw0DrPZ 8KxnDpUM6ju6DPf4VZ+HX6k327qWW/AH7rw7KYsZrMlI4JJAZpxFPOgxBaJhaMtx4aEe O5c4YZWkkuG/RFeiyHtesj1Htbna9BDcvC9uT0rvHMQqCq/KFZ9FjAEQaSQfCuUrsreI 24DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="G82AJC/O"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x19-20020a170906299300b0094a5bf5b1f5si5677560eje.600.2023.04.10.22.48.22; Mon, 10 Apr 2023 22:48:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="G82AJC/O"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229888AbjDKFqd (ORCPT + 99 others); Tue, 11 Apr 2023 01:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbjDKFqV (ORCPT ); Tue, 11 Apr 2023 01:46:21 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD14131; Mon, 10 Apr 2023 22:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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; bh=nvM8pxlJ1Talzo7VMGNpTDLLNruDc+YtSG3z16ERgm0=; b=G82AJC/Oflgo3gckIbFm9SimSb f7YVW22exExmG83ZxkZ6mojVaNLSrH5mi/H4JhtqlYcEEy8PiHmCs5r6rOocgZCD/foZDMtc0tTyu SPK0dVCHM1wKBDJTCycUZfwuSikd+YSlmS+6/rFm2DszSYu6ssNkhTJQ039SSqGCLZA+vPFDzjFH8 6n/abYJ9TVgO+S0erkwSzqIjxTayhnogluLWnNA0CXOZgvJaRzBr7gAl7BxbA2OelGzf7/m2EK6mX SDLpIwp014Ypq1+44YXuomXq8TYIlFOiwiuglGVGrFTQLxUszBpcHNo0HQIW+eh140DkPrNpqjY+c U5PyNa1Q==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pm6pY-00GUhW-08; Tue, 11 Apr 2023 05:46:12 +0000 Date: Mon, 10 Apr 2023 22:46:12 -0700 From: Christoph Hellwig To: "Ritesh Harjani (IBM)" Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Jan Kara , Christoph Hellwig , "Darrick J . Wong" , Ojaswin Mujoo Subject: Re: [RFCv2 5/8] ext2: Move direct-io to use iomap Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Apr 11, 2023 at 10:51:53AM +0530, Ritesh Harjani (IBM) wrote: > +extern void ext2_write_failed(struct address_space *mapping, loff_t to); No need for the extern. > + /* handle case for partial write and for fallback to buffered write */ > + if (ret >= 0 && iov_iter_count(from)) { > + loff_t pos, endbyte; > + ssize_t status; > + int ret2; > + > + iocb->ki_flags &= ~IOCB_DIRECT; > + pos = iocb->ki_pos; > + status = generic_perform_write(iocb, from); > + if (unlikely(status < 0)) { > + ret = status; > + goto out_unlock; > + } > + > + iocb->ki_pos += status; > + ret += status; > + endbyte = pos + status - 1; > + ret2 = filemap_write_and_wait_range(inode->i_mapping, pos, > + endbyte); > + if (!ret2) > + invalidate_mapping_pages(inode->i_mapping, > + pos >> PAGE_SHIFT, > + endbyte >> PAGE_SHIFT); > + if (ret > 0) > + generic_write_sync(iocb, ret); > + } Nit, but to me it would seem cleaner if all the fallback handling was moved into a separate helper function. Or in fact by not using generic_file_write_iter even for buffered I/O and at doing the pre-I/O checks and the final generic_write_sync in common code in ext2 for direct and buffered I/O. > + /* > + * For writes that could fill holes inside i_size on a > + * DIO_SKIP_HOLES filesystem we forbid block creations: only > + * overwrites are permitted. > + */ > + if ((flags & IOMAP_DIRECT) && (first_block << blkbits < i_size_read(inode))) > + create = 0; No need for braes around the < operation, but I think you might need them around the shift. Also an overly long line here. > + if ((flags & IOMAP_WRITE) && (offset + length > i_size_read(inode))) No need for the second set of inner braces here either.