Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3343015rwb; Sun, 9 Oct 2022 03:33:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Pkpuy64qrENxdD53aay7endgcJW+Wh1QzDDfYz5SHPJJUZIxGSkj/MsjVmQMKnZdiQvVq X-Received: by 2002:a17:907:5ce:b0:730:bae0:deb with SMTP id wg14-20020a17090705ce00b00730bae00debmr11002815ejb.181.1665311612022; Sun, 09 Oct 2022 03:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665311612; cv=none; d=google.com; s=arc-20160816; b=KHQW6pax+rBetz/leo7yuM2bfaV5d2/MbAxYb6f2qI/5H84cxiGKyCEbOTei/vkazq C+chXzyCAeac+BOZlUpenDjNJ4GwdqbQLu03L+DscqKgUayx+v9/lI5insUtodMsXnsN qdPZYC4gvuyqpM+ejbNuY6mTGLj0FFCJRTl5poA0mKm+5GdTQtgDZ1P+9ZR/6XLNqXAd Wk4VgUxa9sZTL1CUhcrPKKWfJrjbgtkBdXpfzFa2IbRPyOEdmi3t2/9ZAI56AsW0MUjM Pw7dyDdHnzLV4vq12O7+QsIhDippuOEJ9pkkPnSxv5kAjVk6QxWo2T4q5TXUSEZ7x5Iu CFUg== 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:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=vSVDnAgp4oFS6GtK5rwH8v4//Iq76mLV9/G+ci+5hkU=; b=G56TToqZB9prJPSu9RkTQzTHtYx78MNPD83q7rTa7/3afm9rLrzC/0A3BLheQIo4Gj P1yWrJH+PUY/ATsoGalZF2EZpDz7bh3GgVvahSF8xdCRNrZDiRXzy5mi0G0LUKG6hNkr 4m0OJrDHlspA4CiGR51VKm27sh743E4EB1L0K0cZhdAKLhs//phpcy15lSZURqV6GyGN 9fbL0WEg18IdztgReG4mYgrEQxRtRINgad4N8oLOgzmboOhgLLMTVhMhR2sic5pOtbmH e/BNpbsmRRdoufeCiFFZMx/BCptuCiyIvWbABTbpOWOziXWTk+wuwq2NX8TrkIG78mF6 Mnzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=5X6uW2V+; 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=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a170906975300b0078c5f3569aesi7401332ejy.69.2022.10.09.03.33.06; Sun, 09 Oct 2022 03:33:32 -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; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=5X6uW2V+; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbiJIJwk (ORCPT + 99 others); Sun, 9 Oct 2022 05:52:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbiJIJwi (ORCPT ); Sun, 9 Oct 2022 05:52:38 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1D311C130 for ; Sun, 9 Oct 2022 02:52:37 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 129so8146244pgc.5 for ; Sun, 09 Oct 2022 02:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=vSVDnAgp4oFS6GtK5rwH8v4//Iq76mLV9/G+ci+5hkU=; b=5X6uW2V+efbPbpyDNO3HlTgh8q1X5rnRaOc6ctfh4Nyq+P+npywuh1EOO5ouC2B8Pj S//KvKWa8t5eAgr4fmtMzJBmpY27L5ZomycvSDcVYpkoDjD4DkKEaGBQhHXrpvlpTJf+ /vywDKTauGCQoTz02QOGcT95fyWQEQMOVMp9BfI8nD+HDUnp8CBQ6a4V/zqSPqpUe9eQ Ih3Bnk4n+7voDmxcf/d+fCO9EnGN6uOlOe1K0oGr7j0ePkR5XiTBTB8h4AegVlCAkUmx CSr3ILx2UbazKdN2vbowNDI43x6gdknGrj1pO4/hL+yfEeK3vdle+o6mDaea1gxUZwlN vYzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=vSVDnAgp4oFS6GtK5rwH8v4//Iq76mLV9/G+ci+5hkU=; b=QG/QnHMpgNR3r80BxL8wxnWzCRZtJ4wAvfZJykIo96V7FvOnB/WfJ0qdAOhGrqGCri 7ukgX+6MjGxIquPbPrKzi++WfhzaexNyLKzGtEWF06HASNE8avBZg3ChENqN7NaFDJaP GrzGHCRabVPiVcTFSdZd7imwit1RZf0IC9ceVRgIM9pJYCcXE2ATtYA9rqB7hvSBtm0w B5ENe3r6Kn7c7+2E+Kjd/k63y/Eoaq/5CDvHQHyCqr6jb+mehsEe2tzgOfyQOuPpE3l3 1O2xwnp5M6zZf0TxrDpncI+1If1kIaTvKdZDJkJL0aSLlSKm50FG8qK14f15UIjEbZ7P qIPA== X-Gm-Message-State: ACrzQf3pWs8IamRqdkgXlVBvMtTkDepEZarWwo9qKKgxEldC3d7ZIU8M hqGYed2Q3UWtOjekGR1onCWQQBGG9odpEA== X-Received: by 2002:a65:44c1:0:b0:428:ab8f:62dd with SMTP id g1-20020a6544c1000000b00428ab8f62ddmr11994518pgs.211.1665309157196; Sun, 09 Oct 2022 02:52:37 -0700 (PDT) Received: from [10.3.156.122] ([63.216.146.187]) by smtp.gmail.com with ESMTPSA id c82-20020a624e55000000b0056265011136sm4678686pfb.112.2022.10.09.02.52.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Oct 2022 02:52:36 -0700 (PDT) Message-ID: Date: Sun, 9 Oct 2022 17:52:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [External] Re: [RFC PATCH 5/5] cachefiles: add restore command to recover inflight ondemand read requests To: JeffleXu , dhowells@redhat.com, xiang@kernel.org Cc: linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, Gao Xiang References: <20220818135204.49878-1-zhujia.zj@bytedance.com> <20220818135204.49878-6-zhujia.zj@bytedance.com> <514c06f7-017d-bca5-6a87-0dae54c0d83d@linux.alibaba.com> From: Jia Zhu In-Reply-To: <514c06f7-017d-bca5-6a87-0dae54c0d83d@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 在 2022/10/8 17:00, JeffleXu 写道: > > > On 8/18/22 9:52 PM, Jia Zhu wrote: >> Previously, in ondemand read scenario, if the anonymous fd was closed by >> user daemon, inflight and subsequent read requests would return EIO. >> As long as the device connection is not released, user daemon can hold >> and restore inflight requests by setting the request flag to >> CACHEFILES_REQ_NEW. >> >> Suggested-by: Gao Xiang >> Signed-off-by: Jia Zhu >> Signed-off-by: Xin Yin >> --- >> fs/cachefiles/daemon.c | 1 + >> fs/cachefiles/internal.h | 3 +++ >> fs/cachefiles/ondemand.c | 23 +++++++++++++++++++++++ >> 3 files changed, 27 insertions(+) >> >> diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c >> index c74bd1f4ecf5..014369266cb2 100644 >> --- a/fs/cachefiles/daemon.c >> +++ b/fs/cachefiles/daemon.c >> @@ -77,6 +77,7 @@ static const struct cachefiles_daemon_cmd cachefiles_daemon_cmds[] = { >> { "tag", cachefiles_daemon_tag }, >> #ifdef CONFIG_CACHEFILES_ONDEMAND >> { "copen", cachefiles_ondemand_copen }, >> + { "restore", cachefiles_ondemand_restore }, >> #endif >> { "", NULL } >> }; >> diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h >> index b4af67f1cbd6..d504c61a5f03 100644 >> --- a/fs/cachefiles/internal.h >> +++ b/fs/cachefiles/internal.h >> @@ -303,6 +303,9 @@ extern ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, >> extern int cachefiles_ondemand_copen(struct cachefiles_cache *cache, >> char *args); >> >> +extern int cachefiles_ondemand_restore(struct cachefiles_cache *cache, >> + char *args); >> + >> extern int cachefiles_ondemand_init_object(struct cachefiles_object *object); >> extern void cachefiles_ondemand_clean_object(struct cachefiles_object *object); >> >> diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c >> index 79ffb19380cd..5b1c447da976 100644 >> --- a/fs/cachefiles/ondemand.c >> +++ b/fs/cachefiles/ondemand.c >> @@ -178,6 +178,29 @@ int cachefiles_ondemand_copen(struct cachefiles_cache *cache, char *args) >> return ret; >> } >> >> +int cachefiles_ondemand_restore(struct cachefiles_cache *cache, char *args) >> +{ >> + struct cachefiles_req *req; >> + >> + XA_STATE(xas, &cache->reqs, 0); >> + >> + if (!test_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags)) >> + return -EOPNOTSUPP; >> + >> + /* >> + * Search the requests which being processed before >> + * the user daemon crashed. >> + * Set the CACHEFILES_REQ_NEW flag and user daemon will reprocess it. >> + */ > > The comment can be improved as: > > Reset the requests to CACHEFILES_REQ_NEW state, so that the > requests have been processed halfway before the crash of the > user daemon could be reprocessed after the recovery. > Thanks, I'll apply it. > >> + xas_lock(&xas); >> + xas_for_each(&xas, req, ULONG_MAX) >> + xas_set_mark(&xas, CACHEFILES_REQ_NEW); >> + xas_unlock(&xas); >> + >> + wake_up_all(&cache->daemon_pollwq); >> + return 0; >> +} >> + >> static int cachefiles_ondemand_get_fd(struct cachefiles_req *req) >> { >> struct cachefiles_object *object; >