Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp271245lqs; Tue, 5 Mar 2024 01:15:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWQqwiZjiZU1NJ2vSV5Tx9cPb+CjsDgZIDBQNnJ1Ng2oGVp1DbnTbkNW5P5lngVo43+vE5Vt/7niDZvOok1B2zBFe8+zOIRh30VnzM3+w== X-Google-Smtp-Source: AGHT+IHcUaqLcV8nZr12yS7LMBWOf7USkR/b5s8b+uiqbyt92IoEbAFqhS+TI7jzTnkEWd3CKii5 X-Received: by 2002:a25:abd1:0:b0:dcb:d653:8ad9 with SMTP id v75-20020a25abd1000000b00dcbd6538ad9mr8081759ybi.12.1709630125558; Tue, 05 Mar 2024 01:15:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709630125; cv=pass; d=google.com; s=arc-20160816; b=pVbprk9+SGUtOrU6uiOcIER1DjWub+p43esHjrCPi/8dUYlSherQwf5BRFdKpURdYD PfSbw1EiT8DusWxx8z4/PbGD1eAmJY7BBVa76tfWJpmOedrFsfjwZ0urlsRn7WnfCfJY BQdGDThAYjAHRfkW10jRb9m5T584GsoUoXlz0h6CM4OwdPCiSvVU9d9PdawKsmSp67of w6I3nqLD5A3feqbMx2szA/bR312rgqWhw7x8PWSdqa/U6SoxnTzbKuSNKqzgJ//RTuHj wAManPKWJuTi+Yhj/dvKmZnjZPqc3OK+1VVcWxdvY3/QKZi5FKGYekKmQgKmWqfgCoB8 3scg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=4tRsgiXWNN9mlTyxXmeapNYFeEWm+OEQOBRVCP5FFws=; fh=O78HJmpL5F5vEBJ7fj5QgOSmUhamGk6jv8eSOg+ntqY=; b=qetUP9seJqjXfOptrCG0iRGim7ClPPgRWt3CF8a1wLjJ4XqYTQhj6wF1vmISfvvkYq e0W2VoCRVx4ZaGjz9OhAvd5SZgE/6cbogF1FSFmxLu/LhmwVLBm7NEgi7waFAmVkjmf8 6446OZtcTrlG7ViK0orXA6k8jPaQvt7NgQVwSApbefKZ9Ctl0TvOlZQgldD1enlgtnqP Ni2Chul2Nc6osXnhQR2budpP+vRAa9pgoBOeeI7UhZN1hvdGDHYe7l4xWJL6IqNiY/XT I2+eA24YpDQfNbuuv1q5ncSXD5PN3G8rU5lp8D6/f1reZBxtd8gnPJeLsorfB84hWIxC A6wg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=ucBxdXl8; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-91976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id kd28-20020a056214401c00b0068fa742692asi11490095qvb.577.2024.03.05.01.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 01:15:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=ucBxdXl8; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-91976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4B6241C220C6 for ; Tue, 5 Mar 2024 09:15:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 402D0535BF; Tue, 5 Mar 2024 09:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="ucBxdXl8" Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2968D50272 for ; Tue, 5 Mar 2024 09:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709630104; cv=none; b=I4vH4NYcIj85nVhnDAA7SnO32p2bvKRt50fWs7UU+onEzq8Fvj7g6rOhUY5kga06VwG9vaTFDw2pTbHSCQYRNUahIwkySOxme+mW1VUgO+zpqvsm5XaIWZl8YG438CVv4f+1dC6TvDkfAOSv+W+O+SuNjOeWNSS50AHCF0tqAJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709630104; c=relaxed/simple; bh=CUZK1S/UTm1NptFywhh0dTVAXevwn1WjX6VxrAW5cmY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=lLOaMzM0c+GHebKOmB5QNpsvJ7lW5tkkOyRNfU61ASDCJi3/3t3ERIchvNDpr24Nk0BoDg1SRJKH1vXpDo2Jx3rd7k24exH482aHZIYAtbvi097X/FVLsP0GgxujTkp1ExHzr4ceHGnp2OSJB0MJip9RY0CRso/Skvx/ay2/yNs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=ucBxdXl8; arc=none smtp.client-ip=115.124.30.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1709630094; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=4tRsgiXWNN9mlTyxXmeapNYFeEWm+OEQOBRVCP5FFws=; b=ucBxdXl8CxreHNWnOgqY1MLBj6gxl1ZGVhj+bSiJrdIqII4vNUsbwtiDdFwpg+KylafV1jU1ULLu/AMc6Dg10TnLkZtOOrvxrRqx+sWc1fIo/rTqbaMGOj9MkjfOb6PSCO286x9ZZR6135QpFpmBtNW5U4GLQBV/KZ+BNCCxIhs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0W1tgGeK_1709630089; Received: from e69b19392.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0W1tgGeK_1709630089) by smtp.aliyun-inc.com; Tue, 05 Mar 2024 17:14:54 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH 1/6] erofs: convert z_erofs_onlinepage_.* to folios Date: Tue, 5 Mar 2024 17:14:43 +0800 Message-Id: <20240305091448.1384242-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Online folios are locked file-backed folios which will eventually keep decoded (e.g. decompressed) data of each inode for end users to utilize. It may belong to a few pclusters and contain other data (e.g. compressed data for inplace I/Os) temporarily in a time-sharing manner to reduce memory footprints for low-ended storage devices with high latencies under heary I/O pressure. Apart from folio_end_read() usage, it's a straight-forward conversion. Signed-off-by: Gao Xiang --- Some trivial folio conversions for compressed inodes aiming for v6.9. fs/erofs/zdata.c | 50 +++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index ff0aa72b0db3..5013fcd4965a 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -117,46 +117,39 @@ static inline unsigned int z_erofs_pclusterpages(struct z_erofs_pcluster *pcl) } /* - * bit 30: I/O error occurred on this page - * bit 0 - 29: remaining parts to complete this page + * bit 30: I/O error occurred on this folio + * bit 0 - 29: remaining parts to complete this folio */ -#define Z_EROFS_PAGE_EIO (1 << 30) +#define Z_EROFS_FOLIO_EIO (1 << 30) -static inline void z_erofs_onlinepage_init(struct page *page) +static void z_erofs_onlinefolio_init(struct folio *folio) { union { atomic_t o; - unsigned long v; + void *v; } u = { .o = ATOMIC_INIT(1) }; - set_page_private(page, u.v); - smp_wmb(); - SetPagePrivate(page); + folio->private = u.v; /* valid only if file-backed folio is locked */ } -static inline void z_erofs_onlinepage_split(struct page *page) +static void z_erofs_onlinefolio_split(struct folio *folio) { - atomic_inc((atomic_t *)&page->private); + atomic_inc((atomic_t *)&folio->private); } -static void z_erofs_onlinepage_endio(struct page *page, int err) +static void z_erofs_onlinefolio_end(struct folio *folio, int err) { int orig, v; - DBG_BUGON(!PagePrivate(page)); - do { - orig = atomic_read((atomic_t *)&page->private); - v = (orig - 1) | (err ? Z_EROFS_PAGE_EIO : 0); - } while (atomic_cmpxchg((atomic_t *)&page->private, orig, v) != orig); + orig = atomic_read((atomic_t *)&folio->private); + v = (orig - 1) | (err ? Z_EROFS_FOLIO_EIO : 0); + } while (atomic_cmpxchg((atomic_t *)&folio->private, orig, v) != orig); - if (!(v & ~Z_EROFS_PAGE_EIO)) { - set_page_private(page, 0); - ClearPagePrivate(page); - if (!(v & Z_EROFS_PAGE_EIO)) - SetPageUptodate(page); - unlock_page(page); - } + if (v & ~Z_EROFS_FOLIO_EIO) + return; + folio->private = 0; + folio_end_read(folio, !(v & Z_EROFS_FOLIO_EIO)); } #define Z_EROFS_ONSTACK_PAGES 32 @@ -965,6 +958,7 @@ static int z_erofs_read_fragment(struct super_block *sb, struct page *page, static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, struct page *page, bool ra) { + struct folio *folio = page_folio(page); struct inode *const inode = fe->inode; struct erofs_map_blocks *const map = &fe->map; const loff_t offset = page_offset(page); @@ -973,7 +967,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, unsigned int cur, end, len, split; int err = 0; - z_erofs_onlinepage_init(page); + z_erofs_onlinefolio_init(folio); split = 0; end = PAGE_SIZE; repeat: @@ -1035,7 +1029,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, if (err) goto out; - z_erofs_onlinepage_split(page); + z_erofs_onlinefolio_split(folio); if (fe->pcl->pageofs_out != (map->m_la & ~PAGE_MASK)) fe->pcl->multibases = true; if (fe->pcl->length < offset + end - map->m_la) { @@ -1056,7 +1050,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, goto repeat; out: - z_erofs_onlinepage_endio(page, err); + z_erofs_onlinefolio_end(folio, err); return err; } @@ -1159,7 +1153,7 @@ static void z_erofs_fill_other_copies(struct z_erofs_decompress_backend *be, cur += len; } kunmap_local(dst); - z_erofs_onlinepage_endio(bvi->bvec.page, err); + z_erofs_onlinefolio_end(page_folio(bvi->bvec.page), err); list_del(p); kfree(bvi); } @@ -1316,7 +1310,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, /* recycle all individual short-lived pages */ if (z_erofs_put_shortlivedpage(be->pagepool, page)) continue; - z_erofs_onlinepage_endio(page, err); + z_erofs_onlinefolio_end(page_folio(page), err); } if (be->decompressed_pages != be->onstack_pages) -- 2.39.3