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 D840FC3DA4A for ; Wed, 21 Aug 2024 02:55:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08BF36B0099; Tue, 20 Aug 2024 22:55:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03C1E6B009A; Tue, 20 Aug 2024 22:55:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E457E6B009B; Tue, 20 Aug 2024 22:55: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 C62546B0099 for ; Tue, 20 Aug 2024 22:55:26 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4AD0B12059B for ; Wed, 21 Aug 2024 02:55:26 +0000 (UTC) X-FDA: 82474736652.19.3A6C205 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 7E74AA0012 for ; Wed, 21 Aug 2024 02:55:24 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UMENePFl; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of ming.lei@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=ming.lei@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724208908; a=rsa-sha256; cv=none; b=gg0SOL6jz5/YxmpIzPl2fpMo1u+pHb/NZNWj8nMCWOIjCUfObgZrEVH1G4+g8lCoXfzDoL 3Ipt+3se2U3xP8CmJTPibof2dO0t87AJqD2q7H+NlibjRPpxahqTpfmy6INVgL3BzkMBqt YPxX8/6Z2aelOgGAaxgEgCmwZIJK2t0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UMENePFl; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of ming.lei@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=ming.lei@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724208908; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KSiSgD05DeHtm5VziINX4tjvKw+IZh1lV84+HlnOlgg=; b=Mi3eTLNZEwDRrUeWNRpEZwWqCn8VEnfIF+66FaBDLqa9C4fEfxWJ0nBz5IHDzhcmqi5uCg vfUx77spXSrA/dIu3dmk6HZhsRaK0IyZWDInIeN66Ceh2Hgw4hmwcp4EKSxjlzqQuEhLon B89/71aaZZLjq+INv1EArU54oLCduZ0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724208923; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KSiSgD05DeHtm5VziINX4tjvKw+IZh1lV84+HlnOlgg=; b=UMENePFlvT9G/Ph61dKDH1dEkGPySkgDjv+1/f2zOI574dFr9ZmNhzI/r6/5w0HLzdI33m HrdZLaIMu5Bnkq79+og1wWzYKAI4MbtATivg6iqBFDIpPh1NVRVz1FILR5Sw4rocM0FvmR zkTdXGRFTSFyOLYsrmv/RXwNCCEChsE= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-ufT1cexHObWimM0gMNSokA-1; Tue, 20 Aug 2024 22:55:20 -0400 X-MC-Unique: ufT1cexHObWimM0gMNSokA-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D31DD1955D4C; Wed, 21 Aug 2024 02:55:17 +0000 (UTC) Received: from fedora (unknown [10.72.116.126]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E46CE19560AE; Wed, 21 Aug 2024 02:55:11 +0000 (UTC) Date: Wed, 21 Aug 2024 10:55:06 +0800 From: Ming Lei To: Pavel Begunkov Cc: Jens Axboe , io-uring@vger.kernel.org, Conrad Meyer , linux-block@vger.kernel.org, linux-mm@kvack.org, Jan Kara , Shin'ichiro Kawasaki Subject: Re: [RFC 5/5] block: implement io_uring discard cmd Message-ID: References: <4d016a30-d258-4d0e-b3bc-18bf0bd48e32@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspam-User: X-Rspamd-Queue-Id: 7E74AA0012 X-Rspamd-Server: rspam01 X-Stat-Signature: akz3rs4pitcnup74d1iauacrscfszhzs X-HE-Tag: 1724208924-93329 X-HE-Meta: U2FsdGVkX1/mNZIzintftE35pccdL6GtS0UDKOvXU0SjFd5/0BDXyDFsNzfJ+kIQALx0PX3AUw6L8LLFxZ5b9D9G019nvjxdQNU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zZEjUrLq89vmhhO8krhwugl1WzP43C+Iftnyxp3MT43sIA5Rmr1YFvBf/qvk0O0t2Q9DXeQKRxDOYx7aXWkVFhyZEgw6PtRByptj6cff9zVTgZt/m33NPg7HcYBqMaznkUE4SPKoPZ6t6qGrkNiUPQzpRs6nom8mP7rpN6dG2tkDwFFhPh3OW2MzAFVLO1hsmI8Y2TMDxU2LlCW0y7ULIEMDyA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.017238, 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 Tue, Aug 20, 2024 at 06:19:00PM +0100, Pavel Begunkov wrote: > 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. Fair enough. > > 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. Yes, this way has degraded some sync discard workloads perf a lot. Thanks, Ming