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 4BAADC07545 for ; Tue, 24 Oct 2023 15:09:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BCE826B02B6; Tue, 24 Oct 2023 11:09:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B7DEC6B02B7; Tue, 24 Oct 2023 11:09:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A45756B02B8; Tue, 24 Oct 2023 11:09:12 -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 91C986B02B6 for ; Tue, 24 Oct 2023 11:09:12 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3C4AD14028E for ; Tue, 24 Oct 2023 15:09:12 +0000 (UTC) X-FDA: 81380688144.16.5EE0CC0 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf22.hostedemail.com (Postfix) with ESMTP id B58B2C001F for ; Tue, 24 Oct 2023 15:09:08 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sWKtZ5Ak; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of djwong@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=djwong@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698160149; 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=ZWP3xwT5XDQ+LiGp49iY5KN3it2oCFnEfbPhqynOblc=; b=AN0RFX+mL5tK8k2xKCBjOxm4tvGxqo/BQVCjPRYSOZrha5SyjgGo0vhP5rijdKszqCCgJ7 7VxMrZMp2z5aOiamlhP8ZQJk4Krl1GrvlW/NbS2hSI2DOu9VT6wgvl9avHeWS+v66GqxjZ aqim7byftrDsvLwS5CA+N4H5DFbyyf4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sWKtZ5Ak; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of djwong@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=djwong@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698160149; a=rsa-sha256; cv=none; b=jdP2hwa3Qc9kfEKVUaY7iv2b8uLNwdIOyjCw5NaL9eMETCXFBn43AP89f50yTW2rrrPEHU X9WsUHuR1CXm7kTEZjrXSmG1NbAk4g8YJ4NNMQpFQlbtRw5hVaAljN4nLorAvnOwIwXFNj 6BX5K+J4bAlVBwqrfUMdY/tHZcx1FgI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9B28ACE2CAE; Tue, 24 Oct 2023 15:09:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1E2EC433C8; Tue, 24 Oct 2023 15:09:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698160144; bh=+sTxJDVws6hFbRRZY3T4c/3V2tpunBXLS+DBgSiQAfM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sWKtZ5AkdfEFeb+k6ZpIxTkcLf+AQx1r2Mg3lGcLZLu7ZazlSpberuRpGGgiza/rs vFHx72m+VaquZN/srqBqLAy8XQE6EDzEEL++XrxO7tiwGBBLYcbGnokd+EEz7letQA IFCWLgNZdouVqq4q36Mi8u9dMVfj8pRgGULg/7cgZj7RO1nDb5XEUZDQXPqJcDtwK4 BnCnYnsAeF6Qt2ToYWCxKD2hF2hGa2MXLUkujWXM/C/ncAZnOOkB3kpaJvo/S5/APE vD5eemoPWutD3m97mu90bSuAMYWKPtLKSAsWVEEpvopCkdqlWT7fz7OmQDNt6m6eDB hnpqkcpuHRZlg== Date: Tue, 24 Oct 2023 08:09:04 -0700 From: "Darrick J. Wong" To: Christoph Hellwig Cc: Jens Axboe , Matthew Wilcox , Ilya Dryomov , Andrew Morton , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 3/3] xfs: respect the stable writes flag on the RT device Message-ID: <20231024150904.GA3195650@frogsfrogsfrogs> References: <20231024064416.897956-1-hch@lst.de> <20231024064416.897956-4-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231024064416.897956-4-hch@lst.de> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B58B2C001F X-Stat-Signature: 35ca45rcapik473shtbiekfkrzp7rjzw X-HE-Tag: 1698160148-828886 X-HE-Meta: U2FsdGVkX1+crIsTVbFeunPd1I7SfHGW/CL31RBvgCwzPEDifPr0oaxME1sE4IfowwmmKSfibMeGOm7e50+B0qwYedTvQoADJbaqXMUlO1JX5E3XWQbloezWVAelP5fT4zVxZLkLOaDORlXSKAzJcjqDe+6g6M6Thq9ZIBLXHiDHwvvfAumROiJdnYV2ant+L/Ui/I4hHGD5qPcjzk6Ar8q0MYXvA/UlZHN2PdB4CZ6+IjbWEM3PmHlHoxSCVaY1qb9zdbjbJNPTaVWypx4sUonGnLB6HX424O2FzvBwbS4Xp2GKNgwtffNDS/8XIY82oWavkQ2TsTk1BPdutcEzcF+Bf02tPhD35kkByJWV6SIhD13yhiP43ZeyYfJ+UKS3BXEWmcsKK66Q7Mixe0Fw3VeEAe+ru8imIZYN4J4NuY84jLDCWRCJ5Dl6ucEXQF8qFTEFx1ElTsZ/9iFpdYuU2nQvPC8BpAFVXnbvi/NpsClJ13SF6StiJtytbjTwV53xKqXiby27QETahNtOH4sHL/oyVKuhmcjqO1/LwjuWvUddc6MUEbOYMvzRDkAa22Q5lhp4SEHrXoUFLd/pp5iX7j8kMfoWVqqxm1tWGDJwyY9eC9UhPMggyj/nJ2dPvCfQ4wUdlrNudMmO+22djtWAFLmskaY4Hle7GBHjCLIny9l/Y5CsFVDfq3ZgmvnrCY67ULz4W3+fdmT0hVjCsGtrBiDrUv6i+342+u0F/1MK1E/SCmGuR51c1Aco65kbfB3cB0kQPtlrMxGafEWFHhJXh4uD0yp+gj6XNHyxDrsJPeiv6kP1iQqWBpXDZRXpmyKwOKaoMz9YcFl1Gyll6bIFE0lT/Hwvwm9k3px0VLSRchaMe5yNsR9TvN1GnDvrudHW/mpPOVnxhcU98BHuW48cDZmbYFKFcB1cC+0Q207NUwm8U0B5jPSLyzpJUqquGfkqL6Sapbd/jjEvx/3d8kQ 1+UMSZLv QLr/y6jftavufNBF0p/MOSy6sR6swxrK6Lpnfbd2UeVMZMeX1EpIoVNqVS5GwNpzNvIT3uQjl/dBZ4GVbHPuUk4JXk3OfqjpZ4Y+0W7yYv5v1RI633pQQpgPO89a3c7gT9LqnUwm4SyR1D92FDwpU18J7S4vaMirsBQsRZeb/c/mwKnIMbe2w9+iYtpOCS+pij4toJTeHLc1mRezjOgzgrHuan7pMRnIsvNljNT77avxO7LDpzxgofFZSPg== 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 Tue, Oct 24, 2023 at 08:44:16AM +0200, Christoph Hellwig wrote: > Update the per-folio stable writes flag dependening on which device an > inode resides on. > > Signed-off-by: Christoph Hellwig > --- > fs/xfs/xfs_inode.h | 8 ++++++++ > fs/xfs/xfs_ioctl.c | 9 +++++++++ > fs/xfs/xfs_iops.c | 7 +++++++ > 3 files changed, 24 insertions(+) > > diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h > index 0c5bdb91152e1c..682959c8f78cb0 100644 > --- a/fs/xfs/xfs_inode.h > +++ b/fs/xfs/xfs_inode.h > @@ -561,6 +561,14 @@ extern void xfs_setup_inode(struct xfs_inode *ip); > extern void xfs_setup_iops(struct xfs_inode *ip); > extern void xfs_diflags_to_iflags(struct xfs_inode *ip, bool init); > > +static inline void xfs_update_stable_writes(struct xfs_inode *ip) > +{ > + if (bdev_stable_writes(xfs_inode_buftarg(ip)->bt_bdev)) > + mapping_set_stable_writes(VFS_I(ip)->i_mapping); > + else > + mapping_clear_stable_writes(VFS_I(ip)->i_mapping); > +} > + > /* > * When setting up a newly allocated inode, we need to call > * xfs_finish_inode_setup() once the inode is fully instantiated at > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c > index 55bb01173cde8c..67bf613b3c86bc 100644 > --- a/fs/xfs/xfs_ioctl.c > +++ b/fs/xfs/xfs_ioctl.c > @@ -1147,6 +1147,15 @@ xfs_ioctl_setattr_xflags( > ip->i_diflags2 = i_flags2; > > xfs_diflags_to_iflags(ip, false); > + > + /* > + * Make the stable writes flag match that of the device the inode > + * resides on when flipping the RT flag. > + */ > + if (S_ISREG(VFS_I(ip)->i_mode) && > + XFS_IS_REALTIME_INODE(ip) != (fa->fsx_xflags & FS_XFLAG_REALTIME)) > + xfs_update_stable_writes(ip); Hmm. Won't the masking operation here result in the if test comparing 0 or FS_XFLAG_REALTIME to 0 or 1? Oh. FS_XFLAG_REALTIME == 1, so that's not an issue in this one case. That's a bit subtle though, I'd have preferred XFS_IS_REALTIME_INODE(ip) != !!(fa->fsx_xflags & FS_XFLAG_REALTIME)) to make it more obvious that the if test isn't comparing apples to oranges. > + > xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); > xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); > XFS_STATS_INC(mp, xs_ig_attrchg); > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c > index 2b3b05c28e9e48..b8ec045708c318 100644 > --- a/fs/xfs/xfs_iops.c > +++ b/fs/xfs/xfs_iops.c > @@ -1298,6 +1298,13 @@ xfs_setup_inode( > gfp_mask = mapping_gfp_mask(inode->i_mapping); > mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS))); > > + /* > + * For real-time inodes update the stable write flags to that of the RT > + * device instead of the data device. > + */ > + if (S_ISREG(inode->i_mode) && XFS_IS_REALTIME_INODE(ip)) > + xfs_update_stable_writes(ip); I wonder if xfs_update_stable_writes should become an empty function for the CONFIG_XFS_RT=n case, to avoid the atomic flags update? (The extra code is probably not worth the microoptimization.) With the !! nit addressed, Reviewed-by: Darrick J. Wong --D > + > /* > * If there is no attribute fork no ACL can exist on this inode, > * and it can't have any file capabilities attached to it either. > -- > 2.39.2 >