From patchwork Fri Nov 22 23:23:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13883703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BA9EE6ADCB for ; Fri, 22 Nov 2024 23:24:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF1D16B0083; Fri, 22 Nov 2024 18:24:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA1CE6B0085; Fri, 22 Nov 2024 18:24:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91AD86B0088; Fri, 22 Nov 2024 18:24:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 71A706B0083 for ; Fri, 22 Nov 2024 18:24:28 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0F32BAF633 for ; Fri, 22 Nov 2024 23:24:28 +0000 (UTC) X-FDA: 82815312216.29.414D518 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by imf21.hostedemail.com (Postfix) with ESMTP id 024CE1C0006 for ; Fri, 22 Nov 2024 23:24:25 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Z0f3FyGd; spf=pass (imf21.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732317866; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=t5u3R1yw+kui0tyYMObpxZCZs3WeGMww1fJq5IP8R1c=; b=H2eo+nMXn/BL749MasCVdPdMl65M6MRpwyZmnXW9IHVYSkhyrER2ABQ2LlYovzGVGrie3y /5DM4eueAY77YopooGthW/0GV6OAxRn+Go3kTyOSRgV5XCvS7cPS3xLfNnVbwcMnVtMOIA K8HkjnF8Mx4lLAHN2yVDw0KzIRDpIx8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732317866; a=rsa-sha256; cv=none; b=b32UOW+V+n1Mfqvz4QViJDTFXM4W7aCZFwpumBbbLjv62RP9CZenjEMWxTwIo3S5Ht5jLE iN4xPRceNafh+YfYFWiW0aPHWGdnKCzDmA0fxfELBdjvhBQD8P6yEnBB9np44zV/TkQZkv 1efDW2LZIWTUzTtUy8WIL0TGQu2TL3k= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Z0f3FyGd; spf=pass (imf21.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-6ee7a400647so30141617b3.1 for ; Fri, 22 Nov 2024 15:24:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732317865; x=1732922665; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t5u3R1yw+kui0tyYMObpxZCZs3WeGMww1fJq5IP8R1c=; b=Z0f3FyGdjuPotGKQfpwDjG7WxqlwrSXkcCVC5VfUP9W5afZ2qCR6ATZ93hD5w/yyUj 99lNHXwmxEbsHeNKfRYwZXJBElgP3VinFxZLz3fC03LgEmBIJAmRZGEi/2cukAfp44Pl zf5pNSAiuOQC0nFpqmCYNMXHCfF29/+hEpc98cKsvk+qMEfvqupCjOzszYCPrOPvRsHD bfYWobreML2OcgswJrTpFunQacWIK+k4/qtFa2s0ceukaBSzFwRa6VTMmWq8r780glHE 0sNn8Z3L0jKO7f7HPYMTRG5ok6UX+z40QEe6OFoeOAS0lhB0uork+AQfj6eELdfVqkgE wiWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732317865; x=1732922665; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t5u3R1yw+kui0tyYMObpxZCZs3WeGMww1fJq5IP8R1c=; b=ESNdV3zZo5EERgxTfk/jTocGIi/K91fmHbyfgWexooOlZh+mN6h42ZNScB3BgWk1Nc 0hKQYDeL3lxJTeUaE2LXkg0Qmr9aysR+wMmq1J0iEhkBeQILn9N3zby9WY/HdH+J+dUm 9wBylVYKkkTkkyu5ShvYU1PDoggr011XGFqmryo2qsRTWWVm2RqTYQFf1IM8m+e0KKAN Y5Xmk1tTKtNPC5SngXVZ/bH3KaWkuQoM07rOlTEdb7c6Gnz5HAkd6d0mhpFYKar7QRHy aNwsSbhSfGdE7dQl75kcwWM35GuDfeu9I6VyHuWOfTo833J1HJnerVmgukHhHnnZqCOS P8HQ== X-Forwarded-Encrypted: i=1; AJvYcCU12mkXbvxsJfflGPMIgMcIU3wdURpsmzWsPb84etebVbw95+JXUXgxQ644AVMFaPDSaDdbtKje9A==@kvack.org X-Gm-Message-State: AOJu0YwB1ykEZlb6QEkiV42o/Gclq6mEnVDv/y5Wpg6z3UCF4d1pQt64 R1mL6iXrNC+0FBGpMOQukmDol2uTcR112uFscO8kJjXHRa49M7EA X-Gm-Gg: ASbGncu5s8KYFIi5KvrmpXXtAn3YYnJCGwXzVmNm1qzXqTFS7qOd296TRBfmkxRkWN/ ScKz1w3Wxd6wxaklMRx5u2EX/oIHwOPRu+Yo8KKIFZd5r7u+cvWbmZRHC8jRVHLy+oOycQ5VD23 AQ6t9Ayy8pR0RCsA80slrxshki4p//4Vu0wsMjukdCtQybYL0rmLBWK5L0bkHJ1liNvG34ZGAUp n8xd3jKKq8jsQm8c2dRp3Wt75rExtbkEVFHBx1hA2ejMDlDiqSM6SX+04Zku0tMC6QLphPtIEQ8 Qn+UPISr X-Google-Smtp-Source: AGHT+IE31ZflB95lghWnoApBp5JoBxyoMgfn9RvO479pqfokI54v3mfaN5/ufMEOG8SbV3Cy8wagiw== X-Received: by 2002:a05:690c:6e09:b0:6ee:664e:8c03 with SMTP id 00721157ae682-6eee08b90bcmr51886217b3.19.1732317865368; Fri, 22 Nov 2024 15:24:25 -0800 (PST) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eedfe2c142sm6918817b3.48.2024.11.22.15.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 15:24:25 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: shakeel.butt@linux.dev, jefflexu@linux.alibaba.com, josef@toxicpanda.com, bernd.schubert@fastmail.fm, linux-mm@kvack.org, kernel-team@meta.com Subject: [PATCH v6 1/5] mm: add AS_WRITEBACK_INDETERMINATE mapping flag Date: Fri, 22 Nov 2024 15:23:55 -0800 Message-ID: <20241122232359.429647-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241122232359.429647-1-joannelkoong@gmail.com> References: <20241122232359.429647-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Stat-Signature: xntgbtxgmhfd4zsk5x9z8jecsgajx8r5 X-Rspam-User: X-Rspamd-Queue-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wP9UOj1p7aCn+H5uAbcfFh+cpRzAEDXO1qM32uF9qdPKP1IAjPuQ9M/0kP/1AM8mJ2efxPz5eiooJFI7MYow+fdd/FTTOXy6GX/rDmzzOmIyU5JkxBPw+63I5mAdeBejCyclARa5fIQS7BZIOIQ2Ptw5ruCXbb7jeuIMuAiaEIjafP0760NQr7rNgtLL76kVHkQYus0AKZtFF7aEaGifzkMBEdoQ+C370X/DJEHhFY0ZoP4FJlhkrTxR5PK5KvcL+SARcOX4ArKnhxb3pAkTpKWMhYZSwy/gEVu8ebVA+et2+ncerLUvTy/NouNBnLyy5UMMBNFlrSOFVmMkDh0h+bhPn0MJv7nGQ51qwjrO7pdycIunZkQCRow== 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: List-Subscribe: List-Unsubscribe: Add a new mapping flag AS_WRITEBACK_INDETERMINATE which filesystems may set to indicate that writing back to disk may take an indeterminate amount of time to complete. Extra caution should be taken when waiting on writeback for folios belonging to mappings where this flag is set. Signed-off-by: Joanne Koong Reviewed-by: Shakeel Butt --- include/linux/pagemap.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 68a5f1ff3301..fcf7d4dd7e2b 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -210,6 +210,7 @@ enum mapping_flags { AS_STABLE_WRITES = 7, /* must wait for writeback before modifying folio contents */ AS_INACCESSIBLE = 8, /* Do not attempt direct R/W access to the mapping */ + AS_WRITEBACK_INDETERMINATE = 9, /* Use caution when waiting on writeback */ /* Bits 16-25 are used for FOLIO_ORDER */ AS_FOLIO_ORDER_BITS = 5, AS_FOLIO_ORDER_MIN = 16, @@ -335,6 +336,16 @@ static inline bool mapping_inaccessible(struct address_space *mapping) return test_bit(AS_INACCESSIBLE, &mapping->flags); } +static inline void mapping_set_writeback_indeterminate(struct address_space *mapping) +{ + set_bit(AS_WRITEBACK_INDETERMINATE, &mapping->flags); +} + +static inline bool mapping_writeback_indeterminate(struct address_space *mapping) +{ + return test_bit(AS_WRITEBACK_INDETERMINATE, &mapping->flags); +} + static inline gfp_t mapping_gfp_mask(struct address_space * mapping) { return mapping->gfp_mask; From patchwork Fri Nov 22 23:23:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13883704 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 287A2E6ADCB for ; Fri, 22 Nov 2024 23:24:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4E436B0085; Fri, 22 Nov 2024 18:24:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DFE726B0089; Fri, 22 Nov 2024 18:24:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C82026B008A; Fri, 22 Nov 2024 18:24:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id ABDC56B0085 for ; Fri, 22 Nov 2024 18:24:29 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 69E0180191 for ; Fri, 22 Nov 2024 23:24:29 +0000 (UTC) X-FDA: 82815312258.26.46846B5 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by imf20.hostedemail.com (Postfix) with ESMTP id 6437B1C0017 for ; Fri, 22 Nov 2024 23:24:27 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jrKgnh2B; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732317867; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hqCGll30CJiyTPfCOluQLlSYspNea277q8s6Em+tUXY=; b=7QAa1cDuo3w/Uf73oKFFDmpjSQ1Tgn+EdiGuGstChfiWZORZZvgSwWXP0cSlCo+cJgpztI HQod1D8WFDW44OwPBgtSo/QEy4OzlPBUDPgn8ExZ7wvpIG5sUhWQf4Vw2UbBylk5dgztk2 P3bYo5u+fvNuJ10dYVlvWKGBu3gW3y4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jrKgnh2B; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732317867; a=rsa-sha256; cv=none; b=erExVjn49NX1HzJ4tfI+uztDDMWsExBn7xX4oY5TS5CK+KV5y+cAyqPTYm02EgXDrkXiSX MWoew3z1o5cEvJSNL1JVqMYS/I+auDx6nRXzAdzos4UmQxTny2Fpk1PETeaaLzaNIj3wDS 3BYz5BUZCZYzDNfhY923xsDU0yi6hHw= Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6ee805c96dbso25706007b3.2 for ; Fri, 22 Nov 2024 15:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732317867; x=1732922667; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hqCGll30CJiyTPfCOluQLlSYspNea277q8s6Em+tUXY=; b=jrKgnh2BHILi6Moj0yLvA08v7N5PVUTKaZA+T3Q1tRkBaat8wDndswhJd3zui2Yn0E GaMz7NXrw/2xP974ZhwijrAxejw4g0UTBTTLvgt5GBL0s/zjw5KkGUul5JNSgpxJTuLZ Bffza4nbl3odKl/Aor4qF8dMyTCUFOBhD1aj8Wnw31U2XESRFXvueCmpfY6S35Wlq2wm qD2jtu0Pb9e0gm40K0B2urBK1QwwAlfVgKuGYtlICMuUyMjbAT2B6ZmMPvTCiztqbXOz KCzbI2Jo1uMgrWe8VrbllZNgxFRFplaNAjLjSs+p0gtgh55WCLgECs4sUpDNvN++0B7Y f3cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732317867; x=1732922667; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hqCGll30CJiyTPfCOluQLlSYspNea277q8s6Em+tUXY=; b=OBUrszW1NVp2BZny58PyXUNIMFKp+7EsNPqgixqL70Pdth12Sc/5ExYm1gYSgV+n75 zrS26URSJZGNJ8b3rITLOHpqqR2aZUrTxqGyus4twKocGW1hGUtIKCKYLpnN7E72QliO 4uWby9pG/bBj+OEDbs+hdBydYnSdEHLXb1kLSAtL9l7hlqnIHfnh6rEeM4TW3JOhU8FJ 2H7AvLjAcATj97FF0fZIstMRG1iMxvjc5S4nwG3NToFLN0ryP9iMnwkuiOKH7/8NfBTH 28erofOzspPK2PcRDdyAcoGzo6pv70Dhb8FUZc0G3VBJGhW1A37fBPLm+dKbOKTRioXJ Bz+w== X-Forwarded-Encrypted: i=1; AJvYcCW0FmwWujsdghmn0RV8Wa7v2RnKGfZ94cG6UhA3nLLIg9MAYxgRB5PBIfrS3RXyViyrohY03dI8kw==@kvack.org X-Gm-Message-State: AOJu0YwnOpMBXZbDQKE8cpCCO7qfWD7B0gdVhhB2c81HJ3X5OF99XbaE xpr3iSGbcMRz2qm+3NU+YZH0fUR97V1dgMoY/8YJCuOwIhgYMhY0 X-Gm-Gg: ASbGncux0alq7P4UlHyCThISsSlKX9qhJfGrs77KGXKYfEHk4zML3YrAcSIplKbdfG1 3aONtZkmW9xByYQZUX3Zg5G7C+GI90/nNLTpo0/eQ5+semxW4Qpa7omm3yIGLXnyqsvsFla78XZ jA0tDXCTBrlIHGKDyks3c9e5HuzdAAJntUPzNPPnwDyLxNeP7Q8D2MnxSLNxm8vMadSQ7pElU3u teh8XraNyy6mM0YlXfIJQxfj/PqTk3n4XpAgxkws0HI2tRXbfxPB6h+DVdnP0Gp6UTgkeiAxggz txbNu7rw X-Google-Smtp-Source: AGHT+IFKU5jQK1lagqG1ya3hMgLoQLO7xg2eEmLkI7xWE77dGiRpSdFWIYkKQ4nezV34Rrjdl5rIMA== X-Received: by 2002:a05:690c:688a:b0:6ea:96bf:1706 with SMTP id 00721157ae682-6eee07c224emr61916467b3.0.1732317866710; Fri, 22 Nov 2024 15:24:26 -0800 (PST) Received: from localhost (fwdproxy-nha-006.fbsv.net. [2a03:2880:25ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eedfe2c142sm6918917b3.48.2024.11.22.15.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 15:24:26 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: shakeel.butt@linux.dev, jefflexu@linux.alibaba.com, josef@toxicpanda.com, bernd.schubert@fastmail.fm, linux-mm@kvack.org, kernel-team@meta.com Subject: [PATCH v6 2/5] mm: skip reclaiming folios in legacy memcg writeback indeterminate contexts Date: Fri, 22 Nov 2024 15:23:56 -0800 Message-ID: <20241122232359.429647-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241122232359.429647-1-joannelkoong@gmail.com> References: <20241122232359.429647-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6437B1C0017 X-Stat-Signature: tw7f7k1zofjywupft3qux6rqhdok64fb X-HE-Tag: 1732317867-810706 X-HE-Meta: U2FsdGVkX187p9nKZ2E48IinXex37rPBkaOcRCiPRc/AzO7f/2/uzWFzdiWDSxilStW1GStibOcDTbRhXqhzEkZoEAbqWHQ0S1kG+42gf4Qk7Aht3CRjTGQz6JyAnFN1WvYqOZ+QHtqZruooXA3IIJ3caUBI3QnV9HKoEYPAqVHhBWwKk9V5uJN6yDBEcre+Vh94W119+qdqEcQ56iHcroMtnFA7kIlet7kP3MN+j71lNoBkZtk+HdpvbtLJ50wB9HAwFsYiTBMQPAF6xgLAb8S3HL2oVTWPNIYHiguXynNoPaqz3FDBKgdcNONE9iXwj8mBjV2/9fg+CMXtDb9cwLa4Ia7GPIVZRvQDkOSIKKn4zB6KrBDPytuuBFNlzeM4qRYIMinbo7tOi4hBzDXIlMHRM9WLRYeFSEuv/Hjq5oqugbK5xcdkb1VOuvxJJeC+AGTiPVq8CGqri2fy6mZCcnnsYwRz+x5mfffuJgsFEmVbBxHzP5tfk4rqOWPvI0as1leg8aSwfFZoVm+ceI/qhZN7UAOWwo831Gask5E6Whc5iw6vNqNLCIfqIGdKecON3VnOjjQeO7ByVcYEzjYrAq8c+idd/yinMp75DsjJ7dA5H3xzYlAl+SzvQl845OcaV64gQ/Rctb2OoGkHbmclCYgVM2Mj4xIRjJkOFDHPvqK/sg3BawHWN5+TLyVTnRAR22mCdYZmBqx72oirwRAHJl6QGqpUul9rzewWMuxVFZEAN8yhYfe4+oSsxgfud0W1jbjkhsSEOcyG/17mCYr/Qv7eXLyqTbnabBBK2/A3c5uPCVvsCcDuA10nRFG+gSwrCI8ia9NaWaDvKJBPFvMmvK8vPjb/UtzJTKZ1w7d34W+542aXEoSXxRKnozBWuZXg1DIBpM8pJAV7HzjYrjUTVJZjQPh+wc6DYon9P64oqKCbrXGtCnSJDaHETtnJ0zatnb2y65t7LzXi5mcoi4U b+On6Zt1 m6P+++OxvyH8S0gLgsTSZSAw5//esRY8LfIv0/oicyRi0W4ETjdFyrsMhqCon23cATCkOmKBqRp2mIg/nFjt7u5ZK4wSeDaCzzL6cH3C8DA/OZdRcacYyFoKzNJ9Gkj9iXxCKrT3IEba4e+IUxi+hwuTyyjPH07z4YxFl93QnmwF1cLrqDEDNFy29gL4FDgJXtbvzrcqwYKjPJ1qA8RxsJPOK7QBOUp9+mjkaw+tl+yoW+eVB4EYF5k8GL4a8mzdZTYpXriYuHVYWAJbtD0Vl4feR0qUEj0ebcUsaEytPtl1dx2oQsME3sr37KgTeeB+bzEikIFFyC+18Eyegjlcc8ByXSqRdWDIW3TsbpUb2vIWm2ag= 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: List-Subscribe: List-Unsubscribe: Currently in shrink_folio_list(), reclaim for folios under writeback falls into 3 different cases: 1) Reclaim is encountering an excessive number of folios under writeback and this folio has both the writeback and reclaim flags set 2) Dirty throttling is enabled (this happens if reclaim through cgroup is not enabled, if reclaim through cgroupv2 memcg is enabled, or if reclaim is on the root cgroup), or if the folio is not marked for immediate reclaim, or if the caller does not have __GFP_FS (or __GFP_IO if it's going to swap) set 3) Legacy cgroupv1 encounters a folio that already has the reclaim flag set and the caller did not have __GFP_FS (or __GFP_IO if swap) set In cases 1) and 2), we activate the folio and skip reclaiming it while in case 3), we wait for writeback to finish on the folio and then try to reclaim the folio again. In case 3, we wait on writeback because cgroupv1 does not have dirty folio throttling, as such this is a mitigation against the case where there are too many folios in writeback with nothing else to reclaim. For filesystems where writeback may take an indeterminate amount of time to write to disk, this has the possibility of stalling reclaim. In this commit, if legacy memcg encounters a folio with the reclaim flag set (eg case 3) and the folio belongs to a mapping that has the AS_WRITEBACK_INDETERMINATE flag set, the folio will be activated and skip reclaim (eg default to behavior in case 2) instead. Signed-off-by: Joanne Koong Reviewed-by: Shakeel Butt --- mm/vmscan.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 749cdc110c74..37ce6b6dac06 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1129,8 +1129,9 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, * 2) Global or new memcg reclaim encounters a folio that is * not marked for immediate reclaim, or the caller does not * have __GFP_FS (or __GFP_IO if it's simply going to swap, - * not to fs). In this case mark the folio for immediate - * reclaim and continue scanning. + * not to fs), or the writeback may take an indeterminate + * amount of time to complete. In this case mark the folio + * for immediate reclaim and continue scanning. * * Require may_enter_fs() because we would wait on fs, which * may not have submitted I/O yet. And the loop driver might @@ -1155,6 +1156,8 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, * takes to write them to disk. */ if (folio_test_writeback(folio)) { + mapping = folio_mapping(folio); + /* Case 1 above */ if (current_is_kswapd() && folio_test_reclaim(folio) && @@ -1165,7 +1168,8 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, /* Case 2 above */ } else if (writeback_throttling_sane(sc) || !folio_test_reclaim(folio) || - !may_enter_fs(folio, sc->gfp_mask)) { + !may_enter_fs(folio, sc->gfp_mask) || + (mapping && mapping_writeback_indeterminate(mapping))) { /* * This is slightly racy - * folio_end_writeback() might have From patchwork Fri Nov 22 23:23:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13883705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11D0CE6ADCB for ; Fri, 22 Nov 2024 23:24:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D3CB6B0089; Fri, 22 Nov 2024 18:24:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E2FE6B008A; Fri, 22 Nov 2024 18:24:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 635086B008C; Fri, 22 Nov 2024 18:24:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 45E586B0089 for ; Fri, 22 Nov 2024 18:24:31 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C42561A169D for ; Fri, 22 Nov 2024 23:24:30 +0000 (UTC) X-FDA: 82815312300.27.4D8C019 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by imf12.hostedemail.com (Postfix) with ESMTP id D68244000B for ; Fri, 22 Nov 2024 23:24:28 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=E5+vN0OX; spf=pass (imf12.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732317868; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=J6f5Cg5ni0UxlK+AJQaxldsRM/7KRVbxPRgVDGJ6GHg=; b=QDLiMxqje08fnT2qEfU+B52/JAbTTX8UhAz3DoRh4cw6wHkBrSHHxipKd/lpYclZ2jGxg6 YUhW8GPkosHIsAM6HRtIp/bwAEd5he/P2wTKghL0m59wQ55wb2n2jYim5X/JJv56smy1d+ E3uLRXf7WWUlu/Y4bnzwMR8Ge/6Ei9c= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=E5+vN0OX; spf=pass (imf12.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732317868; a=rsa-sha256; cv=none; b=ggImHGOyHXVau2zWx8AvwyF8Ag2x0NfnXvwE4wsI08imVBHWT7RBSUylrObpaOQ6WFrLfJ Czjt6wh5iv4i/sn/sbDC9hLmwUO6+uM39EpYa/VZLETGjpV0qi8PAD5ZIBnd+VhJ6LHeTK TJFUaAiJx21HYI04TW0GPNmX6Yrpsp4= Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-6e377e4aea3so21394467b3.3 for ; Fri, 22 Nov 2024 15:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732317868; x=1732922668; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J6f5Cg5ni0UxlK+AJQaxldsRM/7KRVbxPRgVDGJ6GHg=; b=E5+vN0OXxxGfW7Ig73XQDps701oTR4XgfMZSph5BonnG9+2XGNOuafmTkLg8gya0cB rcgaKJOYzQArhK7CnLQGH8spRNvfhmPyB6paj4Ls/16Td5W9E/kTsK3DmXAAR6R7JwKj TL3FtQqO0YxwmyRCiTJaA8SJFQoCHjrjtC/XOIOb0QXvfYqyQhZusywA0718HxBk3dJB VeFQCprrAepWrF+cMKhgKhtRkX8pIonTW7ftos7+3p9jr3jEK0n2Q+vmjaDsG/Kf2b2y ntLoVFZykwKZcCXDY6cIc91NECoLiw6RWT8hvUHYsu+YSQlTCOyFCsNpHLpCxOLU6XN0 kywQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732317868; x=1732922668; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J6f5Cg5ni0UxlK+AJQaxldsRM/7KRVbxPRgVDGJ6GHg=; b=sXdIYQIOuHWK3LosPyHOrgpCGXJzHbmsbZCu4PocIQ+Yzea/qEl+A8PT34H5cc47Pg HBSt0FUNpCxey4SKXzkj5y5q7xTmcl+QsFyWBYVz1lr7wpTCRa+sWUMvuLBMke8uY69K wrN/CYCdP58zKMVGtCuxj4EGgiIqemfL5J3yLp4OPg6H+bsjSliap9O1/DlVy9RIppUr XoJMBh110WFAUSAKWENGImUb/Cbhct7INj4HUiVxSZgF9dpgc81C1YzB71wzDKw5OgTE oyCo6KoBwkmimFRlAUgGBZ4l1haGvUFlmTJARxBANBKWTtvnfQ28KxDgn42no6499k6s CHwg== X-Forwarded-Encrypted: i=1; AJvYcCWNHo2XzL3EbjE/I3vcbgVQ3QKMJNtCZpC/i/YroabQwJQFW57qEPvKcGod8N4ZV0NBYykD2SVunw==@kvack.org X-Gm-Message-State: AOJu0Yw5nfnAZePS0OT6wEd7OsW7wW8p6tl/LCZEpTL7lZmun8+/1l5o ujg0fKCChkh2w1IwZ9UhHo0+9UfZv3YIiPjJUo2jId5EkAnz0qzC X-Gm-Gg: ASbGnctk+v1tWsIW/ni833hegRgitzadC60OOyx6YSwWlRWn6BcudsOUB/l35pJn/QJ zhPoX8erVWARLXfo9K7sdIl9kZaj0ECbbVW0bMeyemG+25QX6al4bStnhky9ItArSIsGLEP5OSa w4pBAYkuNrwONmqKRKsO7bCOEgImtTaisuAmumookJkkJcvcGKmox9s+XvZfdKHjF+lZk5212qJ Xztwj/rUkstC8WDfBcDkY6hG20Pv44bIWCgSiBfb0EpvZOb9/U+0urqZU+mr9uy7DTunmenJMkx iU0J5XX65w== X-Google-Smtp-Source: AGHT+IEnS3FrA3zTT50mBSWxAEndxeY552vJ6l3IoZ28ABUPNtO80E0sf2ZpGC6IcKOhHuSDRBLYgg== X-Received: by 2002:a05:690c:6807:b0:6e3:323f:d8fb with SMTP id 00721157ae682-6eee08a11f9mr64934617b3.14.1732317868047; Fri, 22 Nov 2024 15:24:28 -0800 (PST) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eee0094db9sm6794387b3.99.2024.11.22.15.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 15:24:27 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: shakeel.butt@linux.dev, jefflexu@linux.alibaba.com, josef@toxicpanda.com, bernd.schubert@fastmail.fm, linux-mm@kvack.org, kernel-team@meta.com Subject: [PATCH v6 3/5] fs/writeback: in wait_sb_inodes(), skip wait for AS_WRITEBACK_INDETERMINATE mappings Date: Fri, 22 Nov 2024 15:23:57 -0800 Message-ID: <20241122232359.429647-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241122232359.429647-1-joannelkoong@gmail.com> References: <20241122232359.429647-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D68244000B X-Stat-Signature: 3spuorswi5r1z68zr8innbzio4tyqsp7 X-Rspam-User: X-HE-Tag: 1732317868-282750 X-HE-Meta: U2FsdGVkX1/1rerUbz4YEAdhCfgPEj/umhbm4qi1d32dHzv4ABUg1hfBYNxWHrHexvOOj4e8YfCxB+FpJWCmsp7nfdz7MXFIqhp+kd3Y21GMbQ2asbO0GOsA/xFTByCYUeoox0OlMjWS13pZYfdowpjnyIVhsLeFIxv4aO95lkR1rTw11JtO/6PrxA4IjSpbIP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rhbBodn1vjZWzWqn/hQZxUZsxuhqDWedEIgMRBwOm4f+6sJenlOaN5reQ97EHQdqwgBNYZrLMWdfr6fK0LDy8PEOMkVecET06OABKdKIjh39ziecv+9Y3FrYlPcLlPN5T57HtrzcUsoguLzQ= 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: List-Subscribe: List-Unsubscribe: For filesystems with the AS_WRITEBACK_INDETERMINATE flag set, writeback operations may take an indeterminate time to complete. For example, writing data back to disk in FUSE filesystems depends on the userspace server successfully completing writeback. In this commit, wait_sb_inodes() skips waiting on writeback if the inode's mapping has AS_WRITEBACK_INDETERMINATE set, else sync(2) may take an indeterminate amount of time to complete. If the caller wishes to ensure the data for a mapping with the AS_WRITEBACK_INDETERMINATE flag set has actually been written back to disk, they should use fsync(2)/fdatasync(2) instead. Signed-off-by: Joanne Koong Reviewed-by: Jingbo Xu --- fs/fs-writeback.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d8bec3c1bb1f..ad192db17ce4 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2659,6 +2659,9 @@ static void wait_sb_inodes(struct super_block *sb) if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) continue; + if (mapping_writeback_indeterminate(mapping)) + continue; + spin_unlock_irq(&sb->s_inode_wblist_lock); spin_lock(&inode->i_lock); From patchwork Fri Nov 22 23:23:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13883706 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E3E2E6ADCB for ; Fri, 22 Nov 2024 23:24:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFFDE6B008C; Fri, 22 Nov 2024 18:24:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D61B26B0093; Fri, 22 Nov 2024 18:24:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB5DA6B0092; Fri, 22 Nov 2024 18:24:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 820B86B008A for ; Fri, 22 Nov 2024 18:24:32 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 30DC8A0891 for ; Fri, 22 Nov 2024 23:24:32 +0000 (UTC) X-FDA: 82815312384.30.D57DFBA Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by imf21.hostedemail.com (Postfix) with ESMTP id 29E3D1C0007 for ; Fri, 22 Nov 2024 23:24:29 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=l4hso+Ok; spf=pass (imf21.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732317870; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VEBVGrksPHjOfc4WHY5YwyTpscFate/a4s+cTyDDYoU=; b=nbrJb2/XSCsHVESQfYyyrYaGlF2MJwgYih3igKEMhvhw4q/vfuHyAIIEbzMDRWDYZeutSl fYr7MCErWC7FqASncTaQ7KvHztPddXt+GYWbC9jOksTt4vvsl1mJJ6th/1qIb92e6Eubxs aOkQpZDOtc9SAtgUiIG+/N8dXKgg+24= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732317870; a=rsa-sha256; cv=none; b=H3vcP/iBxkNI6lz6ETq4oXfYiOvZTBvIi2lCSRS9GCxuMCG2ntpPeB5yQdYNpupbLyS0ng /VSE3e3NoGi9azxzn/rt3PP8uQ4QTEJ4YOXV+tmjyMKJEGPVRh9Q256nL9mb5VYrgKSpdv HaXv7+gG3iW0OK8JS56IcC9oGjUGI6M= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=l4hso+Ok; spf=pass (imf21.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e388c39b2d0so2071770276.0 for ; Fri, 22 Nov 2024 15:24:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732317869; x=1732922669; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VEBVGrksPHjOfc4WHY5YwyTpscFate/a4s+cTyDDYoU=; b=l4hso+Okc9nIrtpKXog7uEtFPq7JMrkNqZrpdxPdti8plhLicQV8KxkZtB/XzMzDHt ZuNT3jV6idt8LhF+iJH9zro/hS5I9cFY3CcMHy84eymZcQX+vd7/8ZJTMijEOKL3/K6d 3CvbuA+80HW5XXQLvkhP74UeAkTupSs6M/mZzPuV+Xg+1Z7RwkC37kLP/ONwvRGnU8fe wJQ++pi2rXTZYu9IZAHJ8LaehKapRLAtrVF7Yru69yttfTE4kPGodVsjq0L7mN2+1FYF 4WTga+E/xVJLIZW7/Aa66iiN2IO7m0GOO2mRj7o9nmdeDZnFsezaOthRQkTIOiQyN5lH FIkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732317869; x=1732922669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VEBVGrksPHjOfc4WHY5YwyTpscFate/a4s+cTyDDYoU=; b=YFymKWKNGaC2IY9N1U1jNKyeGK20de8ATgsIlkPwrFFMf5GycUg4BZ/cgtn6f/pskb /FktAnQboNXoXghUYW4KQ5ygVKpPRWAhzCxXBU8+zv4H91nZe0I917LedZA7csmI/igA nEpzTNxpNNCVMGm/1oZ+8kyAqtOb2oNMbN1a3/zhUSU/jrXoeOm4LX231hU4W4Az6RC4 yuE2bC1C04wkJe2Xi4bLCgto/yDl5WFpLnHq6Y5ZbTvhUOJKj+Fg4ae/8Nnrlyrnl6oV tkhw6JTz1Q9A1jOid5MWe/6f0f5OoMga7OFQqFOqw+1uOgWZ6O6vzJAwJm8gll9MNb2J T2nA== X-Forwarded-Encrypted: i=1; AJvYcCUFXuphpcXOj6E1CdIi2CjLRCvKGBMxUxKKlJ9j0VsDYq+mMYg9PAMLev4HN8VLEJwBxCPUTrvLUg==@kvack.org X-Gm-Message-State: AOJu0YzMdZ3+/SsXEmIAhx+XP4VhmRhqFW+HoVmMpHGUbYDRBAY4PRKf fc3riITVe6Nd+Rx+++MZ3ruhImVaWZKI90qHN+hOlVlSJ6Cu7sYj X-Gm-Gg: ASbGncvlAqYWSMzy5mf0Wo/2XWJLFuL5oe4dVgQAxzXYSNn+m26W2FE0CNY4CIwLJEf SB/M7TffDgICGpvlT46CWoDIh69+QglnXepL2K27JCM6tNG3/hyc+s5TPzSqQm5HRpbeybpbYaP x79ojZITHUXoxePOa+aErxx0hhTgoi1sBUKWAvlFFbMJib8nGblCeacf4jQsbKTcFy+Qm4zPUQG 1p4Qi7IyWWUALTnrAOgktiGwsnKEQsApFKqylwJJtgIVKCV8hF5aNSz+8Adz2JxxVn8e3gU72CP Ct1E/xAWXw== X-Google-Smtp-Source: AGHT+IFqmAlC0SDQCwdmjhSHUlnQkK2XB4yL/Hv+xmhGPIMjC7dibMuwLQyjuqRbligoAGkvKR8vfw== X-Received: by 2002:a25:720b:0:b0:e38:85ec:9f28 with SMTP id 3f1490d57ef6-e38e182add6mr8426271276.25.1732317869472; Fri, 22 Nov 2024 15:24:29 -0800 (PST) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e38f609c74esm874073276.35.2024.11.22.15.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 15:24:29 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: shakeel.butt@linux.dev, jefflexu@linux.alibaba.com, josef@toxicpanda.com, bernd.schubert@fastmail.fm, linux-mm@kvack.org, kernel-team@meta.com Subject: [PATCH v6 4/5] mm/migrate: skip migrating folios under writeback with AS_WRITEBACK_INDETERMINATE mappings Date: Fri, 22 Nov 2024 15:23:58 -0800 Message-ID: <20241122232359.429647-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241122232359.429647-1-joannelkoong@gmail.com> References: <20241122232359.429647-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 29E3D1C0007 X-Stat-Signature: 9kpus5gdfbd6aa5x4n1u7bz7r8zwamw6 X-HE-Tag: 1732317869-625002 X-HE-Meta: U2FsdGVkX1+sgOmAKE0tJe53cVpAj+5Y/LIRW/eqcwb3h11fPPTQNBd8tCS8wpl4C8bIwItzND/wEop4/XqAuA+fHpxsl5bB+3tsEu2lsQjTTt+GFX+o0LopDPMegSe7yOI3VWBpDdsgWtx+kh6Ofxd9p3kqBQ8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sm1ooHaH3is8S0cWVPrr3oH0evVBDayzjpqTnQJXVoiYuCGrKEOULPM7TP5C3tanLHfBlpkHF7myVbXfLnd0iLYYVpyoaOJWJuowie+kMRuTVa+TUXilFxkWbFyU2K3Md9kls+01MeJlE6fZZZV9/UYg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000102, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: For migrations called in MIGRATE_SYNC mode, skip migrating the folio if it is under writeback and has the AS_WRITEBACK_INDETERMINATE flag set on its mapping. If the AS_WRITEBACK_INDETERMINATE flag is set on the mapping, the writeback may take an indeterminate amount of time to complete, and waits may get stuck. Signed-off-by: Joanne Koong Reviewed-by: Shakeel Butt --- mm/migrate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index df91248755e4..fe73284e5246 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1260,7 +1260,10 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, */ switch (mode) { case MIGRATE_SYNC: - break; + if (!src->mapping || + !mapping_writeback_indeterminate(src->mapping)) + break; + fallthrough; default: rc = -EBUSY; goto out; From patchwork Fri Nov 22 23:23:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13883707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DE41E6ADCB for ; Fri, 22 Nov 2024 23:24:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63B266B0092; Fri, 22 Nov 2024 18:24:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E79A6B0093; Fri, 22 Nov 2024 18:24:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 413466B0095; Fri, 22 Nov 2024 18:24:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1B5EA6B0092 for ; Fri, 22 Nov 2024 18:24:35 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9A7091608F7 for ; Fri, 22 Nov 2024 23:24:34 +0000 (UTC) X-FDA: 82815312468.11.1AF874F Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by imf15.hostedemail.com (Postfix) with ESMTP id AE90CA0004 for ; Fri, 22 Nov 2024 23:24:32 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cPTy+lCU; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732317872; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=E9JVNPyYm/QyejD35mtSNrdYYKrlXcB+rCT1AAYKOoM=; b=VkYOOsyiVTToK+kBWEzqBxMRBAEY4A1moztUJULoIRDsTzI5qEEjdgkJ7GkjGpzC1YDp67 /X+1/FweQZfX/xg3oPlET5e3OXW9rWk4h9CUGedv0TLrWL9zcevEc8PfcZ+I44pe741I9l qt5KchElw5Zd3L+tTCbHEYrRpMOxvj0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cPTy+lCU; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732317872; a=rsa-sha256; cv=none; b=i39moKYOUJJIsRtugPkM2P1uhuuBWRf6vDuIZTwCz6t90Ybw//KzfnGJFhzR5tTIXCcJ7n k7Q50yzfDNN3inPw4BsYlOIDiagtYTU5nNC6F+9WO9eOblWsbpBiBpcNnoYqINToi0Iodq UlsTbd4ydGihOPBKxXF62VkFpeciif8= Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6eeca49d8baso21004547b3.0 for ; Fri, 22 Nov 2024 15:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732317872; x=1732922672; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E9JVNPyYm/QyejD35mtSNrdYYKrlXcB+rCT1AAYKOoM=; b=cPTy+lCUmABvuQNb0BU0pX3IDA77zJVDIRFgNyFoDAkXKT1tbtz9OFPs8J+qsq9jS/ fh4tIDaq5oRFwGG2wcD/LMgumde9Cq+s+z/ENhMRS1FHHb4Ar0kNCnTujDEIhpsFpZo0 YT+SQL9Q1RY1Z818wDq3E59JMvOCtfVtDilcZZz4IPmgDIAld4Ogw0yHNz8CM8aIbkW5 hBvDEQaX6aFJ6watTdrsqjjV8ac377MMTiXe5CTr2CuJ7DjS4Woqo4rf15L7QLpgW7t3 89nkQRs9Jpd97Pq47yf34R7xn0wvvuKx688mbV/+VZQGMWCQy6BvdEXyGrK478SL7G6P WfMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732317872; x=1732922672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E9JVNPyYm/QyejD35mtSNrdYYKrlXcB+rCT1AAYKOoM=; b=B5y4u9a8gGxNHB922IIJEaUlZxaiJAOITQDXZcXfPvFNaddhNuDdVH3sQlm1ng6TTW bx+9TsBUaLO0VA5uoCsVgjqpyXmj6QTif/5yyE6Wx0eedJGjvFtU+Ie9U806v4xNRzsr NrtXdeewn6IqypD2L+tex8IXwUGLf8Nl/X9wlhuLrPQ+9B5T/FPlDyiVSm0Swqqknz5k sXVR3SacSUvxiL6fZuojK+/hAjsKgFi/Au44KqxXmQG3piIbddhIoMSII31ggJEWuiSs l2QRiy0ZGnfqfYxND8MoEt8jQ2V+uRlQw+9ub67nzdQQuJEyhxVBOnk+mz+qXdSh1B8O Uq8w== X-Forwarded-Encrypted: i=1; AJvYcCUlPYcHggZB3qy/+zSD7YAOWaekrEECHr+ePY9sSuR+ArPcRzLzvOBUhG7WZL0fjSeLhnW+Ej7bAg==@kvack.org X-Gm-Message-State: AOJu0Yy7wdhHd23geX4OEEscOdY4Ip5SIFV6eSMRLKYLNGMjVFMt+MKm kI3oZlFrCcSqeJcJeTv+mxvr4C4Ft1IYOLPXkxbuAvIX6k+tLq2H X-Gm-Gg: ASbGncth3N1I3ghHzJrX3d3W76ACDgl3rcKwFqmDZt9uucJENmk7l2jRcp/nqj0CcJ8 WDW8vl7UidhKo91WD2XuH9l00d5cqLk8VM5Pz5smJqoROs3l0hXnqQSbJJeTDSYczZsUBh6hB2p E/bckux8XiIIgAf/9nrnejy7YHfU3DHh6zpB7y0RXdNtOmrKNhlJYJSl+5iPJTKKRqFxFBjpuv1 gyQJFtxCTpsJBrDSR6qrWO/fmEIoHQ6RQ+2y/aVigi3hSf6cvN+2hfbyeSn8TZd8JJFQ6jWesJe PJYDirGs X-Google-Smtp-Source: AGHT+IFJWthOFckJcmHEjim+PgNKr4M5VHJtM7w3iVmCFtJehmT32r3fjFwSh1ZcAtWqaMxwgjJa8A== X-Received: by 2002:a05:690c:3686:b0:6e5:adf8:b0a8 with SMTP id 00721157ae682-6eee08c3f73mr53176627b3.6.1732317871785; Fri, 22 Nov 2024 15:24:31 -0800 (PST) Received: from localhost (fwdproxy-nha-001.fbsv.net. [2a03:2880:25ff:1::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eedfe153e3sm6832367b3.22.2024.11.22.15.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 15:24:31 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: shakeel.butt@linux.dev, jefflexu@linux.alibaba.com, josef@toxicpanda.com, bernd.schubert@fastmail.fm, linux-mm@kvack.org, kernel-team@meta.com Subject: [PATCH v6 5/5] fuse: remove tmp folio for writebacks and internal rb tree Date: Fri, 22 Nov 2024 15:23:59 -0800 Message-ID: <20241122232359.429647-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241122232359.429647-1-joannelkoong@gmail.com> References: <20241122232359.429647-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: AE90CA0004 X-Stat-Signature: rqccc1xxkwr8h5jt1qkkdkbhuti8ujpd X-HE-Tag: 1732317872-912922 X-HE-Meta: U2FsdGVkX1+vqCop+6pFHXGXakqbOKKNi5j8cgRVhBc7NTXDNKFDDs6oi3PzQMiqfXuFgfV5bJmmLIXFypaAIOkbuv7GQJfScEmsqnjnerMZQS1Irr5AIXPxM96L6xZ7CsjeNwXeJZ4lRyncUrZMetlI1YiHIUkZKwnnJuW0q6PsOYjmeTYT9kJCHdCE/yp8v4WwsmWM4PKK+TWXq/ubShLFTno6HsOdow5OPwVmAfHBB5aPv6f3ftpJYtWEHdAV1jmfGGeVGcdllBHTssSJGIRMZby93jrXJSTiWkNzBoLKOU6VCnvR/u9z6nUlsWMrCfD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ner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In the current FUSE writeback design (see commit 3be5a52b30aa ("fuse: support writable mmap")), a temp page is allocated for every dirty page to be written back, the contents of the dirty page are copied over to the temp page, and the temp page gets handed to the server to write back. This is done so that writeback may be immediately cleared on the dirty page, and this in turn is done for two reasons: a) in order to mitigate the following deadlock scenario that may arise if reclaim waits on writeback on the dirty page to complete: * single-threaded FUSE server is in the middle of handling a request that needs a memory allocation * memory allocation triggers direct reclaim * direct reclaim waits on a folio under writeback * the FUSE server can't write back the folio since it's stuck in direct reclaim b) in order to unblock internal (eg sync, page compaction) waits on writeback without needing the server to complete writing back to disk, which may take an indeterminate amount of time. With a recent change that added AS_WRITEBACK_INDETERMINATE and mitigates the situations described above, FUSE writeback does not need to use temp pages if it sets AS_WRITEBACK_INDETERMINATE on its inode mappings. This commit sets AS_WRITEBACK_INDETERMINATE on the inode mappings and removes the temporary pages + extra copying and the internal rb tree. fio benchmarks -- (using averages observed from 10 runs, throwing away outliers) Setup: sudo mount -t tmpfs -o size=30G tmpfs ~/tmp_mount ./libfuse/build/example/passthrough_ll -o writeback -o max_threads=4 -o source=~/tmp_mount ~/fuse_mount fio --name=writeback --ioengine=sync --rw=write --bs={1k,4k,1M} --size=2G --numjobs=2 --ramp_time=30 --group_reporting=1 --directory=/root/fuse_mount bs = 1k 4k 1M Before 351 MiB/s 1818 MiB/s 1851 MiB/s After 341 MiB/s 2246 MiB/s 2685 MiB/s % diff -3% 23% 45% Signed-off-by: Joanne Koong --- fs/fuse/file.c | 360 ++++------------------------------------------- fs/fuse/fuse_i.h | 3 - 2 files changed, 28 insertions(+), 335 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 88d0946b5bc9..1970d1a699a6 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -415,89 +415,11 @@ u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id) struct fuse_writepage_args { struct fuse_io_args ia; - struct rb_node writepages_entry; struct list_head queue_entry; - struct fuse_writepage_args *next; struct inode *inode; struct fuse_sync_bucket *bucket; }; -static struct fuse_writepage_args *fuse_find_writeback(struct fuse_inode *fi, - pgoff_t idx_from, pgoff_t idx_to) -{ - struct rb_node *n; - - n = fi->writepages.rb_node; - - while (n) { - struct fuse_writepage_args *wpa; - pgoff_t curr_index; - - wpa = rb_entry(n, struct fuse_writepage_args, writepages_entry); - WARN_ON(get_fuse_inode(wpa->inode) != fi); - curr_index = wpa->ia.write.in.offset >> PAGE_SHIFT; - if (idx_from >= curr_index + wpa->ia.ap.num_folios) - n = n->rb_right; - else if (idx_to < curr_index) - n = n->rb_left; - else - return wpa; - } - return NULL; -} - -/* - * Check if any page in a range is under writeback - */ -static bool fuse_range_is_writeback(struct inode *inode, pgoff_t idx_from, - pgoff_t idx_to) -{ - struct fuse_inode *fi = get_fuse_inode(inode); - bool found; - - if (RB_EMPTY_ROOT(&fi->writepages)) - return false; - - spin_lock(&fi->lock); - found = fuse_find_writeback(fi, idx_from, idx_to); - spin_unlock(&fi->lock); - - return found; -} - -static inline bool fuse_page_is_writeback(struct inode *inode, pgoff_t index) -{ - return fuse_range_is_writeback(inode, index, index); -} - -/* - * Wait for page writeback to be completed. - * - * Since fuse doesn't rely on the VM writeback tracking, this has to - * use some other means. - */ -static void fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index) -{ - struct fuse_inode *fi = get_fuse_inode(inode); - - wait_event(fi->page_waitq, !fuse_page_is_writeback(inode, index)); -} - -static inline bool fuse_folio_is_writeback(struct inode *inode, - struct folio *folio) -{ - pgoff_t last = folio_next_index(folio) - 1; - return fuse_range_is_writeback(inode, folio_index(folio), last); -} - -static void fuse_wait_on_folio_writeback(struct inode *inode, - struct folio *folio) -{ - struct fuse_inode *fi = get_fuse_inode(inode); - - wait_event(fi->page_waitq, !fuse_folio_is_writeback(inode, folio)); -} - /* * Wait for all pending writepages on the inode to finish. * @@ -886,13 +808,6 @@ static int fuse_do_readfolio(struct file *file, struct folio *folio) ssize_t res; u64 attr_ver; - /* - * With the temporary pages that are used to complete writeback, we can - * have writeback that extends beyond the lifetime of the folio. So - * make sure we read a properly synced folio. - */ - fuse_wait_on_folio_writeback(inode, folio); - attr_ver = fuse_get_attr_version(fm->fc); /* Don't overflow end offset */ @@ -1003,17 +918,12 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) static void fuse_readahead(struct readahead_control *rac) { struct inode *inode = rac->mapping->host; - struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_conn *fc = get_fuse_conn(inode); unsigned int max_pages, nr_pages; - pgoff_t first = readahead_index(rac); - pgoff_t last = first + readahead_count(rac) - 1; if (fuse_is_bad(inode)) return; - wait_event(fi->page_waitq, !fuse_range_is_writeback(inode, first, last)); - max_pages = min_t(unsigned int, fc->max_pages, fc->max_read / PAGE_SIZE); @@ -1172,7 +1082,7 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia, int err; for (i = 0; i < ap->num_folios; i++) - fuse_wait_on_folio_writeback(inode, ap->folios[i]); + folio_wait_writeback(ap->folios[i]); fuse_write_args_fill(ia, ff, pos, count); ia->write.in.flags = fuse_write_flags(iocb); @@ -1622,7 +1532,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, return res; } } - if (!cuse && fuse_range_is_writeback(inode, idx_from, idx_to)) { + if (!cuse && filemap_range_has_writeback(mapping, pos, (pos + count - 1))) { if (!write) inode_lock(inode); fuse_sync_writes(inode); @@ -1819,38 +1729,34 @@ static ssize_t fuse_splice_write(struct pipe_inode_info *pipe, struct file *out, static void fuse_writepage_free(struct fuse_writepage_args *wpa) { struct fuse_args_pages *ap = &wpa->ia.ap; - int i; if (wpa->bucket) fuse_sync_bucket_dec(wpa->bucket); - for (i = 0; i < ap->num_folios; i++) - folio_put(ap->folios[i]); - fuse_file_put(wpa->ia.ff, false); kfree(ap->folios); kfree(wpa); } -static void fuse_writepage_finish_stat(struct inode *inode, struct folio *folio) -{ - struct backing_dev_info *bdi = inode_to_bdi(inode); - - dec_wb_stat(&bdi->wb, WB_WRITEBACK); - node_stat_sub_folio(folio, NR_WRITEBACK_TEMP); - wb_writeout_inc(&bdi->wb); -} - static void fuse_writepage_finish(struct fuse_writepage_args *wpa) { struct fuse_args_pages *ap = &wpa->ia.ap; struct inode *inode = wpa->inode; struct fuse_inode *fi = get_fuse_inode(inode); + struct backing_dev_info *bdi = inode_to_bdi(inode); int i; - for (i = 0; i < ap->num_folios; i++) - fuse_writepage_finish_stat(inode, ap->folios[i]); + for (i = 0; i < ap->num_folios; i++) { + /* + * Benchmarks showed that ending writeback within the + * scope of the fi->lock alleviates xarray lock + * contention and noticeably improves performance. + */ + folio_end_writeback(ap->folios[i]); + dec_wb_stat(&bdi->wb, WB_WRITEBACK); + wb_writeout_inc(&bdi->wb); + } wake_up(&fi->page_waitq); } @@ -1861,7 +1767,6 @@ static void fuse_send_writepage(struct fuse_mount *fm, __releases(fi->lock) __acquires(fi->lock) { - struct fuse_writepage_args *aux, *next; struct fuse_inode *fi = get_fuse_inode(wpa->inode); struct fuse_write_in *inarg = &wpa->ia.write.in; struct fuse_args *args = &wpa->ia.ap.args; @@ -1898,19 +1803,8 @@ __acquires(fi->lock) out_free: fi->writectr--; - rb_erase(&wpa->writepages_entry, &fi->writepages); fuse_writepage_finish(wpa); spin_unlock(&fi->lock); - - /* After rb_erase() aux request list is private */ - for (aux = wpa->next; aux; aux = next) { - next = aux->next; - aux->next = NULL; - fuse_writepage_finish_stat(aux->inode, - aux->ia.ap.folios[0]); - fuse_writepage_free(aux); - } - fuse_writepage_free(wpa); spin_lock(&fi->lock); } @@ -1938,43 +1832,6 @@ __acquires(fi->lock) } } -static struct fuse_writepage_args *fuse_insert_writeback(struct rb_root *root, - struct fuse_writepage_args *wpa) -{ - pgoff_t idx_from = wpa->ia.write.in.offset >> PAGE_SHIFT; - pgoff_t idx_to = idx_from + wpa->ia.ap.num_folios - 1; - struct rb_node **p = &root->rb_node; - struct rb_node *parent = NULL; - - WARN_ON(!wpa->ia.ap.num_folios); - while (*p) { - struct fuse_writepage_args *curr; - pgoff_t curr_index; - - parent = *p; - curr = rb_entry(parent, struct fuse_writepage_args, - writepages_entry); - WARN_ON(curr->inode != wpa->inode); - curr_index = curr->ia.write.in.offset >> PAGE_SHIFT; - - if (idx_from >= curr_index + curr->ia.ap.num_folios) - p = &(*p)->rb_right; - else if (idx_to < curr_index) - p = &(*p)->rb_left; - else - return curr; - } - - rb_link_node(&wpa->writepages_entry, parent, p); - rb_insert_color(&wpa->writepages_entry, root); - return NULL; -} - -static void tree_insert(struct rb_root *root, struct fuse_writepage_args *wpa) -{ - WARN_ON(fuse_insert_writeback(root, wpa)); -} - static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args, int error) { @@ -1994,41 +1851,6 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args, if (!fc->writeback_cache) fuse_invalidate_attr_mask(inode, FUSE_STATX_MODIFY); spin_lock(&fi->lock); - rb_erase(&wpa->writepages_entry, &fi->writepages); - while (wpa->next) { - struct fuse_mount *fm = get_fuse_mount(inode); - struct fuse_write_in *inarg = &wpa->ia.write.in; - struct fuse_writepage_args *next = wpa->next; - - wpa->next = next->next; - next->next = NULL; - tree_insert(&fi->writepages, next); - - /* - * Skip fuse_flush_writepages() to make it easy to crop requests - * based on primary request size. - * - * 1st case (trivial): there are no concurrent activities using - * fuse_set/release_nowrite. Then we're on safe side because - * fuse_flush_writepages() would call fuse_send_writepage() - * anyway. - * - * 2nd case: someone called fuse_set_nowrite and it is waiting - * now for completion of all in-flight requests. This happens - * rarely and no more than once per page, so this should be - * okay. - * - * 3rd case: someone (e.g. fuse_do_setattr()) is in the middle - * of fuse_set_nowrite..fuse_release_nowrite section. The fact - * that fuse_set_nowrite returned implies that all in-flight - * requests were completed along with all of their secondary - * requests. Further primary requests are blocked by negative - * writectr. Hence there cannot be any in-flight requests and - * no invocations of fuse_writepage_end() while we're in - * fuse_set_nowrite..fuse_release_nowrite section. - */ - fuse_send_writepage(fm, next, inarg->offset + inarg->size); - } fi->writectr--; fuse_writepage_finish(wpa); spin_unlock(&fi->lock); @@ -2115,19 +1937,16 @@ static void fuse_writepage_add_to_bucket(struct fuse_conn *fc, } static void fuse_writepage_args_page_fill(struct fuse_writepage_args *wpa, struct folio *folio, - struct folio *tmp_folio, uint32_t folio_index) + uint32_t folio_index) { struct inode *inode = folio->mapping->host; struct fuse_args_pages *ap = &wpa->ia.ap; - folio_copy(tmp_folio, folio); - - ap->folios[folio_index] = tmp_folio; + ap->folios[folio_index] = folio; ap->descs[folio_index].offset = 0; ap->descs[folio_index].length = PAGE_SIZE; inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); - node_stat_add_folio(tmp_folio, NR_WRITEBACK_TEMP); } static struct fuse_writepage_args *fuse_writepage_args_setup(struct folio *folio, @@ -2162,18 +1981,12 @@ static int fuse_writepage_locked(struct folio *folio) struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_writepage_args *wpa; struct fuse_args_pages *ap; - struct folio *tmp_folio; struct fuse_file *ff; - int error = -ENOMEM; + int error = -EIO; - tmp_folio = folio_alloc(GFP_NOFS | __GFP_HIGHMEM, 0); - if (!tmp_folio) - goto err; - - error = -EIO; ff = fuse_write_file_get(fi); if (!ff) - goto err_nofile; + goto err; wpa = fuse_writepage_args_setup(folio, ff); error = -ENOMEM; @@ -2184,22 +1997,17 @@ static int fuse_writepage_locked(struct folio *folio) ap->num_folios = 1; folio_start_writeback(folio); - fuse_writepage_args_page_fill(wpa, folio, tmp_folio, 0); + fuse_writepage_args_page_fill(wpa, folio, 0); spin_lock(&fi->lock); - tree_insert(&fi->writepages, wpa); list_add_tail(&wpa->queue_entry, &fi->queued_writes); fuse_flush_writepages(inode); spin_unlock(&fi->lock); - folio_end_writeback(folio); - return 0; err_writepage_args: fuse_file_put(ff, false); -err_nofile: - folio_put(tmp_folio); err: mapping_set_error(folio->mapping, error); return error; @@ -2209,7 +2017,6 @@ struct fuse_fill_wb_data { struct fuse_writepage_args *wpa; struct fuse_file *ff; struct inode *inode; - struct folio **orig_folios; unsigned int max_folios; }; @@ -2244,69 +2051,11 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data) struct fuse_writepage_args *wpa = data->wpa; struct inode *inode = data->inode; struct fuse_inode *fi = get_fuse_inode(inode); - int num_folios = wpa->ia.ap.num_folios; - int i; spin_lock(&fi->lock); list_add_tail(&wpa->queue_entry, &fi->queued_writes); fuse_flush_writepages(inode); spin_unlock(&fi->lock); - - for (i = 0; i < num_folios; i++) - folio_end_writeback(data->orig_folios[i]); -} - -/* - * Check under fi->lock if the page is under writeback, and insert it onto the - * rb_tree if not. Otherwise iterate auxiliary write requests, to see if there's - * one already added for a page at this offset. If there's none, then insert - * this new request onto the auxiliary list, otherwise reuse the existing one by - * swapping the new temp page with the old one. - */ -static bool fuse_writepage_add(struct fuse_writepage_args *new_wpa, - struct folio *folio) -{ - struct fuse_inode *fi = get_fuse_inode(new_wpa->inode); - struct fuse_writepage_args *tmp; - struct fuse_writepage_args *old_wpa; - struct fuse_args_pages *new_ap = &new_wpa->ia.ap; - - WARN_ON(new_ap->num_folios != 0); - new_ap->num_folios = 1; - - spin_lock(&fi->lock); - old_wpa = fuse_insert_writeback(&fi->writepages, new_wpa); - if (!old_wpa) { - spin_unlock(&fi->lock); - return true; - } - - for (tmp = old_wpa->next; tmp; tmp = tmp->next) { - pgoff_t curr_index; - - WARN_ON(tmp->inode != new_wpa->inode); - curr_index = tmp->ia.write.in.offset >> PAGE_SHIFT; - if (curr_index == folio->index) { - WARN_ON(tmp->ia.ap.num_folios != 1); - swap(tmp->ia.ap.folios[0], new_ap->folios[0]); - break; - } - } - - if (!tmp) { - new_wpa->next = old_wpa->next; - old_wpa->next = new_wpa; - } - - spin_unlock(&fi->lock); - - if (tmp) { - fuse_writepage_finish_stat(new_wpa->inode, - folio); - fuse_writepage_free(new_wpa); - } - - return false; } static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio, @@ -2315,15 +2064,6 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio, { WARN_ON(!ap->num_folios); - /* - * Being under writeback is unlikely but possible. For example direct - * read to an mmaped fuse file will set the page dirty twice; once when - * the pages are faulted with get_user_pages(), and then after the read - * completed. - */ - if (fuse_folio_is_writeback(data->inode, folio)) - return true; - /* Reached max pages */ if (ap->num_folios == fc->max_pages) return true; @@ -2333,7 +2073,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio, return true; /* Discontinuity */ - if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio)) + if (ap->folios[ap->num_folios - 1]->index + 1 != folio_index(folio)) return true; /* Need to grow the pages array? If so, did the expansion fail? */ @@ -2352,7 +2092,6 @@ static int fuse_writepages_fill(struct folio *folio, struct inode *inode = data->inode; struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_conn *fc = get_fuse_conn(inode); - struct folio *tmp_folio; int err; if (!data->ff) { @@ -2367,54 +2106,23 @@ static int fuse_writepages_fill(struct folio *folio, data->wpa = NULL; } - err = -ENOMEM; - tmp_folio = folio_alloc(GFP_NOFS | __GFP_HIGHMEM, 0); - if (!tmp_folio) - goto out_unlock; - - /* - * The page must not be redirtied until the writeout is completed - * (i.e. userspace has sent a reply to the write request). Otherwise - * there could be more than one temporary page instance for each real - * page. - * - * This is ensured by holding the page lock in page_mkwrite() while - * checking fuse_page_is_writeback(). We already hold the page lock - * since clear_page_dirty_for_io() and keep it held until we add the - * request to the fi->writepages list and increment ap->num_folios. - * After this fuse_page_is_writeback() will indicate that the page is - * under writeback, so we can release the page lock. - */ if (data->wpa == NULL) { err = -ENOMEM; wpa = fuse_writepage_args_setup(folio, data->ff); - if (!wpa) { - folio_put(tmp_folio); + if (!wpa) goto out_unlock; - } fuse_file_get(wpa->ia.ff); data->max_folios = 1; ap = &wpa->ia.ap; } folio_start_writeback(folio); - fuse_writepage_args_page_fill(wpa, folio, tmp_folio, ap->num_folios); - data->orig_folios[ap->num_folios] = folio; + fuse_writepage_args_page_fill(wpa, folio, ap->num_folios); err = 0; - if (data->wpa) { - /* - * Protected by fi->lock against concurrent access by - * fuse_page_is_writeback(). - */ - spin_lock(&fi->lock); - ap->num_folios++; - spin_unlock(&fi->lock); - } else if (fuse_writepage_add(wpa, folio)) { + ap->num_folios++; + if (!data->wpa) data->wpa = wpa; - } else { - folio_end_writeback(folio); - } out_unlock: folio_unlock(folio); @@ -2441,13 +2149,6 @@ static int fuse_writepages(struct address_space *mapping, data.wpa = NULL; data.ff = NULL; - err = -ENOMEM; - data.orig_folios = kcalloc(fc->max_pages, - sizeof(struct folio *), - GFP_NOFS); - if (!data.orig_folios) - goto out; - err = write_cache_pages(mapping, wbc, fuse_writepages_fill, &data); if (data.wpa) { WARN_ON(!data.wpa->ia.ap.num_folios); @@ -2456,7 +2157,6 @@ static int fuse_writepages(struct address_space *mapping, if (data.ff) fuse_file_put(data.ff, false); - kfree(data.orig_folios); out: return err; } @@ -2481,8 +2181,6 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping, if (IS_ERR(folio)) goto error; - fuse_wait_on_page_writeback(mapping->host, folio->index); - if (folio_test_uptodate(folio) || len >= folio_size(folio)) goto success; /* @@ -2545,13 +2243,9 @@ static int fuse_launder_folio(struct folio *folio) { int err = 0; if (folio_clear_dirty_for_io(folio)) { - struct inode *inode = folio->mapping->host; - - /* Serialize with pending writeback for the same page */ - fuse_wait_on_page_writeback(inode, folio->index); err = fuse_writepage_locked(folio); if (!err) - fuse_wait_on_page_writeback(inode, folio->index); + folio_wait_writeback(folio); } return err; } @@ -2595,7 +2289,7 @@ static vm_fault_t fuse_page_mkwrite(struct vm_fault *vmf) return VM_FAULT_NOPAGE; } - fuse_wait_on_folio_writeback(inode, folio); + folio_wait_writeback(folio); return VM_FAULT_LOCKED; } @@ -3413,9 +3107,12 @@ static const struct address_space_operations fuse_file_aops = { void fuse_init_file_inode(struct inode *inode, unsigned int flags) { struct fuse_inode *fi = get_fuse_inode(inode); + struct fuse_conn *fc = get_fuse_conn(inode); inode->i_fop = &fuse_file_operations; inode->i_data.a_ops = &fuse_file_aops; + if (fc->writeback_cache) + mapping_set_writeback_indeterminate(&inode->i_data); INIT_LIST_HEAD(&fi->write_files); INIT_LIST_HEAD(&fi->queued_writes); @@ -3423,7 +3120,6 @@ void fuse_init_file_inode(struct inode *inode, unsigned int flags) fi->iocachectr = 0; init_waitqueue_head(&fi->page_waitq); init_waitqueue_head(&fi->direct_io_waitq); - fi->writepages = RB_ROOT; if (IS_ENABLED(CONFIG_FUSE_DAX)) fuse_dax_inode_init(inode, flags); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 74744c6f2860..23736c5c64c1 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -141,9 +141,6 @@ struct fuse_inode { /* waitq for direct-io completion */ wait_queue_head_t direct_io_waitq; - - /* List of writepage requestst (pending or sent) */ - struct rb_root writepages; }; /* readdir cache (directory only) */