From patchwork Thu Nov 21 11:22:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13881882 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 AF6EDD6ED09 for ; Thu, 21 Nov 2024 11:23:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 241AD6B0099; Thu, 21 Nov 2024 06:22:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E35876B00A3; Thu, 21 Nov 2024 06:22:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A5A36B0096; Thu, 21 Nov 2024 06:22:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B4C1F6B0096 for ; Thu, 21 Nov 2024 06:22:31 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 75D4AAEC87 for ; Thu, 21 Nov 2024 11:22:31 +0000 (UTC) X-FDA: 82809862590.12.83E2154 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf21.hostedemail.com (Postfix) with ESMTP id 5AF091C0010 for ; Thu, 21 Nov 2024 11:20:49 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=QlV1S2h+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=YUhKzjAo; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=QlV1S2h+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=YUhKzjAo; spf=pass (imf21.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732187902; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rNXKIooKmDN7lsLja3Qn4DQNYnh1LdTktk6J4bSg71E=; b=sFgRz7884HInPUh3JgdVvbsK6YyBLrdczO+GwHP3hvgMGZQpyxtd6yTuyPewsHrB2YPjD0 hLGDcXoL1JMJi8zNdh83LCCA3PxSqbjBj1RKiYTy9lVwpfCncyCSK+sdo13AMi1p8N7I0S H4m/bfBtJS8Koun/CEwI2uJWahcnZm8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=QlV1S2h+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=YUhKzjAo; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=QlV1S2h+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=YUhKzjAo; spf=pass (imf21.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732187902; a=rsa-sha256; cv=none; b=gJTc13lrgGJqUpSnP3jJUuB9JKJ93h00H28ceTfVvN3+TfQPjwsqbc112U3990hWUyLRix m72eF7qoKWVFJWyFa686WI+WPAVPx2gG+FOd3DFfoK85ujZ7B5+qo3cCJseLdQEUdb25cW 6ribsZzoY4HFfsI6pyNHAUg6xl3iDFg= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C11D01F802; Thu, 21 Nov 2024 11:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732188144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNXKIooKmDN7lsLja3Qn4DQNYnh1LdTktk6J4bSg71E=; b=QlV1S2h+xd23+4a8YG06xuyShqMaNKuWlJp9V34L+ZWqZLH1Cp/l1ilq2NQn5iN3aEeF5V VSrVcK6PbP9KCZ6uR034BR1+X2XgeUmbGBIAWd8LDoqiZZnktQ48xkX70l6PQo4eApUQOU XGRYwMvimGEcnnHXzMr7TD7+czPuAbI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732188144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNXKIooKmDN7lsLja3Qn4DQNYnh1LdTktk6J4bSg71E=; b=YUhKzjAoRO1JpjX5ENW4+IIwXUKJx7w6f/00v6F6A1wimubLShWTK3pOAENAVg59hWiWw/ jaUu26D5Tk+UpWBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732188144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNXKIooKmDN7lsLja3Qn4DQNYnh1LdTktk6J4bSg71E=; b=QlV1S2h+xd23+4a8YG06xuyShqMaNKuWlJp9V34L+ZWqZLH1Cp/l1ilq2NQn5iN3aEeF5V VSrVcK6PbP9KCZ6uR034BR1+X2XgeUmbGBIAWd8LDoqiZZnktQ48xkX70l6PQo4eApUQOU XGRYwMvimGEcnnHXzMr7TD7+czPuAbI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732188144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNXKIooKmDN7lsLja3Qn4DQNYnh1LdTktk6J4bSg71E=; b=YUhKzjAoRO1JpjX5ENW4+IIwXUKJx7w6f/00v6F6A1wimubLShWTK3pOAENAVg59hWiWw/ jaUu26D5Tk+UpWBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B5B9613A7D; Thu, 21 Nov 2024 11:22:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ofy9LPAXP2dHfwAAD6G6ig (envelope-from ); Thu, 21 Nov 2024 11:22:24 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 48A28A08FA; Thu, 21 Nov 2024 12:22:24 +0100 (CET) From: Jan Kara To: Cc: Amir Goldstein , Josef Bacik , brauner@kernel.org, Linus Torvalds , Al Viro , linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, Jan Kara Subject: [PATCH 16/19] xfs: add pre-content fsnotify hook for DAX faults Date: Thu, 21 Nov 2024 12:22:15 +0100 Message-Id: <20241121112218.8249-17-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241121112218.8249-1-jack@suse.cz> References: <20241121112218.8249-1-jack@suse.cz> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5AF091C0010 X-Stat-Signature: 9c6dohkxt5b8c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qpdwhEABMxMHlAWb9kBOgDukCXwTtqk/e/428a/7tIIg5It7pjFbj01RtbJfHQ8v3NirGAQL5LFllbMNVv7WEbM87F147t0BZz+N561W7yOzLyoI3YRRplXan3U/a9BDceVtwsHm6+krbnl0okhpLC0Sb0DP5V4Oi2+yZijRTxr8POMbjDq5/MxhzfbpaqhHv7dPWXxT4P8NbNEyYI5t5WPrRpip+8i5iYjpUDypl1Tb4FdmPIr+oPuBSHNJiq4vG6vSsxG1VFBSy7jnFEM3EvilPIL1rqJWENVYC3KPJyZ+YCbsIdPmfKTdp+Wx1w9GdoOOIk00weZ66q41nasXPRvGb5vjGa+fHlCpI 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: From: Josef Bacik xfs has it's own handling for DAX faults, so we need to add the pre-content fsnotify hook for this case. Other faults go through filemap_fault so they're handled properly there. Signed-off-by: Josef Bacik Signed-off-by: Jan Kara Link: https://patch.msgid.link/9eccdf59a65b72f0a1a5e2f2b9bff8eda2d4f2d9.1731684329.git.josef@toxicpanda.com --- fs/xfs/xfs_file.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 412b1d71b52b..8b1bfb149b2c 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1395,6 +1395,9 @@ xfs_dax_read_fault( struct xfs_inode *ip = XFS_I(file_inode(vmf->vma->vm_file)); vm_fault_t ret; + ret = filemap_fsnotify_fault(vmf); + if (unlikely(ret)) + return ret; xfs_ilock(ip, XFS_MMAPLOCK_SHARED); ret = xfs_dax_fault_locked(vmf, order, false); xfs_iunlock(ip, XFS_MMAPLOCK_SHARED); @@ -1412,6 +1415,17 @@ xfs_write_fault( unsigned int lock_mode = XFS_MMAPLOCK_SHARED; vm_fault_t ret; + /* + * Usually we get here from ->page_mkwrite callback but in case of DAX + * we will get here also for ordinary write fault. Handle HSM + * notifications for that case. + */ + if (IS_DAX(inode)) { + ret = filemap_fsnotify_fault(vmf); + if (unlikely(ret)) + return ret; + } + sb_start_pagefault(inode->i_sb); file_update_time(vmf->vma->vm_file);