From patchwork Wed Oct 25 14:10:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13436237 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 6A2B1C0032E for ; Wed, 25 Oct 2023 14:10:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F158E6B0309; Wed, 25 Oct 2023 10:10:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC5A76B030B; Wed, 25 Oct 2023 10:10:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8E396B030D; Wed, 25 Oct 2023 10:10:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C83F46B0309 for ; Wed, 25 Oct 2023 10:10:51 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A724514069F for ; Wed, 25 Oct 2023 14:10:51 +0000 (UTC) X-FDA: 81384169902.10.52C23D1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id EEF45140013 for ; Wed, 25 Oct 2023 14:10:49 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=RouRtqdb; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+38ff0d3703fb120512f4+7367+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+38ff0d3703fb120512f4+7367+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=1698243050; 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=jujzRHkRyr+wEL+M5CNsHITMDxSDVwIofgMIOfpKOzo=; b=GMvbHAPCK6DltcDIfiXu/9096v2Am452XN2Fg9hz/InD1cZCb4jLjGQiI0BVteHYPfHyYn e8itraQjd76ul5mMHXmTlcSE4Tw9TUAjL5ar+OuIpbfG9rijBapEI1h192R5AfQd60Tkgu mdQgNLJXVv6ViSd2nNIHfliu33JLZ0g= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=RouRtqdb; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+38ff0d3703fb120512f4+7367+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+38ff0d3703fb120512f4+7367+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698243050; a=rsa-sha256; cv=none; b=rw3dXJtMYGiSf9J4vTmg2ShvpzqpUdB6nf6OdUw9ACFNP16glkk04wINcktMvM+oyhLCM6 3gygvujIqpK6T9ZxxfE896ub8QAPtE6uKifRZ7Dovgh8JlAwp56IEdFDBXFlc6iBeQNhP5 XY29CA8CtcLNZ8p/Sg7WyURPXqZfWzQ= 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=jujzRHkRyr+wEL+M5CNsHITMDxSDVwIofgMIOfpKOzo=; b=RouRtqdbgT1VUyFZLCwnq9twGz 5f3XS5x4NLWzTcuzopnzsaPpcu6W3ywN5LX3wU1N2A+oblEZd77vb2YdzipXhTthiYHHWn9dNruCp 8OXiQ+/zpGQoraat6lPZMj1fJnfM4WdFt2TKqP9UGwKRl+nku76aXjNf1oh1QXEzD5WYR8TOmuPQq XTRU/M5I9Lv0Dhw/958Duwa+GKVy3Z32pasiOK7PJ9z3BbzO1vKBwIhPXvSwXzb17DnuaiRORMXaG /Ak/oi+QQ0xWzQXRye2Az5Tqu27fU4Knqv0b2yDEsuzyEvf6lcCApVDhbUwa5Nt7SZbQ6KflbQU2a mbI+lmww==; 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 1qvear-00CTy1-0A; Wed, 25 Oct 2023 14:10:45 +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 4/4] xfs: respect the stable writes flag on the RT device Date: Wed, 25 Oct 2023 16:10:20 +0200 Message-Id: <20231025141020.192413-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231025141020.192413-1-hch@lst.de> References: <20231025141020.192413-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-Rspamd-Queue-Id: EEF45140013 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: awoyw1ouw6hc4xge98rjnnrffkgp19mp X-HE-Tag: 1698243049-995446 X-HE-Meta: U2FsdGVkX1+IuX44+MfvOCrA6SWzIy0bm9W3RQbVfc5JRQPVgZvV4R1k8jLEiqCuu6239uHrbdqMeDtyhETcxFmlSrmW+othuReaIAeGL1h81S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fQyet4lQk2M297jfMtf+c03Al8U1GuJip4rS9dI3Q22wF2QAdWHzzT/UWRQYtBZvIh0Rzvy6QDCf9Bxqnr4hh/W3KMbEMPihIRmzBI9sjgsF5HLDlE8q0+n0wCDQjfdKbIDvQAu/YIVPXmuYOQIMcD8WSM17/wk5ktAT4hdaebILKkhnumNmXiSNCrvP2OSfgIuDPQjcK 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 | 8 ++++++++ fs/xfs/xfs_iops.c | 7 +++++++ 3 files changed, 23 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 be69e7be713e5c..535f6d38cdb540 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1149,6 +1149,14 @@ 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 (rtflag != XFS_IS_REALTIME_INODE(ip) && S_ISREG(VFS_I(ip)->i_mode)) + 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.