From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5BAEC11F67 for ; Thu, 1 Jul 2021 05:06:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0CF766146B for ; Thu, 1 Jul 2021 05:06:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CF766146B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 12A3E8D0291; Thu, 1 Jul 2021 01:06:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DAFC8D028E; Thu, 1 Jul 2021 01:06:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E96328D0291; Thu, 1 Jul 2021 01:06:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C6EF88D028E for ; Thu, 1 Jul 2021 01:06:51 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 929CF253DB for ; Thu, 1 Jul 2021 05:06:51 +0000 (UTC) X-FDA: 78312834222.03.17D7896 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf26.hostedemail.com (Postfix) with ESMTP id 325C72001700 for ; Thu, 1 Jul 2021 05:06:50 +0000 (UTC) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20210701050646epoutp01c43eac8ec09653fd34484b41d5b8b287~NkmXgkSid1688116881epoutp01j for ; Thu, 1 Jul 2021 05:06:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20210701050646epoutp01c43eac8ec09653fd34484b41d5b8b287~NkmXgkSid1688116881epoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625116006; bh=Y6ptCkRzt+ukPgeWud4JsXHQcvHw2fahz0U8y6ETKLo=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=PO7sSeOaCzARoKihvO7d0YXQVEwmsfstTVV4iDxW005ojbky4cFARLZ7jwtf+yDJf k5bABl+sH91K6bpBpryGLUJA9sAzeoZNesmzP3JOFgLrjkmUPT3AAnpDIs9tByc63Z Dzn1Yk6goxhrPi8A8aBrI9We9IMT3Py1Q0Cbjl6o= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20210701050646epcas1p4f2734bdc1e1376b8483aea31fa944010~NkmXOiDb81858318583epcas1p4g; Thu, 1 Jul 2021 05:06:46 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.163]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4GFmQr3Cqbz4x9Pt; Thu, 1 Jul 2021 05:06:44 +0000 (GMT) X-AuditID: b6c32a39-86dff70000002572-14-60dd4d64da50 Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 90.09.09586.46D4DD06; Thu, 1 Jul 2021 14:06:44 +0900 (KST) Mime-Version: 1.0 Subject: RE: [PATCH] mm: cleancache: fix potential race in cleancache apis Reply-To: ohoono.kwon@samsung.com From: =?UTF-8?B?6raM7Jik7ZuI?= To: "gregkh@linuxfoundation.org" , Matthew Wilcox CC: =?UTF-8?B?6raM7Jik7ZuI?= , "akpm@linux-foundation.org" , "konrad.wilk@oracle.com" , "ohkwon1043@gmail.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20210701050644epcms1p5ceaf654fdabec4a126081f9edcbb3fff@epcms1p5> Date: Thu, 01 Jul 2021 14:06:44 +0900 X-CMS-MailID: 20210701050644epcms1p5ceaf654fdabec4a126081f9edcbb3fff Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmrm6K790Eg7bt4hZz1q9hs2hevJ7N Ytnip4wWl3fNYbO4t+Y/q8Xe/b4Wu36uYLb4/WMOmwOHx85Zd9k9Nq/Q8tj0aRK7x4kZv1k8 9s9dw+7x8ektFo++LasYPT5vkgvgiMqxyUhNTEktUkjNS85PycxLt1XyDo53jjc1MzDUNbS0 MFdSyEvMTbVVcvEJ0HXLzAE6TEmhLDGnFCgUkFhcrKRvZ1OUX1qSqpCRX1xiq5RakJJTYGhQ oFecmFtcmpeul5yfa2VoYGBkClSZkJOxf4FLwV2Vis17P7M1MN5W7mLk5JAQMJFYeuwnUxcj F4eQwA5GiTNzlzF2MXJw8AoISvzdIQxSIyzgJXHrXwMzSFhIQFFi22k3iLCVxLS+f0wgNpuA hcTztT9ZQWwRgVSJjjPXwUYyCxxmkphxqYsdYhevxIz2pywQtrTE9uVbGUFsTgFNid9trWwQ cVGJm6vfssPY74/NZ4SwRSRa751lhrAFJR783A0Vl5S42XaXBWSZhEA/o8T9dS1QzgRGiSVP JkFNNZd4tqEFbCqvgK9E/+f7YKeyCKhKfP+5FGqqi8TKfSfBrmMW0JZYtvA12MfMQNet36UP UaIosfP3XEaIEj6Jd197WGEe2zHvCRNIuQTQyGW/PWB+7Jt+GeoCD4mjV76BbRIS+M0osWk7 2wRGhVmIkJ6FZO8shL0LGJlXMYqlFhTnpqcWGxaYIsftJkZwGtWy3ME4/e0HvUOMTByMhxgl OJiVRHijdt5OEOJNSaysSi3Kjy8qzUktPsRoCvTxRGYp0eR8YCLPK4k3NDUyNja2MDEzNzM1 VhLn3cl2KEFIID2xJDU7NbUgtQimj4mDU6qBKTLigENa83LNVxssS3O23k3XMevd7sTdZXZc 6ZzccwNGiek7Hm1+cijIv2jt+f11l36YHin7X82UbhVfv/h60jQff8Mpd7ZNCJupe2DOR9V1 b7aH/7gS+XDu/k69Z/vZozOufLrJ7e5/Im0hw+r4VqlDrOEvWm2K9Ry4Px1zqGh+cs1G92hr 856vdb0+5b8iA96d7qja6Z7hv6S7vCmz+pWmJk/wVJ5Lhz9tuDa5bG1UYtPZHdmua8oTD0ps C9RMC7XZduW0vMEB0cLDB9fnb9QvnsBY/YThVrKA1GKvp/v3c6mxlDqfiTdJTq8/uKw/84kZ 90L1F3N5rxrct1U1tjKtf1fP8i5k4oG+qUw/lViKMxINtZiLihMBZh/DIiwEAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210630073310epcms1p2ad6803cfd9dbc8ab501c4c99f799f4da References: <20210630073310epcms1p2ad6803cfd9dbc8ab501c4c99f799f4da@epcms1p2> Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=PO7sSeOa; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf26.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.24 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com X-Rspamd-Server: rspam02 X-Stat-Signature: qnotcpmmk6bb7bh3nub6gx4zhx5wcsou X-Rspamd-Queue-Id: 325C72001700 X-HE-Tag: 1625116010-297901 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jul 1, 2021 at 02:06:45PM +0900, =EA=B6=8C=EC=98=A4=ED=9B=88=20wrot= e:=0D=0A>=20On=20Wed,=20Jun=2030,=202021=20at=2012:26:57PM=20+0100,=20Matth= ew=20Wilcox=20wrote:=0D=0A>=20>=20On=20Wed,=20Jun=2030,=202021=20at=2010:13= :28AM=20+0200,=20gregkh=40linuxfoundation.org=20wrote:=0D=0A>=20>=20>=20On= =20Wed,=20Jun=2030,=202021=20at=2004:33:10PM=20+0900,=20=EA=B6=8C=EC=98=A4= =ED=9B=88=20wrote:=0D=0A>=20>=20>=20>=20Current=20cleancache=20api=20implem= entation=20has=20potential=20race=20as=20follows,=0D=0A>=20>=20>=20>=20whic= h=20might=20lead=20to=20corruption=20in=20filesystems=20using=20cleancache.= =0D=0A>=20>=20>=20>=20=0D=0A>=20>=20>=20>=20thread=200=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20thread=201=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20thread=202=0D=0A>=20>=20>=20>=20=0D=0A>= =20>=20>=20>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20in=20put_page=0D=0A>=20>=20>=20>=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20get=20pool_id=20K=20for=20fs1= =0D=0A>=20>=20>=20>=20invalidate_fs=20on=20fs1=0D=0A>=20>=20>=20>=20frees= =20pool_id=20K=0D=0A>=20>=20>=20>=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20init_fs=20for=20fs2= =0D=0A>=20>=20>=20>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20allocates=20pool_id=20K=0D=0A>=20= >=20>=20>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20put_page=20puts=20page=0D=0A>=20>=20>=20>=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20which=20belongs=20to=20f= s1=0D=0A>=20>=20>=20>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20into=20cleancache=20pool=20for=20fs2=0D=0A>=20>=20>=20= >=20=0D=0A>=20>=20>=20>=20At=20this=20point,=20a=20file=20cache=20which=20o= riginally=20belongs=20to=20fs1=20might=20be=0D=0A>=20>=20>=20>=20copied=20b= ack=20to=20cleancache=20pool=20of=20fs2,=20which=20might=20be=20later=20use= d=20as=20if=0D=0A>=20>=20>=20>=20it=20were=20normal=20cleancache=20of=20fs2= ,=20and=20could=20eventually=20corrupt=20fs2=20when=0D=0A>=20>=20>=20>=20fl= ushed=20back.=0D=0A>=20>=20>=20>=20=0D=0A>=20>=20>=20>=20Add=20rwlock=20in= =20order=20to=20synchronize=20invalidate_fs=20with=20other=20cleancache=0D= =0A>=20>=20>=20>=20operations.=0D=0A>=20>=20>=20>=20=0D=0A>=20>=20>=20>=20I= n=20normal=20situations=20where=20filesystems=20are=20not=20frequently=20mo= unted=20or=0D=0A>=20>=20>=20>=20unmounted,=20there=20will=20be=20little=20p= erformance=20impact=20since=0D=0A>=20>=20>=20>=20read_lock/read_unlock=20ap= is=20are=20used.=0D=0A>=20>=20>=20>=20=0D=0A>=20>=20>=20>=20Signed-off-by:= =20Ohhoon=20Kwon=20=0D=0A>=20>=20>=20=0D=0A>=20>= =20>=20What=20commit=20does=20this=20fix?=20=20Should=20it=20go=20to=20stab= le=20kernels?=0D=0A>=20>=20=0D=0A>=20>=20I=20have=20a=20commit=20I=20haven'= t=20submitted=20yet=20with=20this=20changelog:=0D=0A>=20>=20=0D=0A>=20>=20= =20=20=20=20Remove=20cleancache=0D=0A>=20>=20=0D=0A>=20>=20=20=20=20=20The= =20last=20cleancache=20backend=20was=20deleted=20in=20v5.3=20(=22xen:=20rem= ove=20tmem=0D=0A>=20>=20=20=20=20=20driver=22),=20so=20it=20has=20been=20un= used=20since.=20=20Remove=20all=20its=20filesystem=20hooks.=0D=0A>=20>=20= =0D=0A>=20>=20=20=20=20=20Signed-off-by:=20Matthew=20Wilcox=20(Oracle)=20=0D=0A>=20=20=0D=0A>=20That's=20even=20better=21=0D=0A= >=20=20=0D=0A>=20But=20if=20so,=20how=20is=20the=20above=20reported=20probl= em=20even=20a=20problem=20if=20no=20one=20is=0D=0A>=20using=20cleancache?= =0D=0A>=20=20=0D=0A>=20thanks,=0D=0A>=20=20=0D=0A>=20greg=20k-h=0D=0A>=20= =0D=0ADear=20all.=0D=0A=0D=0AWe=20are=20using=20Cleancache=20APIs=20for=20o= ur=20proprietary=20feature=20in=20Samsung.=0D=0AAs=20Wilcox=20mentioned,=20= however,=20there=20is=20no=20cleancache=20backend=20in=20current=20kernel= =0D=0Amainline.=0D=0ASo=20if=20the=20race=20patch=20shall=20be=20accepted,= =20then=20it=20seems=20unnecessary=20to=20patch=20=0D=0Aprevious=20stable= =20kernels.=0D=0A=0D=0AMeanwhile,=20I=20personally=20think=20cleancache=20A= PI=20still=20has=20potential=20to=20be=20a=20good=0D=0Amaterial=20when=20us= ed=20with=20new=20arising=20technologies=20such=20as=20pmem=20or=20NVMe.=0D= =0A=0D=0ASo=20I=20suggest=20to=20postpone=20removing=20cleancache=20for=20a= =20while.=0D=0A=0D=0AThanks,=0D=0AOhhoon=20Kwon.