From patchwork Tue Oct 29 15:11:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13855030 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8932190049 for ; Tue, 29 Oct 2024 15:12:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730214744; cv=none; b=uAHLj1vd5211mWufgV68TKkwZZfZTVhdqIf2mY5DmGZH6hTGdgh3gz37M06DpxMcw8B228ngLgak4gv43COt3/nQuhNpHkAhenDRM9jf9GT4qb8vzo+jkPwhnJq56jTOGX1WPER/eCLH8p03/RXWF4kCLUy2nk1s0hSH2zSKhsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730214744; c=relaxed/simple; bh=xeQ26DIlFwrMo2tpZVlvM4eYdtwaRLKDa0qnE7po2qU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F+/NmWKNHSZxsJnUPjCQ18N9w9JomSbIiwrQ/9XAhywjrRMAmI8itSNlYBpQtnUZK8GIXDncNjuUbpS7VMAot2yoPUaNjID7DCgou3AdvIPUpber2C7OzQg6R/nDX8ovmLByJCpYzzHFcXaeNYXHK4AWs4PWM3X0kFU5LD65IUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=wxHSJyo3; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="wxHSJyo3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=EVcjD4YSWsWdRq3FuGYrccSP7KzdxSTLpPYrhC9zBiA=; b=wxHSJyo31GIfFvVjmpuSKYyCq0 Mr0J16aCH3BZpxrsEYDRKvM3ysQmc1Bt//HBG+J7zNTD3hX9GRZb87vTonBenntClb3RsY+is2lPA WU0/JiDrGB6+OmQSWXapW1J/7tj01P9+CR3A7E9NpVbFIArSZJJcic8+RUZsLJa5ZjtD0d1oJYbZc MmtLhf03qFzYuzBIqpkxoRb+ZeokHr3p9lb6ujJUIke7H5q3tt1ljjsMwlihTeEYKKKV2mmMFoqib 7Qx+yOA4Hrz4YNtMTj2m+kor7OZePJc+5K+w5+i4/3UVSMNnP96FN7gybv7kisbLoBewqiJjVKQ7y /zZ83RLg==; Received: from 2a02-8389-2341-5b80-1009-120a-6297-8bca.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:1009:120a:6297:8bca] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1t5ntN-0000000EqrL-0oZg; Tue, 29 Oct 2024 15:12:21 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 1/4] xfs: split the page fault trace event Date: Tue, 29 Oct 2024 16:11:57 +0100 Message-ID: <20241029151214.255015-2-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029151214.255015-1-hch@lst.de> References: <20241029151214.255015-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Split the xfs_filemap_fault trace event into separate ones for read and write faults and move them into the applicable locations. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 8 ++++++-- fs/xfs/xfs_trace.h | 20 ++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index b19916b11fd5..20f7f92b8867 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1425,6 +1425,8 @@ xfs_dax_read_fault( struct xfs_inode *ip = XFS_I(file_inode(vmf->vma->vm_file)); vm_fault_t ret; + trace_xfs_read_fault(ip, order); + xfs_ilock(ip, XFS_MMAPLOCK_SHARED); ret = xfs_dax_fault_locked(vmf, order, false); xfs_iunlock(ip, XFS_MMAPLOCK_SHARED); @@ -1442,6 +1444,8 @@ xfs_write_fault( unsigned int lock_mode = XFS_MMAPLOCK_SHARED; vm_fault_t ret; + trace_xfs_write_fault(ip, order); + sb_start_pagefault(inode->i_sb); file_update_time(vmf->vma->vm_file); @@ -1485,12 +1489,12 @@ __xfs_filemap_fault( { struct inode *inode = file_inode(vmf->vma->vm_file); - trace_xfs_filemap_fault(XFS_I(inode), order, write_fault); - if (write_fault) return xfs_write_fault(vmf, order); if (IS_DAX(inode)) return xfs_dax_read_fault(vmf, order); + + trace_xfs_read_fault(XFS_I(inode), order); return filemap_fault(vmf); } diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index ee9f0b1f548d..efc4aae295aa 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -827,28 +827,32 @@ DEFINE_INODE_EVENT(xfs_inode_inactivating); TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_SHARED); TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_COW); -TRACE_EVENT(xfs_filemap_fault, - TP_PROTO(struct xfs_inode *ip, unsigned int order, bool write_fault), - TP_ARGS(ip, order, write_fault), +DECLARE_EVENT_CLASS(xfs_fault_class, + TP_PROTO(struct xfs_inode *ip, unsigned int order), + TP_ARGS(ip, order), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_ino_t, ino) __field(unsigned int, order) - __field(bool, write_fault) ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; __entry->ino = ip->i_ino; __entry->order = order; - __entry->write_fault = write_fault; ), - TP_printk("dev %d:%d ino 0x%llx order %u write_fault %d", + TP_printk("dev %d:%d ino 0x%llx order %u", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, - __entry->order, - __entry->write_fault) + __entry->order) ) +#define DEFINE_FAULT_EVENT(name) \ +DEFINE_EVENT(xfs_fault_class, name, \ + TP_PROTO(struct xfs_inode *ip, unsigned int order), \ + TP_ARGS(ip, order)) +DEFINE_FAULT_EVENT(xfs_read_fault); +DEFINE_FAULT_EVENT(xfs_write_fault); + DECLARE_EVENT_CLASS(xfs_iref_class, TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), TP_ARGS(ip, caller_ip), From patchwork Tue Oct 29 15:11:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13855031 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 058DE190049 for ; Tue, 29 Oct 2024 15:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730214747; cv=none; b=sLAX2xcKKB4/qL74//cP7jNui+8HiR5t9w9vvKU9K1SdD461F1D4SuX3+XstR2tMCfKoCPY6L57vx8HYnp6HX2qFbNqbTuphNjPbnSZ6oh8w4cWzHIrZUuPgVFF8EvieMNwTOAhJqC6rggnff2KilOV7IVRGCqi1K+2Cg7y0ljQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730214747; c=relaxed/simple; bh=fOKLWD9ftUlx5K2yiKtmK3sXOAkSa4//Qrka9PhMHKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pDHKgk9MTpaNoZV+bKJH/8JBJ17icRNW4siq98zEDC5qFabd3uFniWDZBk5y45wrEQjrlahwWuPwCwCzer5cAG31D7kXzP8UX+U8TjXN/pVEWGOuRhXI/4W7UQoPskNlQTVPQKjGKscY4lj1FhQwe4+X3JCwJigYCunqqrMGwNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=QBTXWM5Q; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QBTXWM5Q" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=fXNg0673JUF6JDVyKLxZbzNHZL1M1b+N09iYlJm5zHM=; b=QBTXWM5Qax3bS5KgJbkDieSp7Q +BYUSB8KWnvxKS/UVnccYLDL6pKJGHVvnkeBQwMrAfidhYmBHEjC6AR1JeL/fjmplefLz/7rC4Q4i 5h4s8qodoWuyhbNWpqZI4nYKe5zU3mm+dnPqnYwFsU/Avj9Ex6b3oktFj2QKfgBBkiIoGSvIwNLB2 1gKdI/huBdp+PuWjhZzdtNfQb80/4bAShm4eUAPWk7YX1l7QHIYShghYetRmah+IFxN34oeX+IBHy +1gwWZgxcWopsF9PC5Ju08I17aSxsjzHuDoDoXw2WJjX5QvqOOFG6gmkF4Q+X7ZJMygCm6LQTBrOC 92xosp5w==; Received: from 2a02-8389-2341-5b80-1009-120a-6297-8bca.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:1009:120a:6297:8bca] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1t5ntQ-0000000EqrY-0L6n; Tue, 29 Oct 2024 15:12:24 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 2/4] xfs: split write fault handling out of __xfs_filemap_fault Date: Tue, 29 Oct 2024 16:11:58 +0100 Message-ID: <20241029151214.255015-3-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029151214.255015-1-hch@lst.de> References: <20241029151214.255015-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Only two of the callers of __xfs_filemap_fault every handle read faults. Split the write_fault handling out of __xfs_filemap_fault so that all callers call that directly either conditionally or unconditionally and only leave the read fault handling in __xfs_filemap_fault. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 20f7f92b8867..0b8e36f8703c 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1434,6 +1434,16 @@ xfs_dax_read_fault( return ret; } +/* + * Locking for serialisation of IO during page faults. This results in a lock + * ordering of: + * + * mmap_lock (MM) + * sb_start_pagefault(vfs, freeze) + * invalidate_lock (vfs/XFS_MMAPLOCK - truncate serialisation) + * page_lock (MM) + * i_lock (XFS - extent map serialisation) + */ static vm_fault_t xfs_write_fault( struct vm_fault *vmf, @@ -1471,26 +1481,13 @@ xfs_write_fault( return ret; } -/* - * Locking for serialisation of IO during page faults. This results in a lock - * ordering of: - * - * mmap_lock (MM) - * sb_start_pagefault(vfs, freeze) - * invalidate_lock (vfs/XFS_MMAPLOCK - truncate serialisation) - * page_lock (MM) - * i_lock (XFS - extent map serialisation) - */ static vm_fault_t __xfs_filemap_fault( struct vm_fault *vmf, - unsigned int order, - bool write_fault) + unsigned int order) { struct inode *inode = file_inode(vmf->vma->vm_file); - if (write_fault) - return xfs_write_fault(vmf, order); if (IS_DAX(inode)) return xfs_dax_read_fault(vmf, order); @@ -1511,9 +1508,9 @@ xfs_filemap_fault( struct vm_fault *vmf) { /* DAX can shortcut the normal fault path on write faults! */ - return __xfs_filemap_fault(vmf, 0, - IS_DAX(file_inode(vmf->vma->vm_file)) && - xfs_is_write_fault(vmf)); + if (IS_DAX(file_inode(vmf->vma->vm_file)) && xfs_is_write_fault(vmf)) + return xfs_write_fault(vmf, 0); + return __xfs_filemap_fault(vmf, 0); } static vm_fault_t @@ -1525,15 +1522,16 @@ xfs_filemap_huge_fault( return VM_FAULT_FALLBACK; /* DAX can shortcut the normal fault path on write faults! */ - return __xfs_filemap_fault(vmf, order, - xfs_is_write_fault(vmf)); + if (xfs_is_write_fault(vmf)) + return xfs_write_fault(vmf, order); + return __xfs_filemap_fault(vmf, order); } static vm_fault_t xfs_filemap_page_mkwrite( struct vm_fault *vmf) { - return __xfs_filemap_fault(vmf, 0, true); + return xfs_write_fault(vmf, 0); } /* @@ -1545,8 +1543,7 @@ static vm_fault_t xfs_filemap_pfn_mkwrite( struct vm_fault *vmf) { - - return __xfs_filemap_fault(vmf, 0, true); + return xfs_write_fault(vmf, 0); } static const struct vm_operations_struct xfs_file_vm_ops = { From patchwork Tue Oct 29 15:11:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13855032 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D8BC1946A2 for ; Tue, 29 Oct 2024 15:12:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730214749; cv=none; b=jszX/8nSyAVHKXHsP76BtwgF91YhSAfrxJfcW5FDg3VDHaGysf0dtarMbvL/JOCgbaOTFobKjWjp/GBB33atond+33Rwb3d8N5xD3/wC8XP3fs+Ae3T6nFslI443hGIiex8ZbADuyplO238zc++yuAyh4r1O18SeoTuDHX9dbyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730214749; c=relaxed/simple; bh=gP+U3suwbd18xb1Y3R5xpcJsqx0AJe7c+lh5LH0/jvM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GzSz3OnZszI1KaxmTfYxxwUT1RPHAYO/X3GbCco5f5AtKU/My3VA1KLz9XZBwBNEFS/N2JI9Yt9xqxqRENep7JjxmqTFVJdjldbISLUVchP8rr8PhZRumXciK3H1J9BtAuk1cOzgjaAgbL8gq+wTE/5I1P9bTUvjL7NlA20hXcs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=C5zlu22l; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="C5zlu22l" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=FofnZmtHDw9S2j4BL1iaFz4F1rJW9fl4Oy0MW85c764=; b=C5zlu22lQs4t1mdt0J9XZtYU5n lxe8acQvRLiPjwkKiMYVZxfCWRFkFG+PJ0zOeUvRiTFbkexH4zL+91APMYu5AqOpy4E/bYX8XWs55 wcHJksHxcne8043JrC41tbRBStsRWaicCicQwoj96Jq61RF63sFPiSROfw6MDWrLm5pzCVopC47AB MaLW4HAsCCMNKdKI6AFJ27vKnB9LXNSCdyzzKyqZ7QNi+p/VdaRWnPdeoIxJPTu/R0w5U4abo832U tnttkBL5m/dgaTECbZPpa1LmaXO0w6T9HnL54O6FOun+1f95LzM4IoL7vkT+toarnWqVU1z76dqto cuTnlkJw==; Received: from 2a02-8389-2341-5b80-1009-120a-6297-8bca.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:1009:120a:6297:8bca] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1t5ntT-0000000Eqs4-0b6l; Tue, 29 Oct 2024 15:12:27 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 3/4] xfs: remove __xfs_filemap_fault Date: Tue, 29 Oct 2024 16:11:59 +0100 Message-ID: <20241029151214.255015-4-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029151214.255015-1-hch@lst.de> References: <20241029151214.255015-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html xfs_filemap_huge_fault only ever serves DAX faults, so hard code the call to xfs_dax_read_fault and open code __xfs_filemap_fault in the only remaining caller. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 0b8e36f8703c..7464d874e766 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1481,20 +1481,6 @@ xfs_write_fault( return ret; } -static vm_fault_t -__xfs_filemap_fault( - struct vm_fault *vmf, - unsigned int order) -{ - struct inode *inode = file_inode(vmf->vma->vm_file); - - if (IS_DAX(inode)) - return xfs_dax_read_fault(vmf, order); - - trace_xfs_read_fault(XFS_I(inode), order); - return filemap_fault(vmf); -} - static inline bool xfs_is_write_fault( struct vm_fault *vmf) @@ -1507,10 +1493,17 @@ static vm_fault_t xfs_filemap_fault( struct vm_fault *vmf) { + struct inode *inode = file_inode(vmf->vma->vm_file); + /* DAX can shortcut the normal fault path on write faults! */ - if (IS_DAX(file_inode(vmf->vma->vm_file)) && xfs_is_write_fault(vmf)) - return xfs_write_fault(vmf, 0); - return __xfs_filemap_fault(vmf, 0); + if (IS_DAX(inode)) { + if (xfs_is_write_fault(vmf)) + return xfs_write_fault(vmf, 0); + return xfs_dax_read_fault(vmf, 0); + } + + trace_xfs_read_fault(XFS_I(inode), 0); + return filemap_fault(vmf); } static vm_fault_t @@ -1524,7 +1517,7 @@ xfs_filemap_huge_fault( /* DAX can shortcut the normal fault path on write faults! */ if (xfs_is_write_fault(vmf)) return xfs_write_fault(vmf, order); - return __xfs_filemap_fault(vmf, order); + return xfs_dax_read_fault(vmf, order); } static vm_fault_t From patchwork Tue Oct 29 15:12:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13855033 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96070192B63 for ; Tue, 29 Oct 2024 15:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730214753; cv=none; b=TvIdve6KYiBTQ4WweMrTtjsijsugTdURG3tdYxVFOL9MtZOmoyJlDncWV0mtetY4uNydp0nadWViS3KjRkTKzdfrgGa6+EEDE+BvLRX8DxLoM/Ob52T4q1aMtKPF49GABdjTXa/ZvKX9MuIT9YuqNiOfIky4iN85Mr8F6arnTY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730214753; c=relaxed/simple; bh=GPh2GAapT0BQVloyUXp6jQFdR/WUu53FO3h1cwuQh8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eabq1CujHvMLzFuDerhSiK9s45SC7jelQFdUB4isb5AtXnVz67rjw6c4dF/oP/oF9kiVk0PS0HRkH1RSMaCuFJb4KEJrBhpLsAj4a3Ea0duTBdFUQuHOEMaBqoC+0DXMUORW8ib2JSPfAhA9bKfEYSFNSZb10JfJ9/XOvOieLnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=UHe6BwMn; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="UHe6BwMn" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=ddrkNXVxAfkB5dngi+D0S6YET5DG/cNomisnRWc7EeE=; b=UHe6BwMnRLL6UagVd8zllZZPws eCJvTG5sb9Q8UwhCCYZeTAqP9b40yRkinSyAWL2w3iiocaIYwRS+37++cZ9GOhoG1egz9HZUTL+r8 icNM62iebGYRAUYXWonhp3P5PtCsho/M9TIgCM9qTqaYTAfiqpBi3kkB98zPo7alhW6mBU6DPkXgJ A8jPBXccJrR7eHGIXaYXB80ETv0fEMkrsP8SnjOaxNEYPkOGOj0Y83QA81YKDEQybS0N3CJFyDfCa yK4tVlPLZe3hkvVFwPkiAuwm12PrHpVCQZHcIjmSIFdQ2A4oX3klNCXTy+UhNsNPgWzgzav8fmwqC Ryqpg3Ag==; Received: from 2a02-8389-2341-5b80-1009-120a-6297-8bca.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:1009:120a:6297:8bca] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1t5ntW-0000000Eqtx-2ZzM; Tue, 29 Oct 2024 15:12:31 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 4/4] xfs: remove xfs_page_mkwrite_iomap_ops Date: Tue, 29 Oct 2024 16:12:00 +0100 Message-ID: <20241029151214.255015-5-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029151214.255015-1-hch@lst.de> References: <20241029151214.255015-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Shared the regular buffered write iomap_ops with the page fault path and just check for the IOMAP_FAULT flag to skip delalloc punching. This keeps the delalloc punching checks in one place, and will make it easier to convert iomap to an iter model where the begin and end handlers are merged into a single callback. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_iomap.c | 17 ++++++++--------- fs/xfs/xfs_iomap.h | 1 - 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 7464d874e766..c6de6b865ef1 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1474,7 +1474,7 @@ xfs_write_fault( if (IS_DAX(inode)) ret = xfs_dax_fault_locked(vmf, order, true); else - ret = iomap_page_mkwrite(vmf, &xfs_page_mkwrite_iomap_ops); + ret = iomap_page_mkwrite(vmf, &xfs_buffered_write_iomap_ops); xfs_iunlock(ip, lock_mode); sb_end_pagefault(inode->i_sb); diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 916531d9f83c..bfc5b0a4d633 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1234,6 +1234,14 @@ xfs_buffered_write_iomap_end( if (iomap->type != IOMAP_DELALLOC || !(iomap->flags & IOMAP_F_NEW)) return 0; + /* + * iomap_page_mkwrite() will never fail in a way that requires delalloc + * extents that it allocated to be revoked. Hence never try to release + * them here. + */ + if (flags & IOMAP_FAULT) + return 0; + /* Nothing to do if we've written the entire delalloc extent */ start_byte = iomap_last_written_block(inode, offset, written); end_byte = round_up(offset + length, i_blocksize(inode)); @@ -1260,15 +1268,6 @@ const struct iomap_ops xfs_buffered_write_iomap_ops = { .iomap_end = xfs_buffered_write_iomap_end, }; -/* - * iomap_page_mkwrite() will never fail in a way that requires delalloc extents - * that it allocated to be revoked. Hence we do not need an .iomap_end method - * for this operation. - */ -const struct iomap_ops xfs_page_mkwrite_iomap_ops = { - .iomap_begin = xfs_buffered_write_iomap_begin, -}; - static int xfs_read_iomap_begin( struct inode *inode, diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h index 4da13440bae9..8347268af727 100644 --- a/fs/xfs/xfs_iomap.h +++ b/fs/xfs/xfs_iomap.h @@ -48,7 +48,6 @@ xfs_aligned_fsb_count( } extern const struct iomap_ops xfs_buffered_write_iomap_ops; -extern const struct iomap_ops xfs_page_mkwrite_iomap_ops; extern const struct iomap_ops xfs_direct_write_iomap_ops; extern const struct iomap_ops xfs_read_iomap_ops; extern const struct iomap_ops xfs_seek_iomap_ops;