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 C859FC02194 for ; Wed, 5 Feb 2025 13:03:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42D0B280003; Wed, 5 Feb 2025 08:03:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B552280002; Wed, 5 Feb 2025 08:03:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2562E280003; Wed, 5 Feb 2025 08:03:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 02A9F280002 for ; Wed, 5 Feb 2025 08:03:41 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F21E24A82F for ; Wed, 5 Feb 2025 13:03:33 +0000 (UTC) X-FDA: 83085907506.22.A4005B2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id B9CB6160004 for ; Wed, 5 Feb 2025 13:03:31 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TwQub1Ph; spf=pass (imf08.hostedemail.com: domain of vgoyal@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vgoyal@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738760612; 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=l83Dw368hueJll8PyntCW0Nb5bpCWlX4zt8mq3uaKys=; b=uCc5AG4VZ6LGFdxcYw75kCKVvyNbtX2YxpNGeZyBfck32uCBWpymdNm1xcpk0J2iYHD2sv bqR9UKdw6h1dEJthCbjLp8izMDKxUDI4yz48dcPFYNCez4Gw0s7Mhqdssc33JDeIn8quZa hku1Qp2KYoZHG2DKNDgt9x9BHJBDU9w= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TwQub1Ph; spf=pass (imf08.hostedemail.com: domain of vgoyal@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vgoyal@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738760612; a=rsa-sha256; cv=none; b=nbF0DX5FOjy4v7Ih3S/aGIk86EiT47MyyzI3pgIK5VT1b4aZs+g3pUfEvIJKRV1+XBZ7o/ FTTkGHyajKm5x6DkRKlVgZ/9GKr/EoYfnXypz1XquQkkIfglxfsnO2VnC0n9uwqKBICYIf PGUjslmUuQzv4VGsKilKvSjEomO4R1g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738760611; 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=l83Dw368hueJll8PyntCW0Nb5bpCWlX4zt8mq3uaKys=; b=TwQub1PhoRy5S12ucWdUn6vfC6TRPOnQvzeS6HIlZgdaMGi+dCLCjs9bwzgLNdl4yT9ZBW XvgpacyXRHQZD47IsMTBuENUBM1EOlPH7lnkWloj7JUTFMhluB030UdEG86jw0Zki8IMUd pjXOG/nAD9WQXKB3bx2tsr7CsWM2Gew= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-1l4K9GaVMGO1d3Se1A4h_Q-1; Wed, 05 Feb 2025 08:03:26 -0500 X-MC-Unique: 1l4K9GaVMGO1d3Se1A4h_Q-1 X-Mimecast-MFC-AGG-ID: 1l4K9GaVMGO1d3Se1A4h_Q Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5FC961801A0D; Wed, 5 Feb 2025 13:03:19 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.186]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 72B8C3000197; Wed, 5 Feb 2025 13:03:15 +0000 (UTC) Received: by fedora.redhat.com (Postfix, from userid 1000) id A724B6AA37D; Wed, 5 Feb 2025 08:03:13 -0500 (EST) Date: Wed, 5 Feb 2025 08:03:13 -0500 From: Vivek Goyal To: Alistair Popple Cc: akpm@linux-foundation.org, dan.j.williams@intel.com, linux-mm@kvack.org, alison.schofield@intel.com, lina@asahilina.net, zhang.lyra@gmail.com, gerald.schaefer@linux.ibm.com, vishal.l.verma@intel.com, dave.jiang@intel.com, logang@deltatee.com, bhelgaas@google.com, jack@suse.cz, jgg@ziepe.ca, catalin.marinas@arm.com, will@kernel.org, mpe@ellerman.id.au, npiggin@gmail.com, dave.hansen@linux.intel.com, ira.weiny@intel.com, willy@infradead.org, djwong@kernel.org, tytso@mit.edu, linmiaohe@huawei.com, david@redhat.com, peterx@redhat.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, jhubbard@nvidia.com, hch@lst.de, david@fromorbit.com, chenhuacai@kernel.org, kernel@xen0n.name, loongarch@lists.linux.dev, Hanna Czenczek , German Maglione Subject: Re: [PATCH v6 01/26] fuse: Fix dax truncate/punch_hole fault path Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B9CB6160004 X-Stat-Signature: 14wic9mx6tsfdczkypqcpya6xwb9aawj X-Rspam-User: X-HE-Tag: 1738760611-450076 X-HE-Meta: U2FsdGVkX18Nfn8OLVj5dGWMye0MCHa8idLygjavJ578PfMEhETiISGjopGsSYNj+83wxLYwiCnPlpCSsYgUwWrRiMsU8NmhXaKd2cc8pcdWoCExamFHm/GtDSOGaCFfBHqnfjwcdoSpLEC6oPPdpRFliF2SePLb102DxBriXSn3wOWs/tMX5QA7Q+uDeMvihCiI9xPKITSP9KW5QlNOpa/+6V/51jVTP+1wip04F8mCc7sJOIsVwUGRrwF6uii/Ew9fcXtybRCYHYIyW3oRzHTjdL6z0jvsIkIBnLpxVycxd0c4WAAGFbktQOnrhJ+ZjeSEKSePmLIr2WYHDZYgIuFJamMJ3RAid6HLxac4Fo4Sq6viIi43ntjGa9w72QN62/O5mkMRA7zp+qcyM8CbQv+/isyK7diaRG0nkr4eagpsCxGtGpkrAsd1PvCGv+GqDCDjzfY/wp8IuCx3CFl6Jwl/532j2zZFf082gWRSGlJYC6U/KKfi6vHfOK/ymW2VSgMmLChKMYASy8lB97qlDMzuwQqLM2mjW1yMdKKOps0fz3EogMcTl/UKMtP9zqxKZW8MIVndhTC9B30PtA3sB3GSMJbreAUcWs5BTqocEGuiJPRefjfFU4OrRHua7w4ydgiWiiSixyGMAwlRvSPtAn5QqVcznGj0ykJBLpxSH5w+OrtrLghQ7THTVXNUqg/SGc2hzIZMC6+3UNE2o48g8UCB2du9z+30DdIdrUx8eIaORFidip+47GZPyGd9vCdVySaQAGshXEhMdeuglrf7+uXHHWydRvbIGOJ2N1B5Pi6yWSAVVeTaVjGHMwxWN3irGS+CIhwIrRvSem+npfr3OpdiEvzqXrYXAti/Y9x2padOXp5njongeZ+/TaEV7shJJyYhXKPHtsTle46rRZczH+OnoKW78jpDr0vXXfuTx+/OJxA5Z84J2yV8jNy8F/+aDoiZ5rck+sjKPb4yU4e r7y3RT+l Sp5Kd0NRBK359GpB3sbajhkIV+UHP3F8QkFCFnklrms8PgYb8u/GdsYRPpM4gTyRAakfPDJM8LMfhYrLJubZDE0N7YDV/T5ZLtH2F/4RYcWJGszWa3dRuXq3Uwt7NbfS2sfApZ/AQmih7HLgsXPLMJ0+c1inNElJ5Sa5axh/pXdh/OQXKGYBzXuYrzFcDUC8ioOZ1Es6r+s17YxIi48iNXJLsZo5CH05mnWCyWqE5el7eqQ/gelg111y3qT2nEdG+Rv8vgAnFKpdP9TEZPeOy0XoPA2sWCIMKLfJ8AqfKLvcW5ul7Mdr6jg92DnfhD4Cw21rc5kYnDlWSixxAbbIRe9KI+85uNSkcuqXhsvVFG3jn7NchvIusoPrFyS7ZyGhOZe3HQalDVxfMqSDXAs1YD+MzgTH2CRCyr/NArdbzxyjzwUc0me2gPe26xkG74LK0Iwg0E208B+mCkilRdPdF/l4PP/hYP3nSXZRBjAp6/+fYTp0sJIRRtgcgEQ== 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 Fri, Jan 10, 2025 at 05:00:29PM +1100, Alistair Popple wrote: > FS DAX requires file systems to call into the DAX layout prior to unlinking > inodes to ensure there is no ongoing DMA or other remote access to the > direct mapped page. The fuse file system implements > fuse_dax_break_layouts() to do this which includes a comment indicating > that passing dmap_end == 0 leads to unmapping of the whole file. > > However this is not true - passing dmap_end == 0 will not unmap anything > before dmap_start, and further more dax_layout_busy_page_range() will not > scan any of the range to see if there maybe ongoing DMA access to the > range. Fix this by passing -1 for dmap_end to fuse_dax_break_layouts() > which will invalidate the entire file range to > dax_layout_busy_page_range(). Hi Alistair, Thanks for fixing DAX related issues for virtiofs. I am wondering how are you testing DAX with virtiofs. AFAIK, we don't have DAX support in Rust virtiofsd. C version of virtiofsd used to have out of the tree patches for DAX. But C version got deprecated long time ago. Do you have another implementation of virtiofsd somewhere else which supports DAX and allows for testing DAX related changes? Thanks Vivek > > Signed-off-by: Alistair Popple > Co-developed-by: Dan Williams > Signed-off-by: Dan Williams > Fixes: 6ae330cad6ef ("virtiofs: serialize truncate/punch_hole and dax fault path") > Cc: Vivek Goyal > > --- > > Changes for v6: > > - Original patch had a misplaced hunk due to a bad rebase. > - Reworked fix based on Dan's comments. > --- > fs/fuse/dax.c | 1 - > fs/fuse/dir.c | 2 +- > fs/fuse/file.c | 4 ++-- > 3 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c > index 9abbc2f..455c4a1 100644 > --- a/fs/fuse/dax.c > +++ b/fs/fuse/dax.c > @@ -681,7 +681,6 @@ static int __fuse_dax_break_layouts(struct inode *inode, bool *retry, > 0, 0, fuse_wait_dax_page(inode)); > } > > -/* dmap_end == 0 leads to unmapping of whole file */ > int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start, > u64 dmap_end) > { > diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c > index 0b2f856..bc6c893 100644 > --- a/fs/fuse/dir.c > +++ b/fs/fuse/dir.c > @@ -1936,7 +1936,7 @@ int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry, > if (FUSE_IS_DAX(inode) && is_truncate) { > filemap_invalidate_lock(mapping); > fault_blocked = true; > - err = fuse_dax_break_layouts(inode, 0, 0); > + err = fuse_dax_break_layouts(inode, 0, -1); > if (err) { > filemap_invalidate_unlock(mapping); > return err; > diff --git a/fs/fuse/file.c b/fs/fuse/file.c > index 082ee37..cef7a8f 100644 > --- a/fs/fuse/file.c > +++ b/fs/fuse/file.c > @@ -253,7 +253,7 @@ static int fuse_open(struct inode *inode, struct file *file) > > if (dax_truncate) { > filemap_invalidate_lock(inode->i_mapping); > - err = fuse_dax_break_layouts(inode, 0, 0); > + err = fuse_dax_break_layouts(inode, 0, -1); > if (err) > goto out_inode_unlock; > } > @@ -2890,7 +2890,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, > inode_lock(inode); > if (block_faults) { > filemap_invalidate_lock(inode->i_mapping); > - err = fuse_dax_break_layouts(inode, 0, 0); > + err = fuse_dax_break_layouts(inode, 0, -1); > if (err) > goto out; > } > -- > git-series 0.9.1 >