From patchwork Tue Nov 1 17:53:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13027298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EC43C4321E for ; Tue, 1 Nov 2022 17:53:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC0E56B0074; Tue, 1 Nov 2022 13:53:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D4B926B0075; Tue, 1 Nov 2022 13:53:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9CBA6B0078; Tue, 1 Nov 2022 13:53:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A673D6B0074 for ; Tue, 1 Nov 2022 13:53:56 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 67AA91C674D for ; Tue, 1 Nov 2022 17:53:56 +0000 (UTC) X-FDA: 80085621672.18.FBE6560 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf18.hostedemail.com (Postfix) with ESMTP id F07A51C001A for ; Tue, 1 Nov 2022 17:53:55 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id m14-20020a17090a3f8e00b00212dab39bcdso19590650pjc.0 for ; Tue, 01 Nov 2022 10:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gL8HvCZz9dSb2yNioMucyaNDmIRb4Dn4rkrcpThzugo=; b=N/5n/6/dEchQiUPQn4ILuSW0qhF4oGND1gECuxKepZ/5xh2x6iJagwhf8ZnLvpfb5n IVKFjbTElEwjtCFiWWomqbCdrTL3jxyfcNfmRkFWGrNBalcxZUeq4pL1RgDghi9aVAxj /rBag8qMIA8cBJK2PiR1fgcp3PUUBxjs3MRdhBTyQFOs+mWiigk5zpa6U5KKjwZj7AVd x9MjxtqOYf4K134z7WyeIXb9KnKVYNvTDRnTF0yd/edBvbLzTY+UgjSwpPRu6JZ38L0g 9qSW/FKlxyBMVc3RKpBMksYuJpScfFAGLcFavweU4t1PzF4PfCi2CRnmLc+anngs8yRJ bT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gL8HvCZz9dSb2yNioMucyaNDmIRb4Dn4rkrcpThzugo=; b=WZOBbLJH8OdmM7YYXl8Hr2N06+nw7uGUDeyhlWWGz1gZ42zt4hn/356dx3lV1cmdBP 2xamGgc/hiDO4bH+0xn08wiqJtdzyAPIWXRsqvoWL4l53hRqfBHTUo2EG32SOwU2qifv gVScHl9S5nn1CmOr0pxauNmqpUQTdf37rfbC51zMTCk40g/tCh9OTkRq+er7Tc2CknTe FVuhxhFUmx4BkIolgqJhxLeRw3ETGo1kWSrSVcdbYk44buGdS2hT/XEFTo7LiJzobvm1 m0KwOc8takGUDUOTOodmKPYIPTwat49KEYHeNGVH6cPzuAhr5fX1ELMwHDXBuRXj9Asu 9L1Q== X-Gm-Message-State: ACrzQf2afVvI3cn/9f6DFptTd/XMiAX5AFvgb/B8ROacJEUJFVs15cZn 3onyD/IAECpAbqilyU8a9gZq0eC9rjku+g== X-Google-Smtp-Source: AMsMyM6C1f+mV994BjbsV8kHe2UGkzBklv03r5VTJO+o24yiXYT9etxuz+hC6lPxfT1+bQnnM3TC4A== X-Received: by 2002:a17:90b:3b44:b0:213:34f7:facb with SMTP id ot4-20020a17090b3b4400b0021334f7facbmr38966874pjb.150.1667325234783; Tue, 01 Nov 2022 10:53:54 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id e26-20020a056a0000da00b0056b9124d441sm6797987pfj.218.2022.11.01.10.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 10:53:54 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, miklos@szeredi.hu, "Vishal Moola (Oracle)" Subject: [PATCH 2/5] fuse: Convert fuse_try_move_page() to use folios Date: Tue, 1 Nov 2022 10:53:23 -0700 Message-Id: <20221101175326.13265-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221101175326.13265-1-vishal.moola@gmail.com> References: <20221101175326.13265-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667325236; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gL8HvCZz9dSb2yNioMucyaNDmIRb4Dn4rkrcpThzugo=; b=Yyo5HZ1DFml6KDVOhIwq8Csv8C0kLqm7HCS8fK/fJeu3JEvv0aD/y+OOOYJGRWcFv4ylWw sgRJzUTOPLa1r9eyGIUo7H08Z9ZHBYJYLAB+5AwjTLBrhs1HbvtDqMv0MtcRfHlt+8Jmqo 2NCknxv5qwXlIyDXY3GOCV86yYdx5ak= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="N/5n/6/d"; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667325236; a=rsa-sha256; cv=none; b=KGbd5fbcR+zugE4XRXuNNUXwQmbrnepec0II6XfDU8Pom0b6fl7xF7ZiAubrpyChnMH3kI TmB+jdIzSFlevY1e2Naat8Sr6GSJ+0CNZHI2qtGPdjUZMx/zUUYfJz18Vkzmajt+URbW3H Bg2jVnfapo0k6Eznnrwj23Rs8JEd/XI= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: F07A51C001A Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="N/5n/6/d"; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: ogupoeandphbjpc81ctcfrkscrmkq81t X-HE-Tag: 1667325235-9015 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Converts the function to try to move folios instead of pages. Also converts fuse_check_page() to fuse_get_folio() since this is its only caller. This change removes 15 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Miklos Szeredi --- fs/fuse/dev.c | 55 ++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 26817a2db463..204c332cd343 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -764,11 +764,11 @@ static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) return ncpy; } -static int fuse_check_page(struct page *page) +static int fuse_check_folio(struct folio *folio) { - if (page_mapcount(page) || - page->mapping != NULL || - (page->flags & PAGE_FLAGS_CHECK_AT_PREP & + if (folio_mapped(folio) || + folio->mapping != NULL || + (folio->flags & PAGE_FLAGS_CHECK_AT_PREP & ~(1 << PG_locked | 1 << PG_referenced | 1 << PG_uptodate | @@ -778,7 +778,7 @@ static int fuse_check_page(struct page *page) 1 << PG_reclaim | 1 << PG_waiters | LRU_GEN_MASK | LRU_REFS_MASK))) { - dump_page(page, "fuse: trying to steal weird page"); + dump_page(&folio->page, "fuse: trying to steal weird page"); return 1; } return 0; @@ -787,11 +787,11 @@ static int fuse_check_page(struct page *page) static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) { int err; - struct page *oldpage = *pagep; - struct page *newpage; + struct folio *oldfolio = page_folio(*pagep); + struct folio *newfolio; struct pipe_buffer *buf = cs->pipebufs; - get_page(oldpage); + folio_get(oldfolio); err = unlock_request(cs->req); if (err) goto out_put_old; @@ -814,35 +814,36 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) if (!pipe_buf_try_steal(cs->pipe, buf)) goto out_fallback; - newpage = buf->page; + newfolio = page_folio(buf->page); - if (!PageUptodate(newpage)) - SetPageUptodate(newpage); + if (!folio_test_uptodate(newfolio)) + folio_mark_uptodate(newfolio); - ClearPageMappedToDisk(newpage); + folio_clear_mappedtodisk(newfolio); - if (fuse_check_page(newpage) != 0) + if (fuse_check_folio(newfolio) != 0) goto out_fallback_unlock; /* * This is a new and locked page, it shouldn't be mapped or * have any special flags on it */ - if (WARN_ON(page_mapped(oldpage))) + if (WARN_ON(folio_mapped(oldfolio))) goto out_fallback_unlock; - if (WARN_ON(page_has_private(oldpage))) + if (WARN_ON(folio_has_private(oldfolio))) goto out_fallback_unlock; - if (WARN_ON(PageDirty(oldpage) || PageWriteback(oldpage))) + if (WARN_ON(folio_test_dirty(oldfolio) || + folio_test_writeback(oldfolio))) goto out_fallback_unlock; - if (WARN_ON(PageMlocked(oldpage))) + if (WARN_ON(folio_test_mlocked(oldfolio))) goto out_fallback_unlock; - replace_page_cache_folio(page_folio(oldpage), page_folio(newpage)); + replace_page_cache_folio(oldfolio, newfolio); - get_page(newpage); + folio_get(newfolio); if (!(buf->flags & PIPE_BUF_FLAG_LRU)) - lru_cache_add(newpage); + folio_add_lru(newfolio); /* * Release while we have extra ref on stolen page. Otherwise @@ -855,28 +856,28 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) if (test_bit(FR_ABORTED, &cs->req->flags)) err = -ENOENT; else - *pagep = newpage; + *pagep = &newfolio->page; spin_unlock(&cs->req->waitq.lock); if (err) { - unlock_page(newpage); - put_page(newpage); + folio_unlock(newfolio); + folio_put(newfolio); goto out_put_old; } - unlock_page(oldpage); + folio_unlock(oldfolio); /* Drop ref for ap->pages[] array */ - put_page(oldpage); + folio_put(oldfolio); cs->len = 0; err = 0; out_put_old: /* Drop ref obtained in this function */ - put_page(oldpage); + folio_put(oldfolio); return err; out_fallback_unlock: - unlock_page(newpage); + folio_unlock(newfolio); out_fallback: cs->pg = buf->page; cs->offset = buf->offset;