Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7226108rwd; Mon, 19 Jun 2023 20:59:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ50sYSdpJniNz+iR5vCHbINb253D2NNW1qXGDsYoJVoieDGoDi0Rn92Z1P6P6dGPHOmi7iP X-Received: by 2002:a17:90a:d90b:b0:25b:c91e:8bf2 with SMTP id c11-20020a17090ad90b00b0025bc91e8bf2mr7693421pjv.49.1687233556008; Mon, 19 Jun 2023 20:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687233555; cv=none; d=google.com; s=arc-20160816; b=WyMQorc21kwqY5HVVSqa02UdFOXz7HfLk87MCo+vScu8LgWgeJIZlC2lpJiMsNbclP BKzRZ4Yt6g0g5LCue5Anta3+C7Qr+uq/Tt7ebyXNQ9PpX7YbUkFMZZhvLoaMs/Avs1CK PxR/G4H3lQxivLu4b8tp0DJ+1iZzd4/vCuCfZau9k0t4ry9UCbq9TTq8Tr0LCJDJS63K aycn2yuX3tN3TevD3I5LTkablzb1JmOVMjPtbIM49Pyyv1zar2T2OjTQvyKFbVtCqSC3 1xFMDfJBq64Qi12gMzhI7Bz52zM9z5xdaz4UODOY0/WPXMYSmYktIAow7TkYAMsehoQ4 Ya4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=KctWszAa6u8/CGL8ShlLXi7xNFQSwxFJWDbTX1ExE/A=; b=MSc1I/AkAV2OFJwuMOsHQDDrdq7AY1atqPj8l4FGbiFYfEaYyU6G8cNTqNoca5z6y0 tuxb1BknAQh/G+XA+VeBvgNHTra6/KBYGRKV1hpuUJ2FdoKnPzlIiyDmMU24VpwqZyZE 9dcEHUQ/QRgU7sv17AT69cNFfB8FeO+JPDfznW3VlYX+FnOp2zvNtTfmB8sukHHZMvnC dguw+tdLD5+s7y6+dugzqUlnjt79BvipWMflVuX4qDM3oVwq5vKMVSWA9KnChlk57E4o shI/lrPW+3sBxrNmogZVD8xPNmFdCFL5b03eVoX+eZgX4z/ICgcv5YfbRcxo4Givu4o3 A/Ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a170902ea0c00b001b544ef9d50si1135276plg.546.2023.06.19.20.59.03; Mon, 19 Jun 2023 20:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbjFTDu1 (ORCPT + 99 others); Mon, 19 Jun 2023 23:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbjFTDuU (ORCPT ); Mon, 19 Jun 2023 23:50:20 -0400 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C298D10F3; Mon, 19 Jun 2023 20:50:12 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0Vla3ivZ_1687233008; Received: from 30.221.149.68(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vla3ivZ_1687233008) by smtp.aliyun-inc.com; Tue, 20 Jun 2023 11:50:09 +0800 Message-ID: <067578f0-9e3a-e2cf-f7c8-ff7eeda2694a@linux.alibaba.com> Date: Tue, 20 Jun 2023 11:50:05 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] fuse: fix return value of inode_inline_reclaim_one_dmap in error path Content-Language: en-US To: Vivek Goyal Cc: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org, gerry@linux.alibaba.com, linux-kernel@vger.kernel.org, German Maglione References: <20230424123250.125404-1-jefflexu@linux.alibaba.com> <33fd8e03-7c99-c12d-255d-b7190612379b@linux.alibaba.com> From: Jingbo Xu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/1/23 7:45 PM, Vivek Goyal wrote: > On Thu, Jun 01, 2023 at 09:45:52AM +0800, Jingbo Xu wrote: >> >> >> On 6/1/23 4:03 AM, Vivek Goyal wrote: >>> On Mon, Apr 24, 2023 at 08:32:50PM +0800, Jingbo Xu wrote: >>>> When range already got reclaimed by somebody else, return NULL so that >>>> the caller could retry to allocate or reclaim another range, instead of >>>> mistakenly returning the range already got reclaimed and reused by >>>> others. >>>> >>>> Reported-by: Liu Jiang >>>> Fixes: 9a752d18c85a ("virtiofs: add logic to free up a memory range") >>>> Signed-off-by: Jingbo Xu >>> >>> Hi Jingbo, >>> >>> This patch looks correct to me. >>> >>> Are you able to reproduce the problem? Or you are fixing it based on >>> code inspection? >> >> It's spotted by Liu Jiang during code review. Not tested yet. >> >>> >>> How are you testing this? We don't have virtiofsd DAX implementation yet >>> in rust virtiofsd yet. >>> >>> I am not sure how to test this chagne now. We had out of tree patches >>> in qemu and now qemu has gotten rid of C version of virtiofsd so these >>> patches might not even work now. >> >> Yeah this exception path may not be so easy to be tested as it is only >> triggered in the race condition. I have the old branch (of qemu) with >> support for DAX, and maybe I could try to reproduce the exception path >> by configuring limited DAX window and heavy IO workload. > > That would be great. Please test it with really small DAX window size. > Also put some pr_debug() statements to make sure you are hitting this > particular path during testing. I tried to reproduce it but failed. It seems the race is impossible theoretically. In theory, the race occurs when a freeable dmap is found in inode's interval tree but found it is removed from the interval tree in the second query. However the above procedure is protected with filemap_invalidate_lock(inode->i_mapping) held in inode_inline_reclaim_one_dmap(). Given the dmap deletion operations from inode's interval tree are all protected with filemap_invalidate_lock(inode->i_mapping) held, e.g. inside inode_inline_reclaim_one_dmap() and lookup_and_reclaim_dmap(), the above race seems impossible then. -- Thanks, Jingbo