From mboxrd@z Thu Jan 1 00:00:00 1970 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 AB656C3DA4A for ; Tue, 20 Aug 2024 17:18:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29DCB6B0083; Tue, 20 Aug 2024 13:18:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24C546B0085; Tue, 20 Aug 2024 13:18:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 113FC6B0088; Tue, 20 Aug 2024 13:18:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E386A6B0083 for ; Tue, 20 Aug 2024 13:18:35 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A082BA7825 for ; Tue, 20 Aug 2024 17:18:35 +0000 (UTC) X-FDA: 82473282990.01.7B75D49 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by imf08.hostedemail.com (Postfix) with ESMTP id A3BE2160035 for ; Tue, 20 Aug 2024 17:18:33 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=I5gNXpwa; spf=pass (imf08.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.218.43 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=1724174297; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=w+RXbpZ+OXyPsRrZFRrCFaRajdIpPUXoh7rfHKzntLs=; b=Wmxu14adMOYARtXIhQQsPpW/1mCN3FKnyXsWYpkl/sAr734wPlfFDJtO9sCgz79eZ8inTS p6fflMmMDwZxeSykIfR14gjVcDTtY9b3dyVjeU1e6oWoXOy9MzhRh+dt0YhN3xIP3keb49 Bl5jQ8/lz6GwKFPVrHpneUPTJijhnv0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=I5gNXpwa; spf=pass (imf08.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=asml.silence@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724174297; a=rsa-sha256; cv=none; b=ltrifGsLhbe1BtuEpfTRxUU2+qs3EMja9oNw9pj+PN0xFMldW7De9a2acz5vP0jr64l5d1 iJTzHTjH6Y7wGHCJl0R5VSAdehOQ34ddpOeEoZDCNgZuyEBuqkK0W2pgqlKIVOJJvXgY2O CnRP9NA961fqiReDKxstDzBpM5N3YqI= Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a7ab5fc975dso573664766b.1 for ; Tue, 20 Aug 2024 10:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724174312; x=1724779112; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=w+RXbpZ+OXyPsRrZFRrCFaRajdIpPUXoh7rfHKzntLs=; b=I5gNXpwa3VwEwuqCHb1Wmo8sIsVEstEa+QAvNnG3zON0sdd+A24arCZxjE970Oq81X ssNBA9W1kFj3FozSqLsU8xlAj7hQz/p8yRFecL4Ih7nRr95VKjewH39jg7vjEPhrLWhv Ic2zqa7mNhhZsOUrKRTn3ufegjdq43fuwrvH4SkleATcLfkmkFGT+x4JYry60a27/OgM xLhTgmWeQdwwjrRZvG3NLfuLd6bHYg6Dl1D75sVx/8CHe045GJV1iGafp/f8RJyyo8r3 n/Ctdx+jiOY6zMNFZXNp93eZWED6Ss/IB30DbxyHq+pB2dUKS4yXQ01FQtx0P4jhCHC1 EJ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724174312; x=1724779112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w+RXbpZ+OXyPsRrZFRrCFaRajdIpPUXoh7rfHKzntLs=; b=bHDe3X4t3Jq28a0rIm+50PRYWyvgn+PBY7H6BeAuDbN+brdM7imRFR6QdwYYLWmTz7 T9ri0DW3yrtFLstJKt8OVqz6YGI3yyS1wNxgoWxBjyP8eDPd8+tzUEYb5dhE6hJr7mEc kL9O4omozvXfKTG6LA+bdYo+grCQDErssdcMt9k7qQ5k2uDViiOFOta6Jl0Fvg6dA5/E vX3xE9kB7RG0l4lZF2IzPcDt0P/9Kj5sfvSSRKiEE8tlYuXCcOn5g1++gFlruuXX5CtT 221qp9oIe+lazidC5R0HPpbMx7unUWLE7zfitn/N4wvv1uifMSKKIuQ94j8Hh+h+ro9N 1Z4A== X-Forwarded-Encrypted: i=1; AJvYcCWHSjmybvx5mbLID/U1hKZi5JQaszR39qxmo+ZwhLfl0uGKeLcEGYTN3e7WiWaTjTrz0XIoJDF0cQ==@kvack.org X-Gm-Message-State: AOJu0YxEt9ts4rH4Ad7YBIW5jZJsI8yY7y0rEy5G0JlGyHLuXfWNI+nR Rp+7SrurMGUCH2i6RC3IKjr597jaj2b0jj5cmKJbca5oiN1Q/wqR X-Google-Smtp-Source: AGHT+IH3k+sZO9tU+W74giEEa69Bw48c6Vz0E0qFyPViLeM3L11zqSo6gMiaGiLsiwO4iLdVM/Jr1w== X-Received: by 2002:a17:907:1c08:b0:a86:672d:8436 with SMTP id a640c23a62f3a-a86672d874dmr37469166b.59.1724174311455; Tue, 20 Aug 2024 10:18:31 -0700 (PDT) Received: from [192.168.42.136] ([148.252.128.6]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a83838eeeefsm787314866b.97.2024.08.20.10.18.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Aug 2024 10:18:31 -0700 (PDT) Message-ID: Date: Tue, 20 Aug 2024 18:19:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 5/5] block: implement io_uring discard cmd To: Jens Axboe , Ming Lei Cc: io-uring@vger.kernel.org, Conrad Meyer , linux-block@vger.kernel.org, linux-mm@kvack.org, Jan Kara , Shin'ichiro Kawasaki References: <6ecd7ab3386f63f1656dc766c1b5b038ff5353c2.1723601134.git.asml.silence@gmail.com> <4d016a30-d258-4d0e-b3bc-18bf0bd48e32@kernel.dk> Content-Language: en-US From: Pavel Begunkov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Stat-Signature: hsz56b94aq4k9xubbrh6efsj9bxu9rzj X-Rspamd-Queue-Id: A3BE2160035 X-Rspamd-Server: rspam11 X-HE-Tag: 1724174313-527197 X-HE-Meta: U2FsdGVkX18F5c/VghTG9fSTQHaLGBVA2OmHveh9YgiVcdzB9+AK/V13Pkiilly+BBv9AvMi8WEG+/QIty2j/OEL/zTjT8PrhpOyX/GKLjus6z6KX8vNQWWx21PyTqKpt2+IOqSuuLYtDcSA9uLE67vgdIAo3AXxojw1cEpAEyeC3ytrm3VJE/36ePfwiDx0mak2m9X3CNXBjYTFbQcQeKQrESgdzVPeiKNerj0KuhH6tpzClcflFggRbj8InreRGN+sxcUm9oFkTbU78CJPOLa1Bllj6qoOphqu48Fk1r/ysxSVhHH+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mcZEAFX1JOmr/XbKBiLDIE0RsdfbNuLKOgPqohIl1FWmic0njsUep7osYixlbsc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.252063, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 8/20/24 17:30, Jens Axboe wrote: > On 8/19/24 8:36 PM, Ming Lei wrote: >> On Mon, Aug 19, 2024 at 02:01:21PM -0600, Jens Axboe wrote: >>> On 8/15/24 7:45 PM, Ming Lei wrote: ... >>>> Meantime the handling has to move to io-wq for avoiding to block current >>>> context, the interface becomes same with IORING_OP_FALLOCATE? >>> >>> I think the current truncate is overkill, we should be able to get by >>> without. And no, I will not entertain an option that's "oh just punt it >>> to io-wq". >> >> BTW, the truncate is added by 351499a172c0 ("block: Invalidate cache on discard v2"), >> and block/009 serves as regression test for covering page cache >> coherency and discard. >> >> Here the issue is actually related with the exclusive lock of >> filemap_invalidate_lock(). IMO, it is reasonable to prevent page read during >> discard for not polluting page cache. block/009 may fail too without the lock. >> >> It is just that concurrent discards can't be allowed any more by >> down_write() of rw_semaphore, and block device is really capable of doing >> that. It can be thought as one regression of 7607c44c157d ("block: Hold invalidate_lock in >> BLKDISCARD ioctl"). >> >> Cc Jan Kara and Shin'ichiro Kawasaki. > > Honestly I just think that's nonsense. It's like mixing direct and > buffered writes. Can you get corruption? Yes you most certainly can. > There should be no reason why we can't run discards without providing > page cache coherency. The sync interface attempts to do that, but that > doesn't mean that an async (or a different sync one, if that made sense) > should. I don't see it as a problem either, it's a new interface, just need to be upfront on what guarantees it provides (one more reason why not fallocate), I'll elaborate on it in the commit message and so. I think a reasonable thing to do is to have one rule for all write-like operations starting from plain writes, which is currently allowing races to happen and shift it to the user. Purely in theory we can get inventive with likes of range lock trees, but that's unwarranted for all sorts of reasons. > If you do discards to the same range as you're doing buffered IO, you > get to keep both potentially pieces. Fact is that most folks are doing > dio for performant IO exactly because buffered writes tend to be > horrible, and you could certainly use that with async discards and have > the application manage it just fine. > > So I really think any attempts to provide page cache synchronization for > this is futile. And the existing sync one looks pretty abysmal, but it > doesn't really matter as it's a sync interfce. If one were to do It should be a pain for sync as well, you can't even spin another process and parallelise this way. -- Pavel Begunkov