From patchwork Fri Nov 8 17:43:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868800 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 45B79D64075 for ; Fri, 8 Nov 2024 17:45:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14C716B00B6; Fri, 8 Nov 2024 12:45:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F9846B00E0; Fri, 8 Nov 2024 12:45:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDCC56B00E2; Fri, 8 Nov 2024 12:45:26 -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 C64B66B00B6 for ; Fri, 8 Nov 2024 12:45:26 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 80D6C40E7E for ; Fri, 8 Nov 2024 17:45:26 +0000 (UTC) X-FDA: 82763653896.16.77DA39A Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by imf02.hostedemail.com (Postfix) with ESMTP id 9599980022 for ; Fri, 8 Nov 2024 17:44:14 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=DOyAI5iW; spf=pass (imf02.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.178 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731087838; 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=wWDNTRuAGEC8P1PkMAQXcWfNP3UvXVPT3pXPdqP7CT4=; b=8pJAWKhPxRnOFVBtwUrQFjQWAwW03P+spO2xF+nh7OO78VhOxLizLWWvHHNBPDdMk6p0ol n+Xa0ykAX58lSWnxIWEPg4BjCAsN+Ruu4mDw56suS1kh7h9RIJS9ernwObtaGwcO1F/oJJ 72BaqLyf7zPcEeUrLIIPFXl1vMO3jSk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087838; a=rsa-sha256; cv=none; b=7i3JK1T9YX+sjVWTWVDLrLmpkop4t3ZrpPiOfi7ybRvE+Nj8A/exWbu5WjXLBaPNsDJ3oO eVrAwBVepUAomgQjaRnzasXWjTcKMzA+Ewi+gYBl1g0AQ0wzS+QRYtsw7EiA/tfZ1MyHu5 KWVnzBVi+raEAICS8LWQCJ1cFOgjEGI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=DOyAI5iW; spf=pass (imf02.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.178 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3e607556c83so1581617b6e.1 for ; Fri, 08 Nov 2024 09:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087923; x=1731692723; 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=wWDNTRuAGEC8P1PkMAQXcWfNP3UvXVPT3pXPdqP7CT4=; b=DOyAI5iW9njSI/n+52sK5n9g5WrANMKGAD1+s3lwc1ATuzL8A+OMn+JaOBZPLuMCco +vWm8qzPzlXU0InsRuG4TT3gmPwkIojEVmgDgypWJIZMonpSegDFAL+zFA+CJOb0PNDP j6FHToWdank5fl3fYJZ9UK7jUzyRuJYdMcJ9JUzJx2zueIUgJbHDrvoZPP/Thm+ceQx1 rVaxaJCCYpgnteSjUK/LcAEdAt5RefajX2gRPKbL1JjHmOF3JOCeACWfhdHldiZBDg+Q 5OiHzY9JNJBek4vIpd5NIyyja4UmJySqjK46e++Ie4kO8UjkRYKOW3u4K6VIODuj5vHm +t7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087923; x=1731692723; 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=wWDNTRuAGEC8P1PkMAQXcWfNP3UvXVPT3pXPdqP7CT4=; b=qbcldQGqS6fkbb4KXJxzxrelNtXuSStF8oSKVlMt35vPVIGLLlVY/tOvnVLz/Fe57H opVPylQkeVACsaKmXnVmqzoR/SFJVNcGaQmhVUhkvS5wXAff1g6AgDOVyosLlq+p7RDL ia6gABNEslQiaX8MBxybPcm4nypHYILPr+IXSPnyUJeDFw/N3eV6P8nsuSc772oYcokZ FvgVgh7Mi7OrQal14wf2aCzQ2WY2VagjT+QzXUBjWFNtdCFTfUXFNs202b4LnTt+kWWT +OjUP2foTBWJPqZWm8wHouDFdyhp8LA0dSY3Cm8gyHUMuJ30hsNQsP3SwhNnZbnn970V /WIA== X-Gm-Message-State: AOJu0YxvkrwMyhw2M7pZEkUU2cK8iM0nl5fgIKtqP0WYWR0kUoIGDQM3 P2l2czkeZ3ni2mi/fGXHMraflWha6cP34oKr8G1Mc4MR84aNWI+sh5NUiOh4mRXqfkiFuZt7TFt CvzE= X-Google-Smtp-Source: AGHT+IEpy29b6bGe+h/CboagPQRbeA16vn/em+bpmlLLfLOrXhNW+1oHUaJS7mfyo/74o97NJpvLFQ== X-Received: by 2002:a05:6808:1525:b0:3e5:f141:1331 with SMTP id 5614622812f47-3e794733f1fmr4465090b6e.37.1731087923389; Fri, 08 Nov 2024 09:45:23 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45:22 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, Jens Axboe Subject: [PATCH 07/13] fs: add FOP_UNCACHED flag Date: Fri, 8 Nov 2024 10:43:30 -0700 Message-ID: <20241108174505.1214230-8-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: uqu7srk733h53x5w5e9wgexbrk5buhcy X-Rspamd-Queue-Id: 9599980022 X-Rspam-User: X-HE-Tag: 1731087854-594509 X-HE-Meta: U2FsdGVkX1/YRAno5TFiMbb7TrLhBG6Nw8Bu6csgZBkh0Y1WbW36XCU8ecRGlrMA+ZriEkh1cNjAxCjgGsp5PhaQkiyNgdK1/lJtojt/IRBRAKWM4+oVLYsmLQKI9RLyrb89jY1xgIAKNBz/kH32ph2eaMGvc8YzOMOiqQA8oKfN62v3W3TFi0oVK/klfZcgcfkdsF0coeOFagPqJ3Z79N2cMgrhPeXFII6nRw4oYz4P/o/V7o5YxdxLxE1nvJbMpIMpCnNGwWMdudsnuzc95NpjJm23oX+zSzugJKDBzez50VkiCsBLEomUGeKhzF7sDGM/FUw2lxLqz/plfSnJ38QagwGrZi6kjhJG/h20HwE8+jUBI3v+q/FT3KLP65Cz333rEHBgwwGptgS6Xz35rPAHC0oChq3sl1FnesxUCuWI/VyTHPMWx2JukM8RuE1NYB4tWN2NJ6mvEdCSoQQOsUgfeQ6HBMsA4RQQC+1V0lFxs8jX29TfhJAa8mqg18pGFjzHlwOhNgffUeItRpX8sVDyXYvoosFe64dBhQWov7RV2EZv4XlAkObtzhMdPsceyQf9HV9eKKvSLeppzbQx1fO0uX3wnku/gv+68HQeAFTcrOfVs61t9g35m3HQ5dfpAB4uuFRyztBCmEuphDRhHy9N3Qz+GaZm5oIHueZRTbBG9d8hwsRoggFahJdG9KVE4W/iky8pu/pYiCP8tC/TwVK8qAbi8OafHxXxfSs/gRBQJmPDMGayv2eOr1pg22UEI39aZX6NjjIJICNUrN3oLnniJhAHCr6Cev06u2vaS9w2Gspkhe2Sk+zsU1u3j26Mhwzexaih0D6JOKan9xEgXYB6EGdvuuhyi9w+CQH2Tqc4nkrBjfyk3AsNTWjMNJHLq9BMaTY+CA1LoDgPAoTjWV67jm3n638m3i6zxubbvK67pEe9j2/VUj7echd4fWt+K1FTn8IVKPCUA5Il0eD PHEfl07i TaVQxmeL7Pkza7x2Hrhi72WJHW3Mm381OZUc/9JbbSVpybHSLbRfKLdXE9WN3ttDLafRamYo8WycLKIRFu0yYa8uuGBnLI4NHk7JbttsN9cP1NsZWOnXDs9ZcHMHpy5PoucyVCrxqCNNRwfX4nXazFqJxsZ96XKGHMpEQHuOOMBYi41JKV8kHdKTMX6qiIQc7kSNdJNk4Cs4ykvuD/bkK9ZFBtbXPhfFQWKAEcisQOrTWCqsfpvwRzhmilrvCXXwiSU9+D78VQ+gMREo8fqnHIM+4WpOfshnriEzbc4Rog9YXvgB2bF+N6J3W8Z2HyY54bjrOPZWM9BV63l9o8q1Jw5JZKTBwZKYD78B5 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: If a file system supports uncached buffered IO, it may set FOP_UNCACHED and enable RWF_UNCACHED. If RWF_UNCACHED is attempted without the file system supporting it, it'll get errored with -EOPNOTSUPP. Signed-off-by: Jens Axboe --- include/linux/fs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3559446279c1..491eeb73e725 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2116,6 +2116,8 @@ struct file_operations { #define FOP_HUGE_PAGES ((__force fop_flags_t)(1 << 4)) /* Treat loff_t as unsigned (e.g., /dev/mem) */ #define FOP_UNSIGNED_OFFSET ((__force fop_flags_t)(1 << 5)) +/* File system supports uncached read/write buffered IO */ +#define FOP_UNCACHED ((__force fop_flags_t)(1 << 6)) /* Wrap a directory iterator that needs exclusive inode access */ int wrap_directory_iterator(struct file *, struct dir_context *, @@ -3532,6 +3534,10 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags, if (!(ki->ki_filp->f_mode & FMODE_CAN_ATOMIC_WRITE)) return -EOPNOTSUPP; } + if (flags & RWF_UNCACHED) { + if (!(ki->ki_filp->f_op->fop_flags & FOP_UNCACHED)) + return -EOPNOTSUPP; + } kiocb_flags |= (__force int) (flags & RWF_SUPPORTED); if (flags & RWF_SYNC) kiocb_flags |= IOCB_DSYNC;