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 B6AE6C3ABCC for ; Wed, 14 May 2025 11:52:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF7EE6B013E; Wed, 14 May 2025 07:52:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA6986B013F; Wed, 14 May 2025 07:52:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A95B06B0140; Wed, 14 May 2025 07:52:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8C4C66B013E for ; Wed, 14 May 2025 07:52:26 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 866BC140B9B for ; Wed, 14 May 2025 11:52:26 +0000 (UTC) X-FDA: 83441350692.22.B3E9301 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by imf28.hostedemail.com (Postfix) with ESMTP id 77790C000C for ; Wed, 14 May 2025 11:52:24 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of tytso@mit.edu designates 18.9.28.11 as permitted sender) smtp.mailfrom=tytso@mit.edu; dmarc=pass (policy=none) header.from=mit.edu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747223544; 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; bh=Nd6VpjQT6jHiZtUp0fgFHjSIPFJW/GAJV3vukbZ2L6w=; b=aYiazPhV9f1y+u8GtOSVZmwsTi12bGTBDEP3Uilwry0+l1u8+PWMrEGCZxeCYo8BecGkve ztWayNkFC5HzYc3W2LPqSkeDfOf8YKe3kQhXLHhAxRdB43UrtBv0c93EKXVqmQMoLDE++Q vqcpHJPp3vISB424yGnQaVZattx1uqw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of tytso@mit.edu designates 18.9.28.11 as permitted sender) smtp.mailfrom=tytso@mit.edu; dmarc=pass (policy=none) header.from=mit.edu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747223544; a=rsa-sha256; cv=none; b=15cto5TCvkPM3ubroG5/vhQTb+UGo5Kk9isX9U4ZIppiPIG8+bCXJKfve0cV6JS9r/4NIj Zn1x1UOiGpWD1VAbEJQctLf+5NgKMulen7dSYyMnVnKUKeaBorPTJkyWWk0c+TCnCKnU4w dbIDhVhDc2j7FsCIA0k1oMTUlHpBvbM= Received: from trampoline.thunk.org (pool-173-48-112-151.bstnma.fios.verizon.net [173.48.112.151]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 54EBqBbZ012749 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 May 2025 07:52:12 -0400 Received: by trampoline.thunk.org (Postfix, from userid 15806) id 74E822E00DC; Wed, 14 May 2025 07:52:11 -0400 (EDT) Date: Wed, 14 May 2025 07:52:11 -0400 From: "Theodore Ts'o" To: =?utf-8?B?6ZmI5rab5rab?= Taotao Chen Cc: "adilger.kernel@dilger.ca" , "akpm@linux-foundation.org" , "willy@infradead.org" , "linux-ext4@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" Subject: Re: [PATCH 2/3] ext4: implement IOCB_DONTCACHE handling in write operations Message-ID: <20250514115211.GC9943@mit.edu> References: <20250421105026.19577-1-chentaotao@didiglobal.com> <20250421105026.19577-3-chentaotao@didiglobal.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250421105026.19577-3-chentaotao@didiglobal.com> X-Stat-Signature: k8z4r4jdp5c7yxi7bipkiizedcpcj836 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 77790C000C X-HE-Tag: 1747223544-669339 X-HE-Meta: U2FsdGVkX18KuRm1y3lEOeaTM7DjiyffYsXqbHyLe9L9nr8iDQ2271zIRGdQgGDXbUC0wMlCpvCAX83yvQyIA/TbCRPw8nW/+pgdkC7pbQ2ywCwyXVvUJ9SsfMpZjLaRpzVjBfSNXcp8HtezQfXb1a3qy3g86ZodTPmFk5F/Ty6vROkHi80d7dBCjmADuOG2Ikl8XcU5H47V8EDqpJ0VnUV1AMu3SS7AslFGH4qd9zPJhb1TqVPoAk7F89SbiSo4/phPUkG/0nwz24Cs8qz6a1wqo2Cxk1jrSP2FaBYQDTQ0/ccz9MFFBsIWRwA56Du4zhX7kIJHNoevz+usk2WWkv5NjQCPVNwEQT0DkVq1ywH/RSUgeIpB5jW6DCh01/g5jEUvkGVb7afZ5K6V90ILfpOIP2t0swBZt5mCqU2IlMc0uRTaLVXzEML+VPERGIMPlzdZtH/vkjvA1vF7bIxsKJA8KTv9bw6lVFZmG7RwBzSW5tTxX+hmOVg3Xy9lo9CetZZaRM4rrhW1EiCLiSGkk07oMzfvJctOXQsJzpP3MDeFqtVrR2gBNAqPKuMJhAT6ZWHgwE0V9RRGk61ZmI4c9wbJUbWksL4TqnLaOMs5Kpxy+d1tIpeyMYdlh0u5HVAp/kiymyFQKH4pkU5BRU0GOm6Cnurvsq/nEMFpOcqJPFHEwHmumiHXnShFQIFy/CfEcjoh1l4+xX1Fnm5MlJOFhssb2BscEIAioSssRyheUWbXeIM5JPq7F1mv4OOhBbeWzrHxQ/k4hpv1N2cs1LYEFosl6lfK2vMheJDkQ5rGcIR7s0S/R8tNlJQeL2T0V10tuzZeD9vUxKQKh/m3m/+M1A104jkA85/mn6m0mZkyhBuIdiLNaGWiSxUIjlL2tIm/vTRAoqvJ1Dt/vqq/bcVW29w0NOevHsPuTAg3nhFT1FgTsOUCd9zeRvnkcslxMnexQUnT5AxM+LlzgEq55Vu 7uENfvj6 rhAIU7m5o34Xd8PNUoj39jq9k8vDvg80gLItHsu/iZ0lj8aObh+2yHeAhWGGJcyfZ/mIgbWvBFIKWZuhGLFTClnOaGidciB7mgHqpzu1gAxh2MdfbdcclmqjwIogQG8N16EMdbwrqjHjrv5qcolV0gipOv4xDxrK1fcJaPLcPAzJXN3zdixMzH1huUKKIniDEby7p+FyvfYr+ZNjveW5umRUEbxvEU+wV0Q8qYb7+0eQCxJQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Mon, Apr 21, 2025 at 10:50:30AM +0000, 陈涛涛 Taotao Chen wrote: > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 94c7d2d828a6..787dd152a47e 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -1147,16 +1147,22 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, > { > struct inode *inode = mapping->host; > int ret, needed_blocks; > + int iocb_flag; > handle_t *handle; > int retries = 0; > struct folio *folio; > pgoff_t index; > + fgf_t fgp = FGP_WRITEBEGIN; > unsigned from, to; > > ret = ext4_emergency_state(inode->i_sb); > if (unlikely(ret)) > return ret; > > + iocb_flag = (int)(uintptr_t)(*fsdata); > + if (iocb_flag & IOCB_DONTCACHE) > + fgp |= FGP_DONTCACHE; > + See my comment against the first patch in this series. It *should* be possible to solve the problem just for ext4 by adding this line here: *fsdata = (void *)0; The problem is that it's super-fragile, since how *fsdata gets used changes at different points in time, so it makes code review and maintenance more difficult. (As evidenced by the fact that you missed this; this is not a criticism on your programming ability, but rather for the design choise of overloading the use of *fsdata. This is a trap that someone else might fall into when doing future code changes.) And of course, the question is whether PATCH 1/3 could potentially break other file systems. We would need audit all of the other *_write_begin() functions, and then document this for the sake of future file system developers that might want to change their write_begin() function. This is why my preference would be to add an extra flags paramter to write_begin(), but that is going to be a lot more work. Cheers, - Ted