From patchwork Thu Aug 22 03:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13772580 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 AE854C3DA4A for ; Thu, 22 Aug 2024 03:35:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE31C6B029A; Wed, 21 Aug 2024 23:35:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A92BD6B029B; Wed, 21 Aug 2024 23:35:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95C9F6B029C; Wed, 21 Aug 2024 23:35:47 -0400 (EDT) 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 65EE26B029A for ; Wed, 21 Aug 2024 23:35:47 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 31826A1255 for ; Thu, 22 Aug 2024 03:35:47 +0000 (UTC) X-FDA: 82478467134.19.D19D5CE Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf18.hostedemail.com (Postfix) with ESMTP id 53FB51C000F for ; Thu, 22 Aug 2024 03:35:45 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fllHs+yl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.128.51 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=1724297655; 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=lswIDLrIj7CXYuFfzAb9ZDGauPy9RK0EG0P/gPYjyms=; b=f179CtbX42JokCSbAdZeRUkd5OnxMjTeCIPgLHvEW0fdhaQpcme38S58xL/YUSpNIexi/p YOjMgu3KXVPCOH0CDakIrqy/oZ+ME3zr8uhR7Qc9MLLgu63BzARFcKUzEjGm+MIiWmtgQM ss6jzZsNwRgzxCAAgvi2QpzdAWS/T6g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724297655; a=rsa-sha256; cv=none; b=DEjuCvAhEaiX54nqIqvcQuLFEWePAWc8O0wOS/M3kt0iVrRUdxWOrVd/wSiBErVoEOqNMH fVgwmVA/qWOJhv5HcOY4MHdu5MAMP+iR4CgeSGYDnfCbotvGkoKiG3r6fdXEm+iUCN84z7 W6dgkoBI9AGwUOiWWh7IGAVClcu5GEs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fllHs+yl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=asml.silence@gmail.com Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4280c55e488so1569695e9.0 for ; Wed, 21 Aug 2024 20:35:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724297744; x=1724902544; 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=lswIDLrIj7CXYuFfzAb9ZDGauPy9RK0EG0P/gPYjyms=; b=fllHs+ylFq3VUT9eK6seYOrZpZP27zf5lcgG0V0eHPmnwIEkLBjtgtNdJlwFQ+RMI5 U9VT6BO/SSn9DNei0hW/Js2gh0CJBxzfeT8ux+zgiEDZqKLQdjVFWhR8gzZOobLwyorH 1+Mk1QH7eQRf+o+VpaTX14OHSv6Gklz9XtoptE8hr7/OnREWsxqZIjq0GZbYNnLgSp7P vWLAOxJ7NbFnpKpGWw0xEuicwWSG+drMVJ+uf2+DIIMZTqpmQAIShcZvNXJauV61DJ6K KgNHMrg/+fIVKqB8eJnp68V/QF4yA8N7netd5Hq9AusAK2G/wgGClgYeKarGMvAy49DN JaFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724297744; x=1724902544; 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=lswIDLrIj7CXYuFfzAb9ZDGauPy9RK0EG0P/gPYjyms=; b=uqW5Gv4XB3++tx7zHhwV/4KxeiVQN64AHxz4q6u35I1hlyAVke7jXHaWrW2TuCOOPD xZ0qkLSb62QHX9ZZ2T/95V3/mY7eyD9Gvyrda0rvKiKmVF53hzg5OnfRIvZlQO8rjhHl ocnrM+7NVHpRu+/btC6zgh5sE87ULKdEjClHT8cpubEI2dHHBCFLP2V/iC5rLSoIneRn eL39VqCgAEvlQ6KuiKecASxSe91yut8Z24vy3GSW89AKbBCRO9xPKfz0Vudpxcn/bydU WS6lSLzqOHRSRPAEHeMBamjAsadxfGztvKluFcCNUtfMFOfYG7j5thCii6vqijdgzdB3 gCFg== X-Forwarded-Encrypted: i=1; AJvYcCUVTjG8w7lxMn+vass5NICMkqDaqz0A2UUipYtufK2kViM+T3FX/KwNFGzpuPy9s5864Rr7fnGMNQ==@kvack.org X-Gm-Message-State: AOJu0Yx42uHJwht4q/ro2Le7/rW58N7ly8r/Z2Kij82tJrObVCnmQNTt 9FyrL5SPPb9tEKOPwypaPkMoDSSha2NbNFw4R1yZXKwlGmoc18tf X-Google-Smtp-Source: AGHT+IG8hgkDMcLSSneo44THzR5IGgkExEMFh9iktxvoExcbZbFlYFw8o0WlWu1YjpgQLAsbGqHOpQ== X-Received: by 2002:a05:600c:3c9d:b0:428:6ac:426e with SMTP id 5b1f17b1804b1-42ac3899e82mr7892605e9.5.1724297743449; Wed, 21 Aug 2024 20:35:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 20:35:43 -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 7/7] block: implement async secure erase Date: Thu, 22 Aug 2024 04:35:57 +0100 Message-ID: <5ee52b6cc60fb3d4ecc3d689a3b30eabf4359dba.1724297388.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 53FB51C000F X-Stat-Signature: trpkyntxwktgeeg1xy3pwjgoquws4kxb X-Rspam-User: X-HE-Tag: 1724297745-613489 X-HE-Meta: U2FsdGVkX19UjJmKP2RZD3IJIgdsq8qnydosKql7Eql01GMjhQjlr4sY0gOeW0zOxSgmQNP62zt5rIRtcVCCweURz5zqFkK0XY3oskPT9DBnDz0DqbkSCldl4RZSol/qdTeC1QAZGblBaTmHUNKhkKmTd/5U+qar0fGdeclt2wGTaeJFsrqQCQ7xcdFg0vCDn+nB+kvBI5GFVEt38E+TddGNHEZBdRn14a15KBS+B4gLCo8/W7O76x6g3MkptYnShmLqreUPiUITb3KmKJNIkLQk/99sFKudgPOj8CB43e5VSxUkxyG9PqS8523jpxWFigXNbih0e+w4yXlxrwIB5meGdQHtJ1Qm6IHOl3yDL4ytYrXX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KDsDMtGzMpkussPZSQKZbIfOaYnO3p4gYKm2S20AyHFXF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, 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 yet another io_uring cmd implementing async secure erases. It has same page cache races as async discards and write zeroes and reuses the common paths in general. Suggested-by: Conrad Meyer Signed-off-by: Pavel Begunkov --- block/ioctl.c | 15 +++++++++++++++ include/uapi/linux/fs.h | 1 + 2 files changed, 16 insertions(+) diff --git a/block/ioctl.c b/block/ioctl.c index 6f0676f21e7b..ab8bab6ee806 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -841,6 +841,18 @@ static int blkdev_cmd_write_zeroes(struct io_uring_cmd *cmd, bdev_write_zeroes_sectors(bdev), opf); } +static int blkdev_cmd_secure_erase(struct io_uring_cmd *cmd, + struct block_device *bdev, + uint64_t start, uint64_t len, bool nowait) +{ + blk_opf_t opf = REQ_OP_SECURE_ERASE; + + if (nowait) + opf |= REQ_NOWAIT; + return blkdev_queue_cmd(cmd, bdev, start, len, + bdev_max_secure_erase_sectors(bdev), opf); +} + static int blkdev_cmd_discard(struct io_uring_cmd *cmd, struct block_device *bdev, uint64_t start, uint64_t len, bool nowait) @@ -911,6 +923,9 @@ int blkdev_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) case BLOCK_URING_CMD_WRITE_ZEROES: return blkdev_cmd_write_zeroes(cmd, bdev, start, len, bc->nowait); + case BLOCK_URING_CMD_SECURE_ERASE: + return blkdev_cmd_secure_erase(cmd, bdev, start, len, + bc->nowait); } return -EINVAL; } diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index b9e20ce57a28..425957589bdf 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -210,6 +210,7 @@ struct fsxattr { #define BLOCK_URING_CMD_DISCARD 0 #define BLOCK_URING_CMD_WRITE_ZEROES 1 +#define BLOCK_URING_CMD_SECURE_ERASE 2 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1) /* bmap access */