Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3736035pxv; Mon, 5 Jul 2021 04:35:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7sBFDAOc3uf19nTrYWB6ZuGWaa//PcxGW6IlohUwRDSs2I6zW+5VuTlmk9KuovXMUHtGj X-Received: by 2002:a17:906:c006:: with SMTP id e6mr13199962ejz.510.1625484942233; Mon, 05 Jul 2021 04:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625484942; cv=none; d=google.com; s=arc-20160816; b=k6xRIfU14sA733oCBJzW3zq/aTh24bwjnLSIWHt3PvWqY+XS+38mtLFlkmUnEG49/w P2MOT9J5ZiBK5HYDfv2CwwfhQfhie5XREGrrXnoHjXzBFKnejZIuXZTVrImgQOg+yyq+ PEk+KZkcDrQx1l+QfoquFY9LcNheDDzq2vsdETW13prIqBbV4ZQ3GciDxCzg+N1HWqTY XCWyHVStg/6lrvNpTCGTjTj6Mvy2rKWNoNwRLUURUNmjt6eIqRm6LTVOdSkcc9CRIUoO 4LGlXnAVsG5FMlS7OAQVvWhW8WwiDv3TZNCnYMpBSofYmIcFnG79RfqZRoVYIKa66hwa JK5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=hk4F9rD9liSIix3sF7kQK9xmL4hfNgiHkvimMQZxOHo=; b=qL8du6vGA94nE0BZ4FO0p59UKoYFbNV1SP1jUlihbCVAvckO3hwQlPmK4uazuwqGFo VeqrxEOXNhj4OW8naden9n8+aQijWjQ4E4NtNL+LBIP021u2RaZEA3aocLDS+O8WNh0U 5WeD67RXJwb9hai36/9GIlWYidX9ffuoIDxXfzU3Uth/3iyIn9vxwSBDabzRquWEDtxL 38p4hAj10lni7R9znjalU3CwnJ/vzQGpUrf/wlSoPZ6Z7ewSK8rdb5t0UkS3Hpfy3SVe ZiNvpsJI2JJ0SozdsuTMXC1XSN1IBpaUV2Y7YtnGfV9YoK8IZ+2vLEXj83fB92eQei0g 3HJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jLGcleRG; 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 m4si10926074ejl.583.2021.07.05.04.35.19; Mon, 05 Jul 2021 04:35:42 -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=jLGcleRG; 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 S231313AbhGELgP (ORCPT + 99 others); Mon, 5 Jul 2021 07:36:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:39028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbhGELgP (ORCPT ); Mon, 5 Jul 2021 07:36:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5033961279; Mon, 5 Jul 2021 11:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625484818; bh=JCzbfrOBLEoTbgD6Ln3Es2DOUH5lhf543Bz5pCxk8ng=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=jLGcleRG3bHdycKc+f5w7I/cPQkXKECKrOn7KDf8dDQ1lXJuG9XxiGqEHg8XBuMXg XvjlTmPRS0d5XLk0/f2+kJMvK/ouPg7pqdfEmi5UNknyoTYX+lvHt/99vhRR2BaYfw 1GlmthWgxTVg62ebKiNrGiWh1MyO2sgMlZK50A8SbJEZPCVwPpFBWULOL+pVBd1QkE oKpGaCeL5OslaTC/rG3tRjGeCkMUyW8bExim71Pn6AXzahNuxesqY2CuwYx17Dqgwa Mpa4ryg3MYK6wABc99I2wu2ZYiL8oSjds8azi7O/pKnIdpyH+rY+XnTUEvkCgrEAY9 Prsqfvqf4PRIg== Subject: Re: [f2fs-dev] [PATCH] f2fs: initialize page->private when using for our internal use To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mm@kvack.org, Matthew Wilcox References: <20210705052216.831989-1-jaegeuk@kernel.org> From: Chao Yu Message-ID: Date: Mon, 5 Jul 2021 19:33:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/7/5 16:56, Jaegeuk Kim wrote: > 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. I'm not familiar with that part of codes, so Cc mm mailing list for help. My question is newpage in .migrate_page() may contain non-zero value in .private field but w/o setting PagePrivate flag, is it a normal case? Thanks, > >> >> 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; >>>