From patchwork Wed Sep 11 16:34:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13800876 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 2FF7BEE57C0 for ; Wed, 11 Sep 2024 16:34:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BB6A940063; Wed, 11 Sep 2024 12:34:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76B7394004F; Wed, 11 Sep 2024 12:34:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 633F1940063; Wed, 11 Sep 2024 12:34:26 -0400 (EDT) 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 44F8D94004F for ; Wed, 11 Sep 2024 12:34:26 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A66F31C5331 for ; Wed, 11 Sep 2024 16:34:25 +0000 (UTC) X-FDA: 82553005290.02.395017F Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf21.hostedemail.com (Postfix) with ESMTP id DDDF21C0007 for ; Wed, 11 Sep 2024 16:34:23 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XOh6y2VS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=asml.silence@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726072348; 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:references:dkim-signature; bh=JMtXVHkqQbVZYjnenJKozcU9t1oo3mrhS0t1pBayqX0=; b=kj9RxdmN1Q17H5H2CuGOMhtGJ8UK4WNbx6159KwKhZEmV3ht4uNuWRut5UZnbkvmGTaj66 R9GGfCEPHqLcdM9QAYW9epVlbfPIVGS2uNW9SQPaksv0G3RBCyaTFSYHyJf9QzoUy5tNNf YGKaXq+iO3Kx5bcCysnmxMtB6E6YTK8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726072348; a=rsa-sha256; cv=none; b=frEy1WBrAAzLuT5NOcZXjhEnNrKByzbPfrlGJN4UlteL4TJg2vOGeyqwnFcJsQjx/IipdE Fj7QWkBgUEy9MbGiREmwiUsaebke2NbEOyiIvI+AvK7JbfrkNto4gvZptd9WKnFlTTqeep ZBnbjwHRJz8hfpWLK5F+DZu7lxP3GxU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XOh6y2VS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=asml.silence@gmail.com Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a8d100e9ce0so2701466b.2 for ; Wed, 11 Sep 2024 09:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726072462; x=1726677262; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JMtXVHkqQbVZYjnenJKozcU9t1oo3mrhS0t1pBayqX0=; b=XOh6y2VSVyE6qtM6WOiyVo0PbPR4N8eK3cg4R/ZP1NNBYHnQ6N+03esE2jggvKGHfc VJZAlqQvTAM9XeQs7J7VkuOV+JPiDDdLJGyUj5WIKGPWRi4w8siqgNOiZSWc7Q8s72pW Hh4WEzdddBg63/pYWMUlxdTugMwSMIriGH8BmqYHZoczd0DffEiDCdjxXRDNUsIE7zFF uNGPmRrjyYQTCdOXOC9GIPV/3I4NKZdOKiFJJ7bjxqP5qVClzUN+kOdu+hfrWPuvS562 6OEVMi8NaR7WdWMZgJmbdm9fhn25PfOE0TSRer4BsIUHO974+C++1nIV78qw2/xeh5td YWZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726072462; x=1726677262; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JMtXVHkqQbVZYjnenJKozcU9t1oo3mrhS0t1pBayqX0=; b=TLU9WdL4bGTPDlmQIyYSbfP/aIgxK1Adnjzt6KnvFyF7Drgdb1d10+lV0ovtuSjSgy ps/Wx/lVhb2lFve/JJzSPLKxHQfVgt8Q3Liuc0IrbSgb3vNYHg1kCMoPKwwRTDEssqlF sohqkISQkFXXMkFc/IYps2OKjBeD2yFvSn22ijyU7m4MNM8J/wZfG+a/0lx7n6SCB6/6 YLBvG0B1i2g3DXFmaO0nWGmcjGFzXuNBHQk6ZKTup16e+Rs4w0AxzpGzY8X+6g5RjK9j XYMzZKz69ZTcGWc8cAz229drW+1TCVcxppg0c1tAqiSsHf6eKuPvi3R0ZAhtsoMtuRho SoWA== X-Forwarded-Encrypted: i=1; AJvYcCWrLbfvr/VLrD0ioKnYJjJUwYmvysdTZedQ5EtI+CjpgjK+j5517k5QX1Qjd9kSrgPzA9RGxqIb/g==@kvack.org X-Gm-Message-State: AOJu0YwlLE9bYw4/ymbeE38aoogwUTivx7b6CtIDYqkv8zuJW+I7MTaA vA0oAGItmvpxRPia6DLZneg3u/BRbJUyYt80Se9opl4g259GaK1C X-Google-Smtp-Source: AGHT+IGjuO6kXZBiH/YIXMFCm9Da9OqH+kOJ25he8cNe8qOZqvyK5g024tTbFGMJIxveiGd9EzI8/w== X-Received: by 2002:a17:906:d555:b0:a8d:5e1a:8d80 with SMTP id a640c23a62f3a-a902961ab79mr6013366b.40.1726072461451; Wed, 11 Sep 2024 09:34:21 -0700 (PDT) Received: from 127.0.0.1localhost ([163.114.131.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c72ed3sm631820866b.135.2024.09.11.09.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 09:34:20 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com, linux-block@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig Subject: [PATCH v5 0/8] implement async block discards and other ops via io_uring Date: Wed, 11 Sep 2024 17:34:36 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DDDF21C0007 X-Stat-Signature: udhhpm7wx7nkhcqd1qrkh48qynxqikp8 X-Rspam-User: X-HE-Tag: 1726072463-635177 X-HE-Meta: U2FsdGVkX1+s3aJnMxnmF5mjyiRuz6IgYETTam0osogsC/gYmbF0PImYunVBmWuQ0RWws0GD1ISwmkRi+RCesTDr9MXPOu+vaYjklZjlhmTu4qZCcTkPwEVE+EeEk336FiPDOyr+lxECfdZ67j7qMXxFWhh20qNjfNflYSP+ZdPx9sGdQd63dwEs3ZD//gDJF4INAPjBPyDnAyfWOYTQAPw6pWq9fprswJgfo4kSdZJgegVMDrzEgal/bk5npDX0FmYNXSSGVEGCUCMpY+Bi+gp1Qd3vJYD5z10bWT11OwTBt/TekXqffbIG4Jxle75SAXZK5doVJjD0TyIxLvOb/KituNIH5jZPR4U7lnfVkuT7bn2j0hAd0CxafRfSAIZaKrYvC9ekNznewe0dIbKpbD3P4Q4qTg1zm7M+4jIaTsPKUvGnY5p4FWz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-Bogosity: Ham, tests=bogofilter, spamicity=0.000047, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: There is an interest in having asynchronous block operations like discard and write zeroes. The series implements that as io_uring commands, which is an io_uring request type allowing to implement custom file specific operations. First 4 are preparation patches. Patch 5 introduces the main chunk of cmd infrastructure and discard commands. Patches 6-8 implement write zeroes variants. Branch with tests and docs: https://github.com/isilence/liburing.git discard-cmd The man page specifically (need to shuffle it to some cmd section): https://github.com/isilence/liburing/commit/a6fa2bc2400bf7fcb80496e322b5db4c8b3191f0 v5: add uapi/linux/blkdev.h number block cmd opcodes starting from IOC seq 0 don't export bio_discard_limit(), return to v2 and put bio if nowait can't proceed minor comment and stylistics changes v4: fix failing to pass nowait (unused opf) in patch 7 v3: use GFP_NOWAIT for non-blocking allocation fail oversized nowait discards in advance drop secure erase and add zero page writes renamed function name + other cosmetic changes use IOC / ioctl encoding for cmd opcodes v2: move out of CONFIG_COMPAT add write zeroes & secure erase drop a note about interaction with page cache Pavel Begunkov (8): io_uring/cmd: expose iowq to cmds io_uring/cmd: give inline space in request to cmds filemap: introduce filemap_invalidate_pages block: introduce blk_validate_byte_range() block: implement async io_uring discard cmd block: implement write zeroes io_uring cmd block: add nowait flag for __blkdev_issue_zero_pages block: implement write zero pages cmd block/blk-lib.c | 22 +++- block/blk.h | 1 + block/fops.c | 2 + block/ioctl.c | 242 ++++++++++++++++++++++++++++++++--- include/linux/bio.h | 4 + include/linux/blkdev.h | 1 + include/linux/io_uring/cmd.h | 15 +++ include/linux/pagemap.h | 2 + include/uapi/linux/blkdev.h | 16 +++ io_uring/io_uring.c | 11 ++ io_uring/io_uring.h | 1 + io_uring/uring_cmd.c | 7 + mm/filemap.c | 17 ++- 13 files changed, 314 insertions(+), 27 deletions(-) create mode 100644 include/uapi/linux/blkdev.h