From patchwork Sun Nov 10 15:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869951 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 66DD3D12D46 for ; Sun, 10 Nov 2024 15:29:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 978D36B00B6; Sun, 10 Nov 2024 10:29:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9270B6B00B7; Sun, 10 Nov 2024 10:29:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A27F6B00B8; Sun, 10 Nov 2024 10:29:27 -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 5A18C6B00B6 for ; Sun, 10 Nov 2024 10:29:27 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 226F2ACC8A for ; Sun, 10 Nov 2024 15:29:27 +0000 (UTC) X-FDA: 82770566802.17.357DA31 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf25.hostedemail.com (Postfix) with ESMTP id DF3FEA0003 for ; Sun, 10 Nov 2024 15:28:56 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=0eUB1Hxp; dmarc=none; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.43 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252504; a=rsa-sha256; cv=none; b=xSoMa/Gug5bNNVhaQTiSRm7ZA0lVU+EmUyFWmAGIWEaG6c6GJT7ZpovDo4LSe0BzMQW6/M OWS+XVvjfVPxx6r/Tza4pOgmvhxjU4tNxEU9ihgbcM8aYP8uDQHv7gqvCww0qlfeoADjgA X3BuN3KO3wBA4VEYb4BYWszygvA46YI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=0eUB1Hxp; dmarc=none; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.43 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252504; 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=BpaeGG8sCxZf4JRh/p7NGjZl2gbHvBRPjf0TUvSvRrE=; b=yx2S6AypbN0bDCEBAIIEzI1EYW5WgNzg1p8IJJ8wYTRhJariRd3VrTWMSuRNmeFIELbZbj QSMd1C/kHzjzMSqaw3l117Ai4eTjPHcHhzUOipxKFTK0+9xdwW6Bf4SUJ9rNgfTB+eA9Hq 6ax+ItkOdK22Jn/VqhFowTCt6zskVbQ= Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2e2ad9825a7so2840109a91.0 for ; Sun, 10 Nov 2024 07:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252564; x=1731857364; 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=BpaeGG8sCxZf4JRh/p7NGjZl2gbHvBRPjf0TUvSvRrE=; b=0eUB1Hxp1NEBj58pU47ypngPEvk/5vS/T0jhKFdKKFy0Z5tOAm+cjePcrGjooN/Bxw szvZEIrhs+JIS5OYSefVvlAxrnxiq/HO/nGojeUkMD+CG/TScuRda9NrsS2HMoI4ylGA gbnG3kllkjJLtju027GjB4AGOEgvyS5dUnG45sSGG5BJvouZ9Fi3KFbbKwsOTblP8PZa 3gZU5JuYtQB7n1A9+5j0bs3bJpS4iUQnySjmRxUDr94qX7TcgxZaGWQgu+m830x2DzZD Tpb5BBKyuLG6e4PZqXDpUnt5yyND58M87H1aiKlUSO/L4c6JXYTaWdxtBQWVOOPkb17o vNIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252564; x=1731857364; 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=BpaeGG8sCxZf4JRh/p7NGjZl2gbHvBRPjf0TUvSvRrE=; b=kXSHp5pcR8SXHLfn7O+CkAEXDIVGBeCEFpQAyx3eS/vXBYBsGXFN7PepuQOLVkDjY3 g2Pty6JFFb6fMMokqCzFKT6fwzwxulWRFtdXmXIT/Wq8hfn8LagEg7ffKqbW/hCQUprf 5sdrqJj7A2CDk1PLtd00pdwzDrn5EsJT0/wXrS4KRKPg/m1kqUBgahaYtOR5eDfMqm2U evjtB9eCMsYmVBWE9m8E/68/NiF4lddp12bdzy6KCv9INT5CGTNofKNcvShxO6WdBQWa lAoJqPNPVEkGy7vCJySwoKBDc3mTkJnLHHwadG2LZHPWReHOU5vbsXX+SdYYJdw1T+qj bBDQ== X-Gm-Message-State: AOJu0YzIPIWiGrMri+29MyQRnMmc1+BCZUhDgCL5oa2bKGvrJxMz5nRT TW9kV8rXt+yD76OR8EsY6wMJ5+dOipDGsYizF1ovoXNFcrXe1oIVgaIu99esg/ejeMBJqUah4JJ YNVE= X-Google-Smtp-Source: AGHT+IGs3z/1IuRBhhgcQrQmIVWwPr43n/jctzILt+apLswhddJAGBym568yRqijFSP667Ww7gbDZA== X-Received: by 2002:a17:90b:1f8e:b0:2e0:d957:1b9d with SMTP id 98e67ed59e1d1-2e9b17163cbmr13877494a91.13.1731252563753; Sun, 10 Nov 2024 07:29:23 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:23 -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, willy@infradead.org, Jens Axboe Subject: [PATCH 07/15] fs: add RWF_UNCACHED iocb and FOP_UNCACHED file_operations flag Date: Sun, 10 Nov 2024 08:27:59 -0700 Message-ID: <20241110152906.1747545-8-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: DF3FEA0003 X-Rspamd-Server: rspam01 X-Stat-Signature: f67zme1i3sw9o9ahfco5gft6hz3gp5uz X-HE-Tag: 1731252536-513637 X-HE-Meta: U2FsdGVkX1+i15g7Ink2jlWd85Xj0syBQPqfOPm6w8OgAmJm0ogVXtxWcAqpEVl1nmATo5/59x71ICZ8nmk84Goy1WbsjGKLRApnG4eTIMgTlmJZkFx6qaowm6O67mODVQ3UhJuuApuWWLiSUL2a1w1Rg0Yrq6FezUDVA3OtcRJ42hiFUcY5sk1MZkI6Dv8PPGFYgQNB9RYaYwY33GFvGmXcWLydR9XWHkwWuhVQ/R9OyhP9S00XQFJ681f2zc6kIY2nAh6TkRuThzXw/hodcf5p/kbLlxUJx3KYpPEEkBRZEgaxrfieF597KK4nee2JjEle1lOrb6AIcmA7dF0OCb5urIfnQWdx+fW9b1NbWXPOBWAtpHraoME5B21VkgOmDqZcjHoyuP7vLmrSwTxjP8bMGqZeDbjgY5uZZc28iQpJ0hvtMgDmnUImW+Zlcn+By5WCK3qaMzBBn34OP24fDwjZnXgIaBgpSGeM7DFrn1JntI7y7mzQknwKN9acUzEHFW9WMo0kr4Iqupq3oR7VlKSUdgEU4S4+zo7DwEDnKpKsl+9/VCi/B49TO/CxqIaqpDaU8E9inzXQrY5KomrUC0fm9rOIZwsA/UpZJsR22Uk9pcJFHU4qQ5HKdKuH7KGwVGvHcqQivrWuSbmzmWSUv8f94X7Zpm3OOrOi7b64WkWGS4S/2BTgfZVj0lGAF2hsrEZlnEwob0rREDqmLaj5WdHsh9PwO/RtBRgrsAmLse6L+IJskG1Vso8m2oZUOu3ap7cyloeu9XHvGnwZoyBQQyoWDpS6eEnneeP40Vs+vVyQ3Ct35Il/nOuXphELexlkYoVLD3CaMjh2Zi4HM3Toc21xTMNLBwBCLlrehfh+DsxK5faasYR365iOnFF4XAjmyzxX6x4iKywNqXhr+BrZlVs5lDXRFhKMveGmtCjXChP5IU5aGwlawDkn9gJ+uVydxsb5C2VjITdDSZ6yL3k wetjaBsx VZQvproBAqeVglHHDrHGCCv5MO0zNa8lYDWg17Xxb2C6z2GH7dXNO1ZKD7ZLNuNQxevjqH+XuIdxZOdiiG1CFTVdYKhLi0PHapQ250r/mju8hef2qVroJgddYF4if5ssWrvoI2eulbgVyqzYYbpI01Tde20HPQDUTX0p1dzvQx0NMBwUZXj9mdGGJENE/DE5h+W6wMSxJ1cacDzW7n7VuWLOorJKdYWGfwX0I5nAchjxTKOJnfTuHYZHrNbNVzUklcLap4rRg5VDW88dSKui5RwjdUUSOtpooVqZjN4wDTvG8MGw/rewqTH8oEkgR9N/QDnNyRg4vCB+hotLgXzo+HGS3ccfMXcn6xWsK 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 | 10 +++++++++- include/uapi/linux/fs.h | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3559446279c1..5abc53991cd0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -320,6 +320,7 @@ struct readahead_control; #define IOCB_NOWAIT (__force int) RWF_NOWAIT #define IOCB_APPEND (__force int) RWF_APPEND #define IOCB_ATOMIC (__force int) RWF_ATOMIC +#define IOCB_UNCACHED (__force int) RWF_UNCACHED /* non-RWF related bits - start at 16 */ #define IOCB_EVENTFD (1 << 16) @@ -354,7 +355,8 @@ struct readahead_control; { IOCB_SYNC, "SYNC" }, \ { IOCB_NOWAIT, "NOWAIT" }, \ { IOCB_APPEND, "APPEND" }, \ - { IOCB_ATOMIC, "ATOMIC"}, \ + { IOCB_ATOMIC, "ATOMIC" }, \ + { IOCB_UNCACHED, "UNCACHED" }, \ { IOCB_EVENTFD, "EVENTFD"}, \ { IOCB_DIRECT, "DIRECT" }, \ { IOCB_WRITE, "WRITE" }, \ @@ -2116,6 +2118,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 +3536,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; diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..dc77cd8ae1a3 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -332,9 +332,13 @@ typedef int __bitwise __kernel_rwf_t; /* Atomic Write */ #define RWF_ATOMIC ((__force __kernel_rwf_t)0x00000040) +/* buffered IO that drops the cache after reading or writing data */ +#define RWF_UNCACHED ((__force __kernel_rwf_t)0x00000080) + /* mask of flags supported by the kernel */ #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\ - RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC) + RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\ + RWF_UNCACHED) #define PROCFS_IOCTL_MAGIC 'f'