From patchwork Thu Nov 7 23:56:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13867333 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 4A5EBD5D695 for ; Thu, 7 Nov 2024 23:56:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA3976B00A6; Thu, 7 Nov 2024 18:56:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C53176B00A7; Thu, 7 Nov 2024 18:56:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF59E6B00A8; Thu, 7 Nov 2024 18:56:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 94E2B6B00A6 for ; Thu, 7 Nov 2024 18:56:32 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4E6D31A03C3 for ; Thu, 7 Nov 2024 23:56:32 +0000 (UTC) X-FDA: 82760959386.08.8BE8078 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by imf14.hostedemail.com (Postfix) with ESMTP id 4681B100004 for ; Thu, 7 Nov 2024 23:55:50 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YAUU2NUl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.171 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731023665; a=rsa-sha256; cv=none; b=6MLy9tT6BtTb+t5XKnxNfx0I/Oo/P5BCb1o3oIGf3Eh4xP/CozNxTOpAyt7BokTxlGU7da 64hGyMhyJxZhPLgaxWFypZnXwusBdLvLfTMuhQEO8BXXHtPNVVhB0pqQj6xTAJ43GZiIUe F842i5HCD6JOfXlLkBIpaGKFKAomZl4= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YAUU2NUl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.171 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=1731023665; 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=ikpYM/WWgMZzee5LK9ccNIkwppCcSDNp4r5PwHAnOS0=; b=C2aGz5m/2pcam65PrrvhOBwu4/e8+3+G+8IG2iXK/LUiZMpmdHh13BpRBCQbRUfGuzz/p0 wCS+bxIrb6edpMMFV6uNdIWXb45aiPnSM3J42Fy/0TAwXY/bi57QDhoebbbGRTU1o0BGk/ 8nC+KnQPaw25oLRCXxj6kFZbK9zeztw= Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-6e5e5c43497so12746867b3.3 for ; Thu, 07 Nov 2024 15:56:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731023789; x=1731628589; 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=ikpYM/WWgMZzee5LK9ccNIkwppCcSDNp4r5PwHAnOS0=; b=YAUU2NUlNMAuzxayfZx4BhAbDHwVgG5hyjkyga5pA1bEZtGjaExci+P04Ca4H+Mnal X28kbcEkrcHJ+liH4h+Xvn6WVl87mYOT6/Ll80f4GC7A5HC5HRmT2/4D7FjQDz9vKsiB 7VqoqKqN6G145o/0HObOcKyTW1jKxcEshqWjG1XYd4dsneWQ9scVhzt874rjav0161jZ D+Ptld5nbySQnm6mrpno4+RkUx4CggM6zc71a+WCZEV253PNrW75ZQdVujgVu2CBfbXN icMJdL2yRr5xD3ENNOqv0CEfGfs+k30cPa9bto4Rj/UqNo7Vf1WC/RlAGKCP+m9tB7+M eRXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731023789; x=1731628589; 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=ikpYM/WWgMZzee5LK9ccNIkwppCcSDNp4r5PwHAnOS0=; b=bZJE8BBW9QC/2tSkcHsdWDZafSR7hA5lTRc8ZpjdZOCM1Jzlug8o+22EBVH4z3coF7 cVH2ZOWCcyK2ddJKJYMlWcWYWmh9BwM5Hz7XuXupGcZ8gcyrwNGYlFdK4tThJgpDrsJs Lw3azCE7WpCki/X2k3vyliNxTb2bSoR0P5hwZYauWB93/wXhHVGXpaMcMPl2Q+XLvVpm KojLklmwY4HztDAz2d9URUKRbmSyMdSAthnuVEF3s4iy6mojgp6DRfBWvK0N21XRLIIS htKtAEU7hUKi2E1rNTzV1N/sh98lfCqsx0XbKVmTH1v5kV2rwGGM6PxDk1417G9t+caC 6ucQ== X-Forwarded-Encrypted: i=1; AJvYcCXgELfyDehhot7VwHCofgQN2G49Ino9x/9glqw9acMYYWy2VWOAExsMwrcqghqRH5Xa5+JI/2RQ3A==@kvack.org X-Gm-Message-State: AOJu0YxkAF7lCdBTyGNHf3p/ta8KrQzofcKoNJdufZ64mJ34c/YLLAmk VQ/IB4Ji6fxSTSO3Qwb9hmOEIm5MjPTU8ELIm/e/SkqFz4oaRTjm X-Google-Smtp-Source: AGHT+IE1RwTd0+7DYupIY1PYmqJOKwOZCXsEe05QepgoB+3JP5jig5elKW2UZmO9v9UgGqA6cNuR5A== X-Received: by 2002:a05:690c:6886:b0:6e5:b6a7:1640 with SMTP id 00721157ae682-6eaddfa967fmr10156897b3.42.1731023789401; Thu, 07 Nov 2024 15:56:29 -0800 (PST) Received: from localhost (fwdproxy-nha-002.fbsv.net. [2a03:2880:25ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eaceb7b234sm5007697b3.98.2024.11.07.15.56.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 15:56: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, linux-mm@kvack.org, bernd.schubert@fastmail.fm, kernel-team@meta.com Subject: [PATCH v4 1/6] mm: add AS_WRITEBACK_MAY_BLOCK mapping flag Date: Thu, 7 Nov 2024 15:56:09 -0800 Message-ID: <20241107235614.3637221-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241107235614.3637221-1-joannelkoong@gmail.com> References: <20241107235614.3637221-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4681B100004 X-Stat-Signature: np765b3fajsanjaod6eqeg3qwga7t673 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1731023750-463570 X-HE-Meta: U2FsdGVkX18xIuV1Tu2kMDcAPEb9BtIzqsVoi1ltEL9sO2uUnIcNQm8RPB8ye2YXN9oO7LbMHuW/eRcnx79IENmoutj31PBlcXD0Um78q7uOGW7nwLIXEiKzZbT02x4jnX35kiBBeneC6ZO1a/R6d7yu6GUNNPd4uC+8DlzDnbDEhUJIsPKNtE5j3F9o+wxwj6Mhc0jpzBxza2jgguNh16ZsQFBh7hGV3NmAmS0BM7pTcHm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aR49Zzk71q5OpbVGoLDK3YmFnojSNimpVSWHJaYhOcSkCjK+HZ+C3BXr/kLve2IxetfMkDNcutA== 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_MAY_BLOCK which filesystems may set to indicate that writeback operations may block or 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 --- include/linux/pagemap.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 68a5f1ff3301..eb5a7837e142 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_MAY_BLOCK = 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_may_block(struct address_space *mapping) +{ + set_bit(AS_WRITEBACK_MAY_BLOCK, &mapping->flags); +} + +static inline bool mapping_writeback_may_block(struct address_space *mapping) +{ + return test_bit(AS_WRITEBACK_MAY_BLOCK, &mapping->flags); +} + static inline gfp_t mapping_gfp_mask(struct address_space * mapping) { return mapping->gfp_mask;