Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp890878pxu; Fri, 4 Dec 2020 19:46:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJytttFi9aoi8fT8yieknncT6ZqKMIKuNNaOO2EbEzvLMVE+KqrlEiWIKLauRjP7FCB9NNV/ X-Received: by 2002:a50:d6c6:: with SMTP id l6mr10649913edj.80.1607139977149; Fri, 04 Dec 2020 19:46:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607139977; cv=none; d=google.com; s=arc-20160816; b=rUkAWXZND67HtzsDMJt7mtZUEk+cKfrqh5eF9DmABruje9uddTZNJKAOr9OqE5YGHe U5dAEAQEcmAr6ozCUTlKnl5qwlwG/LsYUM6y6RRX0Hecv4fsnTkDrjr1VtVdk8uAJMhh gSUK+qXTGSn4S09yYM17+sng5AcyEe7smYcBFZMLlMo8tr0TUIyL25jooakdN9rJTFmH QcK4yyMIo6K0wkpsk7FemPyYIfNVEvSKuPFPvTIILNmst1R2hTkMnMU9k6H6BKJ3J0qo o/0/P1mpCEFekn6lnXf/7z7MPYIU0oL6bRWWWYDwzYRM4zem4LTfbqoF3rC7vb8NgEB1 ZY/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=LJTsl6c44Uxv31c8hslGbnFgaJEY6UyCSOPJO2t5yoo=; b=MsXIijYXTsoUHfH/oAtJnkEwR6bfNFSO9gSpwI5FLaiW0Rmnk++lX5ZL2vifTRxI8C yRHi6jA7OOwKJKekDzY3pxINFWcsPM+KqGvkfc6WhciFWA0X0LpactE9ie8rrJZFr1gB H7CXg0tfpyDTRmlmt2/LrY0G89M9noF+QJpK8e1kvqHqhmP1F9IviE48Yb4mN9gXawAr AQzMLubHkadj1435s4UNH/Ua0GdoAY/MAc2jIlArDgyni+vVXOgXB0uX2Uz8Pkmcc3q4 cyiKHUxgdqBk+P0OEdhnr+XCqyCIK6glG0eGg6ingheaMQ9sjRoMQONfd7gZE7XfXAp3 QgWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KIrUEQP+; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc18si3973348edb.76.2020.12.04.19.45.54; Fri, 04 Dec 2020 19:46:17 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=KIrUEQP+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbgLEDl1 (ORCPT + 99 others); Fri, 4 Dec 2020 22:41:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727822AbgLEDl1 (ORCPT ); Fri, 4 Dec 2020 22:41:27 -0500 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2840C0613D1 for ; Fri, 4 Dec 2020 19:40:46 -0800 (PST) Received: by mail-lj1-x244.google.com with SMTP id s9so8808213ljo.11 for ; Fri, 04 Dec 2020 19:40:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=LJTsl6c44Uxv31c8hslGbnFgaJEY6UyCSOPJO2t5yoo=; b=KIrUEQP+BXrrXPpbpyNG2Xfn2lUBRkqUCKMNo6BBt/EgLZuQMkbCYknfzy1u84/aZX ryRQ7IViUu3sZWA+htQoajbDRHzaV4geUTkkO4xcNaYhNT4/SAR8DyW/x7q0kyLrr9Gc 12LgfTiB0SYF0smdnJE5vA7BZC9q26tbje3hnVZAl692JwVufnNM3HzRUdUpD4HJHOUM g6u6Xnr1bl7XG6fpK0IuG5YjYo/W4YBh7IaSN73x/0SGSMRIePjH0K4WmSHAzMokgDXC sEQ6i9OMX2Bviwrf3BsZ2vRgxKD5G7/oBLkpseTA7jt6rwvw4iYE7Qhq8hv1WQ/cBlG6 PBmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=LJTsl6c44Uxv31c8hslGbnFgaJEY6UyCSOPJO2t5yoo=; b=Dwh7IJ5qNiFZ7iJdI8FQRKbZcerpOnG+aUiDI+x5ZjKHEwMqT7tVKt66XdyTMt7sng S/HYc+LprgO4wNwPTW0oBppRmo0g6YL6e29+N3pJRfgmTfgyReDBB6YxcX76IJOaDDK2 RdKU8awoKQ3AaNA/+XA4rJt8U1WQezHDvbh/An5r2Rjbtzb9x/YPApDT10wp8zuqmrT2 Tv+o/Aer71vAvQUSPFMBNNmXykiA6wO8ar6S+L4w7em0zX4nCD1MncT0g7my+xuj0rS3 DbEfPpyVJ0+lAU4v99PSCLvaUgms3B5ftRi1bSden3uF4qAp6G6sXivM/+KTLEajIyGS DyeQ== X-Gm-Message-State: AOAM531aHonV6wAZ+CWRDstw3a/3vReXsjeHTrw3zcfcWDG/ZZjkTyTa USWFZcKRpK6SWZDKr0Lq+07eCxqLWV+ZIFqZA/k= X-Received: by 2002:a2e:9707:: with SMTP id r7mr4417251lji.265.1607139645307; Fri, 04 Dec 2020 19:40:45 -0800 (PST) MIME-Version: 1.0 References: <20201204005847.654074-1-daeho43@gmail.com> In-Reply-To: From: Daeho Jeong Date: Sat, 5 Dec 2020 12:40:34 +0900 Message-ID: Subject: Re: [f2fs-dev] [PATCH] f2fs: fix race of pending_pages in decompression To: Jaegeuk Kim Cc: Eric Biggers , Daeho Jeong , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yep, we need to come back to v1 and enable verity in a unit of cluster. Plus, as I told you, I'll prevent newly verity enalbed pages from being merged with verity disabled bio. Thanks, 2020=EB=85=84 12=EC=9B=94 5=EC=9D=BC (=ED=86=A0) =EC=98=A4=EC=A0=84 3:29, J= aegeuk Kim =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On 12/04, Daeho Jeong wrote: > > Thanks for the explanation about verity. > > I got your point. Thanks~ > > Possible fix can be like this? > > --- > fs/f2fs/compress.c | 2 -- > fs/f2fs/data.c | 19 +++++++++++++------ > 2 files changed, 13 insertions(+), 8 deletions(-) > > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c > index 89f73a7c8667..c5fee4d7ea72 100644 > --- a/fs/f2fs/compress.c > +++ b/fs/f2fs/compress.c > @@ -1491,8 +1491,6 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct com= press_ctx *cc) > dic->magic =3D F2FS_COMPRESSED_PAGE_MAGIC; > dic->inode =3D cc->inode; > atomic_set(&dic->pending_pages, cc->nr_cpages); > - if (fsverity_active(cc->inode)) > - atomic_set(&dic->verity_pages, cc->nr_cpages); > dic->cluster_idx =3D cc->cluster_idx; > dic->cluster_size =3D cc->cluster_size; > dic->log_cluster_size =3D cc->log_cluster_size; > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index e3168f32f943..657fb562d7d4 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -1035,7 +1035,8 @@ static inline bool f2fs_need_verity(const struct in= ode *inode, pgoff_t idx) > > static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkad= dr, > unsigned nr_pages, unsigned op_flag= , > - pgoff_t first_idx, bool for_write) > + pgoff_t first_idx, bool for_write, > + bool for_verity) > { > struct f2fs_sb_info *sbi =3D F2FS_I_SB(inode); > struct bio *bio; > @@ -1057,7 +1058,7 @@ static struct bio *f2fs_grab_read_bio(struct inode = *inode, block_t blkaddr, > post_read_steps |=3D 1 << STEP_DECRYPT; > if (f2fs_compressed_file(inode)) > post_read_steps |=3D 1 << STEP_DECOMPRESS_NOWQ; > - if (f2fs_need_verity(inode, first_idx)) > + if (for_verity && f2fs_need_verity(inode, first_idx)) > post_read_steps |=3D 1 << STEP_VERITY; > > if (post_read_steps) { > @@ -1087,7 +1088,7 @@ static int f2fs_submit_page_read(struct inode *inod= e, struct page *page, > struct bio *bio; > > bio =3D f2fs_grab_read_bio(inode, blkaddr, 1, op_flags, > - page->index, for_write); > + page->index, for_write, true); > if (IS_ERR(bio)) > return PTR_ERR(bio); > > @@ -2141,7 +2142,7 @@ static int f2fs_read_single_page(struct inode *inod= e, struct page *page, > if (bio =3D=3D NULL) { > bio =3D f2fs_grab_read_bio(inode, block_nr, nr_pages, > is_readahead ? REQ_RAHEAD : 0, page->inde= x, > - false); > + false, true); > if (IS_ERR(bio)) { > ret =3D PTR_ERR(bio); > bio =3D NULL; > @@ -2188,6 +2189,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, = struct bio **bio_ret, > const unsigned blkbits =3D inode->i_blkbits; > const unsigned blocksize =3D 1 << blkbits; > struct decompress_io_ctx *dic =3D NULL; > + bool for_verity =3D false; > int i; > int ret =3D 0; > > @@ -2253,6 +2255,11 @@ int f2fs_read_multi_pages(struct compress_ctx *cc,= struct bio **bio_ret, > goto out_put_dnode; > } > > + if (fsverity_active(cc->inode)) { > + atomic_set(&dic->verity_pages, cc->nr_cpages); > + for_verity =3D true; > + } > + > for (i =3D 0; i < dic->nr_cpages; i++) { > struct page *page =3D dic->cpages[i]; > block_t blkaddr; > @@ -2272,7 +2279,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, = struct bio **bio_ret, > if (!bio) { > bio =3D f2fs_grab_read_bio(inode, blkaddr, nr_pag= es, > is_readahead ? REQ_RAHEAD : 0, > - page->index, for_write); > + page->index, for_write, for_verit= y); > if (IS_ERR(bio)) { > unsigned int remained =3D dic->nr_cpages = - i; > bool release =3D false; > @@ -2280,7 +2287,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, = struct bio **bio_ret, > ret =3D PTR_ERR(bio); > dic->failed =3D true; > > - if (fsverity_active(inode)) { > + if (for_verity) { > if (!atomic_sub_return(remained, > &dic->verity_pages)) > release =3D true; > -- > 2.29.2.576.ga3fc446d84-goog >