Message ID | 20221014030745.25748-1-zhujia.zj@bytedance.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp589989wrs; Thu, 13 Oct 2022 20:09:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AYdZrA6fv013r12JsPlHhChuvfKFEO1UgSgYVjZSeAcMLvpip9C3vSY58gYgvFcEwzkJl X-Received: by 2002:a63:1a4c:0:b0:43b:e648:a7a4 with SMTP id a12-20020a631a4c000000b0043be648a7a4mr2713908pgm.7.1665716982330; Thu, 13 Oct 2022 20:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665716982; cv=none; d=google.com; s=arc-20160816; b=uVkFbtn3SIx0sXWdDb+yMhOUxshjsHD+zw5HI9+htSSSxkbH/jL/48F1IanLpxLmhb IDZ4wxtZItXcfQCraGpvHXvZIh/K+YlFfBlzWsoCI7u2vU3O5kgdX7bFOn+Xz2ZgB1DN clUBf3WplGiq0pJI4lxFjAROmPS3BvH5BOWqfKbxa4C8+9/8tWMB76WYtubqs/XSJ3XW VvtlR1Fk7el3AOnmCCoey7sWyj/Bukalqjkhcu1CEytj3UWFb9R9Yj+E+PetQiduolHg 8i/Rwjgg10SYdDP0eaUGRnfR3iSySm8v/64rRF0Sdy2ZcozygJu47Ur+PYBGm8GF1Pg6 1ibQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=tR+LEXzrwnagFeN1X0qgpjAc8sXMoTZWp+ylsCx2Q8o=; b=K1buVitHdvKfPdbPgXlRwZemE4fwzcGdzqanZ/eK/zzy+KPRHz7YRWN1OS7GA53fmT VsYPwqTmLOWqsLuvEMulefXclcAzsbmN9GZGTLsIn7I9xd91cyWkUy9DCr68wLCrS1k9 2z2+VgeWFt87b1kAULGYs0cr/zmb9gbWpdVUW3qu/uOSIqwgFw+EmLOqWsQwC8NVAe14 0D56zWlFR4GvpDnS0tdQMnuNdr+YrIvaXYmLWhh9blSSBOyxKKzYc9JV8r5SbxZ2SR4b c5vfUn6ddPJA+0v8q+nyoH1CXZkymo0XaPhpgqYzik2DKo7O2z4HcQvPgd8fuYJj8eV4 eD2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=j7OAaYtj; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a5-20020a1709027d8500b001831d43fd44si1468964plm.358.2022.10.13.20.09.29; Thu, 13 Oct 2022 20:09:42 -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=j7OAaYtj; 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 S229460AbiJNDIV (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 23:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiJNDIT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 23:08:19 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B57CD18A3D5 for <linux-kernel@vger.kernel.org>; Thu, 13 Oct 2022 20:07:59 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id l4so3544764plb.8 for <linux-kernel@vger.kernel.org>; Thu, 13 Oct 2022 20:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tR+LEXzrwnagFeN1X0qgpjAc8sXMoTZWp+ylsCx2Q8o=; b=j7OAaYtj4gywSty7236efJMlTd/eu1sIqqWbPt8D+9YFUIliYfpSpcCP0RVtqISuqu EUApBFrH2c13AslkzH2kxWWxVhadCyNF/XhwEb1+wO1wlOTaN9UmHTqGz6A7dGpsv7YF it1z3ccyiqrCduYkbdGYj6lFMob/8GWFUxSCLiEfqRHYmzWYMz69f2joQ1gse4CahmQo B0QilVGK3KBdC876cBFng16Xiyd/XBhGL3l+BQpBzVtwxcRpIqlzRC0RzVLV7IIzDFrN seYRGXSdBD8Bnk7v8XEuCwP6nYfyx4K0Y2PGOehom5FlQdP1PnCIfIsZ1rHUoEYjSv2F SSGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tR+LEXzrwnagFeN1X0qgpjAc8sXMoTZWp+ylsCx2Q8o=; b=BYaJbLIJfVWMk6clCez/G6Vz7DC2s/dTYw31ae7Rc7ouTuK8FTPBN+B+zQ+HrbZAGm ziqocr0NlZwFAqzF0wzUlQeFVHgcY6zb8ESZW2BIHU0aooUeD3cG/h2Ias8XK0z/9JT4 qGdsiGR9BQZOrQaej4p44NZ0yq7xiV7zAZVQUpx4FGuXC++vcmp12029h2WcaC/cGuq0 yYxGruUAUjMmHvuNY4ryGHvRYC+EcqC+PylQsC07UanByr3IXY/8MYGrpr0jBo63oCvY AUV650hpNGM6GDZImnHCuNKz16p3UOBR2zeimv2u2bDxKC0/XkWQd3I+WDPVs1cuOc30 1nbw== X-Gm-Message-State: ACrzQf2aTg7TWEs+s6ILJx8oC+ZRQDWnBTHLpg6WgFXKgLtRXUmdXcWP 8YfXqCzbcbHDHLLmuT/E31buaw== X-Received: by 2002:a17:903:2307:b0:17f:78a5:5484 with SMTP id d7-20020a170903230700b0017f78a55484mr2957038plh.15.1665716879180; Thu, 13 Oct 2022 20:07:59 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([63.216.146.183]) by smtp.gmail.com with ESMTPSA id h4-20020a17090a710400b0020ae09e9724sm425524pjk.53.2022.10.13.20.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 20:07:58 -0700 (PDT) From: Jia Zhu <zhujia.zj@bytedance.com> To: dhowells@redhat.com, xiang@kernel.org, jefflexu@linux.alibaba.com Cc: linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, Jia Zhu <zhujia.zj@bytedance.com> Subject: [PATCH V2 0/5] Introduce daemon failover mechanism to recover from crashing Date: Fri, 14 Oct 2022 11:07:40 +0800 Message-Id: <20221014030745.25748-1-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746630850653942513?= X-GMAIL-MSGID: =?utf-8?q?1746630850653942513?= |
Series |
Introduce daemon failover mechanism to recover from crashing
|
|
Message
Jia Zhu
Oct. 14, 2022, 3:07 a.m. UTC
Changes since V1: 1. Extract cachefiles_ondemand_select_req() from cachefiles_ondemand_daemon_read() to make the code more readable. 2. Fix a UAF bug reported by JeffleXu. 3. Modify some code comments. [Background] ============ In ondemand read mode, if user daemon closes anonymous fd(e.g. daemon crashes), subsequent read and inflight requests based on these fd will return -EIO. Even if above mentioned case is tolerable for some individual users, but when it happenens in real cloud service production environment, such IO errors will be passed to cloud service users and impact its working jobs. It's terrible for cloud service stability. [Design] ======== This patchset introduce three states for ondemand object: CLOSE: Object which just be allocated or closed by user daemon. OPEN: Object which related OPEN request has been processed correctly. REOPENING: Object which has been closed, and is drived to open by a read request. [Flow Path] =========== [Daemon Crash] 0. Daemon use UDS send/receive fd to keep and pass the fd reference of "/dev/cachefiles". 1. User daemon crashes -> restart and recover dev fd's reference. 2. User daemon write "restore" to device. 2.1 Reset the object's state from CLOSE to OPENING. 2.2 Init a work which reinit the object and add it to wq. (daemon can get rid of kernel space and handle that open request). 3. The user of upper filesystem won't notice that the daemon ever crashed since the inflight IO is restored and handled correctly. [Daemon Close fd] 1. User daemon closes an anonymous fd. 2. User daemon reads a READ request which the associated anonymous fd was closed and init a work which re-open the object. 3. User daemon handles above open request normally. 4. The user of upper filesystem won't notice that the daemon ever closed any fd since the closed object is re-opened and related request was handled correctly. [Test] ====== There is a testcase for above mentioned scenario. A user process read the file by fscache ondemand reading. At the same time, we kill the daemon constantly. The expected result is that the file read by user is consistent with original, and the user doesn't notice that daemon has ever been killed. https://github.com/userzj/demand-read-cachefilesd/commits/failover-test [GitWeb] ======== https://github.com/userzj/linux/tree/fscache-failover-v3 Jia Zhu (5): cachefiles: introduce object ondemand state cachefiles: extract ondemand info field from cachefiles_object cachefiles: resend an open request if the read request's object is closed cachefiles: narrow the scope of triggering EPOLLIN events in ondemand mode cachefiles: add restore command to recover inflight ondemand read requests fs/cachefiles/daemon.c | 14 +++- fs/cachefiles/interface.c | 6 ++ fs/cachefiles/internal.h | 58 +++++++++++++- fs/cachefiles/ondemand.c | 156 ++++++++++++++++++++++++++++---------- 4 files changed, 188 insertions(+), 46 deletions(-)