From patchwork Tue Oct 24 06:44:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13433973 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 1624BC25B48 for ; Tue, 24 Oct 2023 06:44:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FFAF6B0181; Tue, 24 Oct 2023 02:44:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 261286B0183; Tue, 24 Oct 2023 02:44:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 128C06B0184; Tue, 24 Oct 2023 02:44:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 048126B0181 for ; Tue, 24 Oct 2023 02:44:35 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D16A0B5B45 for ; Tue, 24 Oct 2023 06:44:34 +0000 (UTC) X-FDA: 81379416468.13.6B06403 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP id 348D040018 for ; Tue, 24 Oct 2023 06:44:32 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=WXv3G4pj; dmarc=none; spf=none (imf27.hostedemail.com: domain of BATV+e19589c3639214e6c3cb+7366+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+e19589c3639214e6c3cb+7366+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698129873; 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=NA1ivap7QBb2ywFQh6pxpUiR9qrIreFL3p9thcCX5KE=; b=i8IDgbrCAUhJjqtBYVTwx23ZdycAr+CkemnolIiY1YgIstwk1NFqP3LOjuJ7nUucEEwV0N Qn0iYKKMPdaqloWHsa7uVHUPGvy2wodPCFhet09cMYaAtvwyvB7wEqSw/uz/Y0gcwM8dhQ jPCmLVjgn1o2AzBjE6tv1DgEt3RAeoY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=WXv3G4pj; dmarc=none; spf=none (imf27.hostedemail.com: domain of BATV+e19589c3639214e6c3cb+7366+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+e19589c3639214e6c3cb+7366+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698129873; a=rsa-sha256; cv=none; b=WmvlMczrD4EEl6f/01TcgkO8c9eXrRgyZQuyse14mw7yJC1bdp5NsUGc7oa0+X6vVmBssa BjXLrMkk8SVdS4nXhWXEXOi8Ux/OJborAmFNu3FBdqOHl8FvIT2wa9MlRnGSwanA1rCMjy bHXTsO/B/kawKm9nGlpcF79CHdlz/Gc= 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=NA1ivap7QBb2ywFQh6pxpUiR9qrIreFL3p9thcCX5KE=; b=WXv3G4pj+cmxjDwS9VwZasOwnp 1hLehJhbtZnmElQUJCmR+P3FjyKhS/nTjVKLpsB6P0jWSCnAB4BON2xeSMI/+B5cnR2VEHbkxlgX0 DZ0i5zFldcuKMtoGSbOPBxZTNmHdw2VyhvTFFAa2V+J4oUmvxqP0qUU0/q371gD2YUV73Bls8pvch n70IWoUvyxzJRBlwzSLrJd9/b20nb3ruLdqVgImeTgKfnVeasyKxgylLKGqVEXulotOKls22J6QRQ 2JA4QylhiyKiC/bPSAowPFWjBsVjaRvEJiebLXd75fbwCsaAtCFqEHaGe9rrvR9KQyjA+tzjNZM48 RTlesNng==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qvB9Q-0090Se-0H; Tue, 24 Oct 2023 06:44:28 +0000 From: Christoph Hellwig To: Jens Axboe , Matthew Wilcox Cc: Ilya Dryomov , Andrew Morton , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/3] xfs: respect the stable writes flag on the RT device Date: Tue, 24 Oct 2023 08:44:16 +0200 Message-Id: <20231024064416.897956-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231024064416.897956-1-hch@lst.de> References: <20231024064416.897956-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Stat-Signature: 6a4e7e6edfruk9ec1thkwjg7oy8hg35g X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 348D040018 X-HE-Tag: 1698129872-582445 X-HE-Meta: U2FsdGVkX1863UmUjAXOwIoicBClxiiucRhRvGvZZcW2fsQdlHJFDqP0zRn9CrKWge2fgSI/zOLgvsdVDfDabsUHn6UQIxzIpKKLr9bmv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nr6VGNxphQ6lYUULdpj393FQz5XWx0II37S1rExb2x8MQNN0INE/LjL3kTDtAv1vQXU8nTKqSeaOGzEWclid4EjGv7bPAm3EDNUkRNSTwRNOrrixWeszfz7NIwkNZZMfBwxTsW+sd11Gs7vj4AQL+N6syFEu45eyBE3jS1whDI7tSZbtM5gC2D0XflrU/yxsitqFCFE09VksrOtg9+w1PF507kGaS 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: Update the per-folio stable writes flag dependening on which device an inode resides on. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- 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); + 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); + /* * 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.