From patchwork Thu Aug 22 03:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13772573 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 10ED5C3DA4A for ; Thu, 22 Aug 2024 03:35:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E6846B0252; Wed, 21 Aug 2024 23:35:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 895BB6B0253; Wed, 21 Aug 2024 23:35:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75D496B0256; Wed, 21 Aug 2024 23:35:39 -0400 (EDT) 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 57FC66B0252 for ; Wed, 21 Aug 2024 23:35:39 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CAD581C1BB4 for ; Thu, 22 Aug 2024 03:35:38 +0000 (UTC) X-FDA: 82478466756.24.BAC0E40 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by imf09.hostedemail.com (Postfix) with ESMTP id 1654B140017 for ; Thu, 22 Aug 2024 03:35:36 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=M1b1Oxnd; spf=pass (imf09.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=asml.silence@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=1724297656; 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=+IreBDreZSBwJydKxcFKtWQRaeFNvxt3rNW9GfTop+k=; b=0ClOSjr3woesRTYFHHWIS3VNBE0zvPKZUXEDBlDiPlyoKLxEu20LmNqWmAaADHyK5s4SPQ Vv8as+hq4yRHPpAFBb2B8qkcYVzFabbfsr7VhjS9Vdurq09nptdAJH+UHsMuXjFH5TxDyK QibjOr9NrmaQkatz8G1ewHZa18udjT0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724297656; a=rsa-sha256; cv=none; b=z2ox3oQLs7Yx0yk6wqCWp7ZKML17afzXPwwuqcwlO693X940jllVnF4idUESlRu+JnGVvT 6o2Mwz1l5iw6T0kklkqtaqKj/Qmc08vagsI0cudvvguxGvp+jI5rYM+BgRzGOCvO0hqPVa SQTYmLhR4zY0hupj9jd3tunaKP3XKmU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=M1b1Oxnd; spf=pass (imf09.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=asml.silence@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3730749ee7aso131487f8f.2 for ; Wed, 21 Aug 2024 20:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724297735; x=1724902535; 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=+IreBDreZSBwJydKxcFKtWQRaeFNvxt3rNW9GfTop+k=; b=M1b1OxndwZAt9I+dj5FMeqRRv5P9+WQHm2MrphsjHmecXgZULFBkGybQUDHC3NPCAw OAtV5Dv9dSeqDfiAUpNK7u2t5qq259NJzmP5jGErp7dKavZvENkc7QqYQMzhCdmry990 +CuUorp1fx6BuR9TZaJ7pqBh9i9cO6XXe+9OO450z7HVszU5tnn/2E/qn4cELHDIVwQ2 4ksU/nBcy1esbTwZVc5QBLXfGeRZ/T2IkL4w/j6RDAEBRJ25WlgjtYqO2PpEohvRnrRd K0vQI+x+ByAdx+eOAxP3E47yw1LzbII/9tXvOPJiORJMpRo5ofm2kBYOot2S2i4hQYQ/ k98g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724297735; x=1724902535; 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=+IreBDreZSBwJydKxcFKtWQRaeFNvxt3rNW9GfTop+k=; b=YUI+9faG8kMQwAH08zqObaPWcBoAuIjpbdaTrezEnoj9VOiGopeJbEYmyAW+4MBlUB 2sqxn81Py5XPKG+UqxQp6Zwn4ENakgZn5gyJViqdqh87Cdi1XGOgSRhy0KHTrLdFDFV9 C1K7ODo6G1fwQ/cZI/wV9+C+6wd7dlla6FppcxMc9H0glhWdf0Jm5Dn/+mYaXdd3lxZ1 0lcmvSM7T0gshpuEBeJy4VyaC7IcXoF2F5A9UICXFy9TaVWO++3WIrvuWpDch13lKHfA BFMf3YjkIyBNAvzLrmpZ01VM1+e+32jKkdTNRUAPqgPwv2ZFKLVnbKwdcmt46d/lUQhF 7yKA== X-Forwarded-Encrypted: i=1; AJvYcCWOnNKGOy30I30VEF0ehew701TkvRAn8J7FG+OMQ/Acfz+3NaREH1Z96Y1HZ2de5JBUCa0SMkRQ4g==@kvack.org X-Gm-Message-State: AOJu0Yx56Ur/fAEjCi2nOM+urtW887ONOj3pAnVWFQzGtv6UVdubvxDk rDJlAtZAZ1bW7KzkUoP67GmitITCIOwmm/pfNYE9omCLVC8oXMEv X-Google-Smtp-Source: AGHT+IFCrZJRE3JoOsYnLyBpiBJ1fJMH0zCOC/q+yqldv3zN7E3+YSE/nUZfdiUy2hzpTtOjgxqKnA== X-Received: by 2002:a5d:44ca:0:b0:367:434f:ca9a with SMTP id ffacd0b85a97d-372fd4d11a0mr2598796f8f.0.1724297735071; Wed, 21 Aug 2024 20:35:35 -0700 (PDT) Received: from 127.0.0.1localhost ([148.252.128.6]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abefc626fsm45491995e9.31.2024.08.21.20.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 20:35:34 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com, Conrad Meyer , linux-block@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 0/7] implement async block discards/etc. via io_uring Date: Thu, 22 Aug 2024 04:35:50 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Stat-Signature: ccz6aamzom7ykeo8c4d8o9okmtcffusr X-Rspamd-Queue-Id: 1654B140017 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724297736-310927 X-HE-Meta: U2FsdGVkX190j2C1hYXImKksabUWGgpIfuiGveHy7stT1nCc5qHnlOsoM/cP2t+0FgWenAzHpa3o9WX1nP6ixgkzxbLdWi6mzxcCAtjUs0Q04gfpm/DqFei35bExDwNtovPN827gLbuXmW8KkZac05Yxm/npxgmVk1a8vzAi67QOKZrtg7H8xZIAbCyMSVTSKPSYdqX7cUXWXUgcAU4w6kj8zZQwpMmOeeUOl15643pQGJ+VcQ6hHSdRCfErNXaK1MEmJLMLpV5sWp0bCtd0xlqRyS1T2hl4kCvVMA5q1d3H67TNRbb9xkzpAm3vjBcEkUMESNunvCATaPo4+Qe+GoGlpfV0L/GCPfFgHIGO73/X/bE+CmwB/vnKw/+O+kPZtvVCEtWgYSSqqCNkZ9P5aAb2Bg4FfmPCvTGNsl71qS/MlWkNef1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697, 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 patches are simple preps, patches 5-7 implement support for discards, write zeroes and secure erases correspondingly. While the two latter commands use the same code path, discards only reuses common callbacks and not bio allocation loop because of differences in how the range is sliced into bios, see granularity handling in bio_discard_limit(). Note that there are differences with ioctl() versions, these are asynchronous and looser on synchronisation with page cache allowing more races, see comments to patch 5. liburing tests: https://github.com/isilence/liburing.git discard-cmd-test Pavel Begunkov (7): 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_write() block: implement async discard as io_uring cmd block: implement async wire write zeroes block: implement async secure erase block/blk.h | 1 + block/fops.c | 2 + block/ioctl.c | 231 ++++++++++++++++++++++++++++++++--- include/linux/blkdev.h | 4 + include/linux/io_uring/cmd.h | 15 +++ include/linux/pagemap.h | 2 + include/uapi/linux/fs.h | 4 + io_uring/io_uring.c | 11 ++ io_uring/io_uring.h | 1 + io_uring/uring_cmd.c | 7 ++ mm/filemap.c | 18 ++- 11 files changed, 273 insertions(+), 23 deletions(-) base-commit: 15dadb5430367959a455818fef80350a68c010f4