Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3521130pxv; Sun, 4 Jul 2021 22:23:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC7UYf452S6MK2iaZEbZllwFKVXK45O/YCJfNqhzgfEmGP1CzSD7W7hra0bX2FJ26UvqRq X-Received: by 2002:a17:906:5d13:: with SMTP id g19mr12025972ejt.90.1625462612710; Sun, 04 Jul 2021 22:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625462612; cv=none; d=google.com; s=arc-20160816; b=rg0njgdNzSS8U/6q4mF9v5jVVhfG5XZC0Ii3schaTbVTPoZyUKQDteN0b9+CsGPaF9 u0sIUiIM1ldz1uLa3RnN/8v7063juGm3Jk5AXNHLWsBNu6kW0FfEjdfT4HcWHsLiwJ4C 57FO1EyIlFNpGFogcOwbGF2Tw55SghkAC579k3f5nzh/VmtOH9e23McXrKRGIINA+Dq0 nNAp/GaDOtAJ4ycyoOMhwD7OFoAq21mL312+k5Vjo9PRKLVHvtbLrBDZLWESERN9YQOr cOOUGVN9Hjr+umXuJ1dO5iAPTvBu0T55LLH3k0pjCfLI29Tc1f722Xb6clLhwdEhaq5G K0zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HBzNbo+94ovv/kZ+iiMvdunnhXRkT8myUf8Fh0Xeij0=; b=cCo5vpc3axIvN4Ols8vV3/OaVakHlfZ85otMY/EpE2hcxCmfnH5wJ2OKcL49c4wupW t6/8STj80Ob6A9kYDQm7GkObT3bYeu/NEpwmqJ3BUTZaOXqnzJCG0iJ5tVM2sTVUk5lU crOEzX638MMu7DcjWHxVGITK2laSJhsypgPDyHx5y9JyuZPg7JW1B+h2FSOyKWGyifKK aHaVjLQ79kaQwf2E37aqchcH3ed8H+b+Bg0AotgN1qfJr67CfL7lwiYu2x5uZZSUjyBL aHdi7KykqmyZI8CeF/nHJXFeOf2wtYO+HorBJmSL25qXH+9ybcEjGLiniXnDbzS7cw5I fC/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YAPSQ4s6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si12081395ejj.750.2021.07.04.22.23.09; Sun, 04 Jul 2021 22:23:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YAPSQ4s6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbhGEFY5 (ORCPT + 99 others); Mon, 5 Jul 2021 01:24:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:45250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbhGEFY4 (ORCPT ); Mon, 5 Jul 2021 01:24:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95FCA613E2; Mon, 5 Jul 2021 05:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625462539; bh=vZYGv/E1tXW+mr7nAYMJFnoN1LWBW/rm/2P3TYvvKZQ=; h=From:To:Cc:Subject:Date:From; b=YAPSQ4s6aUeWp+YHgh//SLHpLvV6IAKmTv6J8UBd0+XopqffpHHNu64ujbhwrJSDq dAsJP+mw/oB0xMPRpm17y5dyuwcqB0DIRchjgSKPibmSNwfiRrUVU/dOM2+H6/e/Yc qQIOUMVK5vRnhlaPATR9spHrDe2Oa9aUV7XBj2SH1+FlzyrnEZcRuX21HDB4gH6A4a ffrLUb6gXvtB0SVJ666m8RGUW+Ap/G+7WmsSDKlotq8Z3NTC15I0LIBcYV3UV+3wn2 zx7OpPkOTRI8L7jqWSVZgcPQZ5hWJ1r1E1zDG/L2IfWU2PD3J66IdL28XXFrbfgJh6 NHCvh0gYA0yog== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH] f2fs: initialize page->private when using for our internal use Date: Sun, 4 Jul 2021 22:22:16 -0700 Message-Id: <20210705052216.831989-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to guarantee it's initially zero. Otherwise, it'll hurt entire flag operations. Fixes: b763f3bedc2d ("f2fs: restructure f2fs page.private layout") Signed-off-by: Jaegeuk Kim --- fs/f2fs/data.c | 2 ++ fs/f2fs/f2fs.h | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 3a01a1b50104..d2cf48c5a2e4 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3819,6 +3819,8 @@ int f2fs_migrate_page(struct address_space *mapping, get_page(newpage); } + /* guarantee to start from no stale private field */ + set_page_private(newpage, 0); if (PagePrivate(page)) { set_page_private(newpage, page_private(page)); SetPagePrivate(newpage); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 65befc68d88e..ee8eb33e2c25 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1331,7 +1331,8 @@ enum { #define PAGE_PRIVATE_GET_FUNC(name, flagname) \ static inline bool page_private_##name(struct page *page) \ { \ - return test_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)) && \ + return PagePrivate(page) && \ + test_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)) && \ test_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \ } @@ -1341,6 +1342,7 @@ static inline void set_page_private_##name(struct page *page) \ if (!PagePrivate(page)) { \ get_page(page); \ SetPagePrivate(page); \ + set_page_private(page, 0); \ } \ set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)); \ set_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \ @@ -1392,6 +1394,7 @@ static inline void set_page_private_data(struct page *page, unsigned long data) if (!PagePrivate(page)) { get_page(page); SetPagePrivate(page); + set_page_private(page, 0); } set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)); page_private(page) |= data << PAGE_PRIVATE_MAX; -- 2.32.0.93.g670b81a890-goog