Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp957064rwp; Thu, 13 Jul 2023 04:04:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXNSY78Vln6Mrniv8B5VuNk/XJZ0ur8ywGj2GbiAeAhcW9fuohK+HMlgnLlgkCliuF49jI X-Received: by 2002:a17:906:7681:b0:98e:2334:af12 with SMTP id o1-20020a170906768100b0098e2334af12mr1176505ejm.45.1689246273999; Thu, 13 Jul 2023 04:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689246273; cv=none; d=google.com; s=arc-20160816; b=w1iLeDd1YDeRF1ZBQEa30oYy5Gtz7hrygUhOmkLEpAreQTKx2JhwLIbnq1sPODg/Iy Npf9n/4spgdZmt1nl4s54DiImpm7Dk0gcwlqUbqwKOGWIK8WUZqm6SHp7DCD/XvYU6Lz 2UTe0TOeAJgFxjRRSPnwDTyD6Ku09ncWpIwm0kYYCEnhxKS6fpF5/2u3/jxvsPUGYmSt MzGimtannuq/o+lRyd4VpMkZmfco9lbvVWy6/rSUFBUR0BnGOa6C1Kl2hhTFTn1UbQKt Nv0zVEycPEbLWLqhugejgMByuCOCSGiwZXwh2m1+hzBnGoSMe0jtEjxfNMLYTb4+tjUy XmIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :in-reply-to:from:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=s29oTsNdA6AOkv2q7awRhtrV4xQfy49uD8Iv+7noKLo=; fh=RxLfTW1ihKpzaC8f4c5QU7q8ThGVDxP4hWR0XfG2vl8=; b=bGfFEk9UrxssK9LHQ4kClWHgkDuCIUreph4oXdkxKGOwFCxG4IvTfI5jRuYnfE+Ujk 78plQ7CvFgNQXND4C6WKygQjxlEGn4vRp2fGZhSgGAVl5Y8Ff0nilnFiz4UmGiWFeGyt 1m+I3ALBqXM2YHeKnQAn5g7LPax38JEg0Qmlw9BFNyVdoCeHNlSR/zkoaOiXdKWHzH9z kIO35FtlQ6NM2V6ZKelbrJVAPP+dFsdClrhLYE2VLKtuvgybIr+n9+dvbi5YCFNJxaFW /1KvoKJjkemFiqJ6hyb9bv+WgxEFmD86eowOy5jjsM88jfgW+m8Xg3p20oXgxmiPbkmv ndFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=J3FNiRzh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id op10-20020a170906bcea00b00991f9e2a81asi7431803ejb.238.2023.07.13.04.04.04; Thu, 13 Jul 2023 04:04:33 -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=@samsung.com header.s=mail20170921 header.b=J3FNiRzh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233106AbjGMKgL (ORCPT + 99 others); Thu, 13 Jul 2023 06:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231431AbjGMKgK (ORCPT ); Thu, 13 Jul 2023 06:36:10 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A56119 for ; Thu, 13 Jul 2023 03:36:07 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230713103604euoutp02d3a47f76f086b08d5cb9bc802d5d3acb~xZvtVt8A_2199621996euoutp02o for ; Thu, 13 Jul 2023 10:36:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230713103604euoutp02d3a47f76f086b08d5cb9bc802d5d3acb~xZvtVt8A_2199621996euoutp02o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1689244564; bh=s29oTsNdA6AOkv2q7awRhtrV4xQfy49uD8Iv+7noKLo=; h=Date:Subject:To:CC:From:In-Reply-To:References:From; b=J3FNiRzh2iFHbOc+bqt55NPNz9PTjf3fpcVkcHIJReVXY5p8Z40+/iSRBrSwj+i5F pZLzVUxR1Ip37zAWXX55HuFbPVlpqA4lCK+38Yo+p30xz/dSV54Zr0UZqssMKr/3I9 3/hKcafPJ+HpKS9r2omm523Qw7l/sM2OLClRfC7I= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230713103604eucas1p2c7e041a3db554075210f4d4a7c04a058~xZvtIIddm2639826398eucas1p2i; Thu, 13 Jul 2023 10:36:04 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 13.C5.42423.493DFA46; Thu, 13 Jul 2023 11:36:04 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230713103604eucas1p227fd0734b3629e0c8a1f1175f4d083ea~xZvs1Uoq12654826548eucas1p20; Thu, 13 Jul 2023 10:36:04 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230713103604eusmtrp29e662ff3dacf6a3d660c130f13c99b77~xZvs0pQ7z1997719977eusmtrp2H; Thu, 13 Jul 2023 10:36:04 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-ed-64afd394af49 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 60.ED.10549.493DFA46; Thu, 13 Jul 2023 11:36:04 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230713103604eusmtip1659a0783f2ce26b5c68558330b5cb864~xZvsopOEW1235012350eusmtip1X; Thu, 13 Jul 2023 10:36:04 +0000 (GMT) Received: from [106.110.32.65] (106.110.32.65) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 13 Jul 2023 11:36:03 +0100 Message-ID: <98e30ed3-e9b1-2869-b31e-32b099ef3865@samsung.com> Date: Thu, 13 Jul 2023 12:36:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 3/7] affs: Convert data read and write to use folios Content-Language: en-US To: "Matthew Wilcox (Oracle)" , Andrew Morton CC: David Sterba , , Konstantin Komarov , , Theodore Tso , Jan Kara , From: Pankaj Raghav In-Reply-To: <20230713035512.4139457-4-willy@infradead.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [106.110.32.65] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA02SfUhTYRTGe3fv7u4G2m2mniyKVkbNtCSNW6ZYFo2gspSK/COH3pY1dWwz tehjYV9TMi0xl5UmlVa0cEtbNWSLrJVEn7aZYX6hs8RSk+lSc14D//u9z3kOPM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230713103604eucas1p227fd0734b3629e0c8a1f1175f4d083ea X-Msg-Generator: CA X-RootMTR: 20230713035542eucas1p2cbb80eae0876527c2ba3d5b7dc46c906 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230713035542eucas1p2cbb80eae0876527c2ba3d5b7dc46c906 References: <20230713035512.4139457-1-willy@infradead.org> <20230713035512.4139457-4-willy@infradead.org> X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 2023-07-13 05:55, Matthew Wilcox (Oracle) wrote: > We still need to convert to/from folios in write_begin & write_end > to fit the API, but this removes a lot of calls to old page-based > functions, removing many hidden calls to compound_head(). > > Signed-off-by: Matthew Wilcox (Oracle) Looks good to me except one minor nit! Reviewed-by: Pankaj Raghav > @@ -624,25 +623,23 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize) > return PTR_ERR(bh); > } > > -static int > -affs_read_folio_ofs(struct file *file, struct folio *folio) > +static int affs_read_folio_ofs(struct file *file, struct folio *folio) > { > - struct page *page = &folio->page; > - struct inode *inode = page->mapping->host; > - u32 to; > + struct inode *inode = folio->mapping->host; > + size_t to; > int err; > > - pr_debug("%s(%lu, %ld)\n", __func__, inode->i_ino, page->index); > - to = PAGE_SIZE; > - if (((page->index + 1) << PAGE_SHIFT) > inode->i_size) { > - to = inode->i_size & ~PAGE_MASK; > - memset(page_address(page) + to, 0, PAGE_SIZE - to); > + pr_debug("%s(%lu, %ld)\n", __func__, inode->i_ino, folio->index); > + to = folio_size(folio); > + if (folio_pos(folio) + to > inode->i_size) { > + to = inode->i_size - folio_pos(folio); > + folio_zero_segment(folio, to, folio_size(folio)); This change makes the code more readable! > } > > - err = affs_do_readpage_ofs(page, to, 0); > + err = affs_do_read_folio_ofs(folio, to, 0); > if (!err) > @@ -688,6 +686,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, > loff_t pos, unsigned len, unsigned copied, > struct page *page, void *fsdata) > { > + struct folio *folio = page_folio(page); > struct inode *inode = mapping->host; > struct super_block *sb = inode->i_sb; > struct buffer_head *bh, *prev_bh; > @@ -701,18 +700,18 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, > to = from + len; > /* > * XXX: not sure if this can handle short copies (len < copied), but > - * we don't have to, because the page should always be uptodate here, > + * we don't have to, because the folio should always be uptodate here, > * due to write_begin. > */ > > pr_debug("%s(%lu, %llu, %llu)\n", __func__, inode->i_ino, pos, > pos + len); > bsize = AFFS_SB(sb)->s_data_blksize; > - data = page_address(page); > + data = folio_address(folio); > > bh = NULL; > written = 0; > - tmp = (page->index << PAGE_SHIFT) + from; > + tmp = (folio->index << PAGE_SHIFT) + from; Can this be made to: tmp = folio_pos(folio) + from; Similar to what is being done in affs_do_read_folio_ofs() > bidx = tmp / bsize; > boff = tmp % bsize; > if (boff) { > @@ -804,11 +803,11 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, > from += tmp; > bidx++; > } > - SetPageUptodate(page); > + folio_mark_uptodate(folio); > > done: > affs_brelse(bh); > - tmp = (page->index << PAGE_SHIFT) + from; > + tmp = (folio->index << PAGE_SHIFT) + from; Same as the previous comment. > if (tmp > inode->i_size) > inode->i_size = AFFS_I(inode)->mmu_private = tmp; > > @@ -819,8 +818,8 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, > } > > err_first_bh: > - unlock_page(page); > - put_page(page); > + folio_unlock(folio); > + folio_put(folio); > > return written; >