From patchwork Thu Nov 7 19:16:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13866967 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 7B8C6D5D683 for ; Thu, 7 Nov 2024 19:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C45136B0083; Thu, 7 Nov 2024 14:17:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BCE826B0085; Thu, 7 Nov 2024 14:17:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A20116B0088; Thu, 7 Nov 2024 14:17:26 -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 82C886B0083 for ; Thu, 7 Nov 2024 14:17:26 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3ED6F1A0B08 for ; Thu, 7 Nov 2024 19:17:26 +0000 (UTC) X-FDA: 82760256600.30.475C3AE Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by imf17.hostedemail.com (Postfix) with ESMTP id BC9DE4002A for ; Thu, 7 Nov 2024 19:16:56 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=W50GZe9t; spf=pass (imf17.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.174 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=1731006876; 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=LRqOIFOP4fPvK0VjJEYPYWlKg3WtbX7ZXa3kaUW1+Rv+dTrxUknjRKa3b4gghWNFYkbZM6 3aHmioUulZ0dOscsbyLD/W9Blt4xABY2Boncb7vfniZU6HnskklmOds77AahtqEBx9tTNP m31IG+LJ/bk1PfgAJlNEP7kNTDPo6N0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=W50GZe9t; spf=pass (imf17.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.174 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=1731006876; a=rsa-sha256; cv=none; b=X5Cbpu8J+qbJGmM3cfE8VtsJm+/cyOoFwCwMxv1ClWjnXIgLGm4jhoqYkrguIDjaVTFihj cL2VeuIN87RxUO4XvfL2lJ/6LRDyxo/Ub3x4Oy6HzdIcJohZuDrHyJTyuXYloLgYi91EHX r84OFsD8OO5TActRBALnwnL/ZBxbjpU= Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6e377e4aea3so10842427b3.3 for ; Thu, 07 Nov 2024 11:17:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731007043; x=1731611843; 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=W50GZe9txHOTtA2IULv7XdMse2jBMThPkK+CHdHxvXX0TdAJzRI4i81RvVOPcF7Q0+ fTT2ADmcpWQXEX7mOlw0/H9/bORmBMMpS+9uHPXR0Jqt099Mh6wJbu3TYO6OG7hc2G6z KuISNwuYt6/hy6eDJs5fzhYppcbfph7eHEma3A14vcpMU6OR/0rQJ9rtkd1Tl7KXT28y cTMGqM+PpfF0ilmxLVbc+wJ7qNj2vx5mF/a78Rovx4LcTsvfzuc3X2hmIu30e98a8tQt qaQ7cEvC7eXn7ZObUI154y0eSHK4CJtJc4iHqsHjux4BBQGWoNWtTA4WZfooTC1UI24P NegA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731007043; x=1731611843; 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=Lk1nzAK1EVKfWfR0hTUm362VUYRpiIcTUM76t2MpTDIAtfri9qJSoY/Xjo8IrjMqx3 HftD6QsTiq4gOmjl+UGXm2jG0LMHEENxcHNxRPifswMmwNIaX0O8Pn1UsHooPkr0CLvA XQF5v46VuMBMx6JNWYB2iHNcU2iCvXpvyu7f5BmpqlL1SPKsyL6bQPzm2qJi9jlbvAxH ZJvMDCw8Q+vhNUILMWZTzEZWL+AsdPZwC98U+Q2vqlhOTwUaa/s/dn/fl3rKrJQcPDY2 8jYm2jg3f7QWpGPXQLM5iZIyZ+5+4H9DC5mVcS9yXvf/GX+7GXsv2TtW+QkT67VQIsMi R6lQ== X-Forwarded-Encrypted: i=1; AJvYcCUFqyMCvof6038oxu27s7hRHSY+LnLV/yUMuPlfchSiuAWc9gisFg3C4iILUSEyg3kseoAIgpVnuA==@kvack.org X-Gm-Message-State: AOJu0Yw48RqBthGcBlhpJabbjRXLjybfzlAqrgYtQ0CgwaX79nYSuJuJ S46v0WonBZ5W+aNdAUyeB1gkA5/sCzLwZItpXd8NwcjWaB+Fia+8 X-Google-Smtp-Source: AGHT+IFHssVnIsuRtflrMUnmonDOpNMTsU28VnY3e7vVVJcpvOBurpk0sydP4Cx4Ik3eP3kEc+Ijgw== X-Received: by 2002:a05:690c:67c8:b0:6e3:323f:d8fb with SMTP id 00721157ae682-6eaddd994d5mr929977b3.14.1731007043403; Thu, 07 Nov 2024 11:17:23 -0800 (PST) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eace8efa7esm4148957b3.40.2024.11.07.11.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 11:17:23 -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 v3 1/6] mm: add AS_WRITEBACK_MAY_BLOCK mapping flag Date: Thu, 7 Nov 2024 11:16:12 -0800 Message-ID: <20241107191618.2011146-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241107191618.2011146-1-joannelkoong@gmail.com> References: <20241107191618.2011146-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BC9DE4002A X-Stat-Signature: yrkcp3mrfyud8dbks3fj4ogfi9ye3mae X-Rspam-User: X-HE-Tag: 1731007016-666529 X-HE-Meta: U2FsdGVkX18D2YtcjtYBANqJNvva5/fV+j0ixm8L2m/I6irc8+HHvRKRAL8Ob+HxtjwziVuJpJXhf7Fxk1oVUgEKfQSm+Tvt3tThBrqSgChyRXzNiA7f1VZrGZf1J9Ae8cFilJQ5ntWm6+YSNsz2T3Y/jkKFNGwQjtHAHIxEhClbe0YUJ0Ib9gmqVUOt9avmsAJ0i4PRMAW34D8+SU+SdiYCL3ewvo8MzTHs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ZkczyxanA1G1xVMMZ2na/K+zP4d5DCGA76ZYpTbeO7bGgQUYkw1MN7LXHK/OZ9F0GuhSZILWrbRw== 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;