Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3632141pxv; Mon, 5 Jul 2021 01:58:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUNU0jANMq2C0DDH7OC++28iwkMHtwrZcxoA9Qs0XUIpvIPKg3dwMNlzXMHzURLzEg2yqL X-Received: by 2002:a17:907:2be7:: with SMTP id gv39mr12464691ejc.179.1625475501258; Mon, 05 Jul 2021 01:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625475501; cv=none; d=google.com; s=arc-20160816; b=Mjd3eTZ0RdKaea7Ya2shw0y0TklTjYEmN7lzQFUNCt4NKYD1IzvdrSKZdEVu9D46/B ZanKGrMSxCWebx5PhsDOrL0fnD2oTOsKCeb7HEsw1hasPvmWqZ9CNmFuVAlaAQwcr4g4 mwUMlo7BoBsAURieOjz5bP6ig/LE2dX0c82WW7DAM5pYKtownf2bx1aQOMKkY8Bq2yVN emwbuQByHXIUkbu0V4Xr+xGUomRvpA+aYKG+2K654fuMl0KB+55TQz02EkpYAHBoWjhp 2QvEVcGYCpc4ohbve/0j5LCvWN4KadYHIR4tJO8QqfxHCdA881OWBDJijQOd/F1RHVpF fiKw== 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=adsLoZYjyZMopXg1uCR2q4bhXinCptCX4JfdkoNW2SQ=; b=lEQuwq0IrF43FMOkHvYisatbD9zzFG/NRN7QwrR9VYz1tr3T153QWB718gUUCkFis/ iB2tOtbVYM5ucwnnmGMROHq+Rdg3yQDCJCPjvx/gYr0naG+u8G3Rj+tiyoB5VJQ3GC/c l4NeavAGLP5TF38yBh/nDCYsKdlJ7lpjLIVzXAnzHowlzgNLY/zwGBMe8m7MrGd+sjG5 dL18+HolIPG74os3Dcjfl50vL71x3gUVDkM02zSbdEHfbVhMwupzwmigDU3h9A2enNAf 39eVY/bQjNOzWJpsbr6o5nnH5BUbsPgphtAlxHqpGbNTHu4U0zaJ81w8La3XHQe3kW2f yBQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FDMrGP9j; 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 q18si13138215edi.63.2021.07.05.01.57.58; Mon, 05 Jul 2021 01:58:21 -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=FDMrGP9j; 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 S230196AbhGEI7i (ORCPT + 99 others); Mon, 5 Jul 2021 04:59:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:47784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230121AbhGEI7h (ORCPT ); Mon, 5 Jul 2021 04:59:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 765A1613C2; Mon, 5 Jul 2021 08:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625475420; bh=ZqjV6RrWkA7theMbsvZ8YZrCke0QXHtvRo3wcNk+Upk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FDMrGP9js/MZtQ/Ho77/c6GRBbjraVZgGhojOtutaYSGt24I4xbHtiq1lif8985y9 XFWGS7NOy5jhd8Ot4wjbzr9tWMk8qrleglrNJ/64p3/DDMB+05wlcmIXbsJ+eJAOkT sv6KEaC2gujt5FpQCFWRUp2t1+OLRgP0XKZk8ZrqrtQsbna8/f1UPK+6ZWjUBaFT4B bNMbqjxNUSWacN04vI3t/lt4l0zLx4ZUwygD1usCRyMkVNeWLkvpOcsg7LLJl3sGs9 mAnQNtddAWQyjQNOdcAPCe0j71nwQzvi0o0t/uVdc+6nfc71Na0r0rQeOFKQG8QXPe DVrsLbBs3zfiw== Date: Mon, 5 Jul 2021 01:56:59 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Matthew Wilcox Subject: Re: [f2fs-dev] [PATCH] f2fs: initialize page->private when using for our internal use Message-ID: References: <20210705052216.831989-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/05, Chao Yu wrote: > On 2021/7/5 13:22, Jaegeuk Kim wrote: > > We need to guarantee it's initially zero. Otherwise, it'll hurt entire flag > > operations. > > Oops, I didn't get the point, shouldn't .private be zero after page was > just allocated by filesystem? What's the case we will encounter stall > private data left in page? I'm seeing f2fs_migrate_page() has the newpage with some value without Private flag. That causes a kernel panic later due to wrong private flag used in f2fs. > > Cc Matthew Wilcox. > > Thanks, > > > > > 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; > >