From patchwork Tue Oct 24 06:44:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13433972 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 DCED4C25B6D for ; Tue, 24 Oct 2023 06:44:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E7F86B0180; Tue, 24 Oct 2023 02:44:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 547AE6B0181; Tue, 24 Oct 2023 02:44:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25A016B0184; Tue, 24 Oct 2023 02:44:31 -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 087D26B0181 for ; Tue, 24 Oct 2023 02:44:31 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D03AF8075C for ; Tue, 24 Oct 2023 06:44:30 +0000 (UTC) X-FDA: 81379416300.09.52AB82B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id D2316A0005 for ; Tue, 24 Oct 2023 06:44:27 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=5ABpqDa1; spf=none (imf25.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; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698129868; 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=SRYZHQ04hacwuEwpWKzRe5AbE87Phgtpy62POhugK7g=; b=nhoQE8U4GyHV7pUDBS5r7rPY8vzi8Z38cDwBCSY5tfTPM8X4HDXTDbKYcecyaQSHHOuLzg TzmWFvnrKDKfOC+dPQPdLAQR4lj4cIn2VCrufNWFSu3wGlVXpYl9Kb0aLBJQIjKGomSJaZ 7x8yHR9jgjGxKWx3Tpei1DrBbMAr0n8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698129868; a=rsa-sha256; cv=none; b=zar6YGwW07lL7nS43i0fDHxUsGUbLQccxfTA4Ede29oZySPSLOauMI2rRHtEJQ5lIAfFxQ OaSC6/ceM8VEIkDuasDkp2mEtllU9hWU5wQgqOtD1RlJNgi19o/uYF1uzPss6GpnKarrKv 4CbH6lrt+hpejhrxpmxf/n2r2MPywMc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=5ABpqDa1; spf=none (imf25.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; dmarc=none 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=SRYZHQ04hacwuEwpWKzRe5AbE87Phgtpy62POhugK7g=; b=5ABpqDa1lh0phh7GpUJ2sCEBTX euFvql4TUCV/4em6WAf5iTj1UtDv9YFIM77swuiFHaaJtPUr6D31ivY+9UgDgRmHxWEyXVkHgnPJw MHbflhwJZYn4ZQZGt1ZJgsg94+XN27VjVlwZnEBem3BKEPUjPtKfmPs4YYGz8XFw6nL7qrBQvCVYg tfDSE8HmNOIwHYS+yN694/z9224F69MJ/AcbYVUUx1E9gcspA4wQK7jxQ9ojSlFF/AqBK8kg9pev8 XIsk4eYKOlpr7BGIyPvNwFWqAwZWh9L7/h5o6inPZQJsuzHt/XwR0n8PoPG/yTzSKjREQhC9Z+xjl HWg+mOVw==; 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 1qvB9K-0090RZ-2f; Tue, 24 Oct 2023 06:44:23 +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 1/3] filemap: add a per-mapping stable writes flag Date: Tue, 24 Oct 2023 08:44:14 +0200 Message-Id: <20231024064416.897956-2-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-Rspamd-Queue-Id: D2316A0005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 58c77q53nceqjgtrgztyzrynb7ehkxpi X-HE-Tag: 1698129867-973205 X-HE-Meta: U2FsdGVkX19eVdgmVelxXA1umiqeMLl4+kIo2SncxMzTR4CVigYtexXGDq5G2sl6KyWqgpwntD1vNTPEobS0Dcnz1r08QcOr06U1qvYV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bDk15ZOD7me7uflctDv0EkInXDiP+ujHDsv7wLpTqwPjlQvld3qTr6NcccSPTOKymyjnIdfn781xfpIwYqhrppsfi2Z6jERUt7ulZfRYMawMfYEicd/2F4ahzNvwScz7Ug9Rth2m6YyDP6zW1cKhNZ1RsA6XjB/OOUurdbka4aDQl7E37lts8rlgv8C25ApSYG+xLDEYIeKx3SHXebZp2+6Rz99UtLJqVWKwRxTG+Fqk8 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: folio_wait_stable waits for writeback to finish before modifying the contents of a folio again, e.g. to support check summing of the data in the block integrity code. Currently this behavior is controlled by the SB_I_STABLE_WRITES flag on the super_block, which means it is uniform for the entire file system. This is wrong for the block device pseudofs which is shared by all block devices, or file systems that can use multiple devices like XFS witht the RT subvolume or btrfs (although btrfs currently reimplements folio_wait_stable anyway). Add a per-address_space AS_STABLE_WRITES flag to control the behavior in a more fine grained way. The existing SB_I_STABLE_WRITES is kept to initialize AS_STABLE_WRITES to the existing default which covers most cases. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) Tested-by: Ilya Dryomov Reviewed-by: Darrick J. Wong --- fs/inode.c | 2 ++ include/linux/pagemap.h | 17 +++++++++++++++++ mm/page-writeback.c | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 84bc3c76e5ccb5..ae1a6410b53d7e 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -215,6 +215,8 @@ int inode_init_always(struct super_block *sb, struct inode *inode) lockdep_set_class_and_name(&mapping->invalidate_lock, &sb->s_type->invalidate_lock_key, "mapping.invalidate_lock"); + if (sb->s_iflags & SB_I_STABLE_WRITES) + mapping_set_stable_writes(mapping); inode->i_private = NULL; inode->i_mapping = mapping; INIT_HLIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */ diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 351c3b7f93a14e..8c9608b217b000 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -204,6 +204,8 @@ enum mapping_flags { AS_NO_WRITEBACK_TAGS = 5, AS_LARGE_FOLIO_SUPPORT = 6, AS_RELEASE_ALWAYS, /* Call ->release_folio(), even if no private data */ + AS_STABLE_WRITES, /* must wait for writeback before modifying + folio contents */ }; /** @@ -289,6 +291,21 @@ static inline void mapping_clear_release_always(struct address_space *mapping) clear_bit(AS_RELEASE_ALWAYS, &mapping->flags); } +static inline bool mapping_stable_writes(const struct address_space *mapping) +{ + return test_bit(AS_STABLE_WRITES, &mapping->flags); +} + +static inline void mapping_set_stable_writes(struct address_space *mapping) +{ + set_bit(AS_STABLE_WRITES, &mapping->flags); +} + +static inline void mapping_clear_stable_writes(struct address_space *mapping) +{ + clear_bit(AS_STABLE_WRITES, &mapping->flags); +} + static inline gfp_t mapping_gfp_mask(struct address_space * mapping) { return mapping->gfp_mask; diff --git a/mm/page-writeback.c b/mm/page-writeback.c index b8d3d7040a506a..4656534b8f5cc6 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -3110,7 +3110,7 @@ EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); */ void folio_wait_stable(struct folio *folio) { - if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES) + if (mapping_stable_writes(folio_mapping(folio))) folio_wait_writeback(folio); } EXPORT_SYMBOL_GPL(folio_wait_stable); From patchwork Tue Oct 24 06:44:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13433971 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 022F4C25B71 for ; Tue, 24 Oct 2023 06:44:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B9C36B017F; Tue, 24 Oct 2023 02:44:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76A756B0180; Tue, 24 Oct 2023 02:44:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 658966B0181; Tue, 24 Oct 2023 02:44:30 -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 56B0B6B017F for ; Tue, 24 Oct 2023 02:44:30 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 28FD4160E05 for ; Tue, 24 Oct 2023 06:44:30 +0000 (UTC) X-FDA: 81379416300.11.C5A3991 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id 83BD040006 for ; Tue, 24 Oct 2023 06:44:28 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LbsFIHIa; dmarc=none; spf=none (imf17.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=1698129868; 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=Xv0Y7MMN6a+oO5YWZ9vpRkvqCfuPiGUZ4v0gSgQ4Fio=; b=AUUue2Oh6LGy2MrcY0JSNP34NVxhRXwqtRP1XnAEbVcVV9VCRduHlM46lURmVLCNVaWR21 7u81R5ryAgLVGXYhax3tQ5rdMC/GevwftAFgaPIrFkNJG2nUld2E7G+VdDvHwP+LsblYRb 1SC++hNrpf9RBZ1myqoR2OSQZirn4D8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LbsFIHIa; dmarc=none; spf=none (imf17.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=1698129868; a=rsa-sha256; cv=none; b=56ZgniK/oLIy8Tir61ErfkF5vylmWa5XmiyDpIJnkMd1jZMI5oYDZGR699UNpL7TN4m+HZ VV9gNiz1nNQ+jjGBglmSBuams5jRgxN38ZjsZDU7MTEhrZTrTJTIQCeaLeGNCz6CeUl3eS QjzStEk6R0dWIS3FFOd/cBoYW3+Eoqk= 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=Xv0Y7MMN6a+oO5YWZ9vpRkvqCfuPiGUZ4v0gSgQ4Fio=; b=LbsFIHIaMCxJK5tHyXHay27Tpj 0aMIGXw6DujKIybLgCJyppua7cZTABksNxgjpULkWeufdVhy2DR4tImheev61lt+bUJVdzkbAyRJf TiLWyG+7G5LSn3Z3tq3hbiI0bEU3JiOMlA2+aPMAOnQ1TkJ6rKJegATMhaWnO0hkLOKuikj+ETiYi 4GI+mG3g+TmTne4T+QQA5YEP9rgNldFXZWy3SCjN0kFegAOqXb5l9CSJYDShQLtNCAq1enB5zZaXR CXRHTj6muUCEt5sPaPDSl+ZW2FFxKkWLwcZKhPXGp/FCX/Dns/BDyxnH6AxR22KqReTfq0saPB8k1 8MjFBsXw==; 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 1qvB9N-0090S8-1j; Tue, 24 Oct 2023 06:44:25 +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 2/3] block: update the stable_writes flag in bdev_add Date: Tue, 24 Oct 2023 08:44:15 +0200 Message-Id: <20231024064416.897956-3-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-Rspamd-Queue-Id: 83BD040006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: zx8cxojdnqck4rdcjbmfwc4nfxfn3yaz X-HE-Tag: 1698129868-887395 X-HE-Meta: U2FsdGVkX1+XQavJtNqNuqCnREYgifpTezXTg4xw1MRTcN+gh8Ai4+4aSu5PJMDmkXwQIZ/wB/bCA0Rolsaum5eWaQTmSala9z+00QbCbaPwri8+L2YZbHUIqEY8sSdBZybDKjCmolT6CSIdrrKaJSzpUw/hC24N/XzBGSRZ7n3fF2rFM5LJxUhmWGChzY6TM6NsmpodfV9lpKspTS40XlY0vpWZ0P6NBAQ8Whp17HSyyUeCDLJ5b2d5WFoNTWRRpnLT735afdYlGrkjuOHcyASGPgLsUGxg1QXd7ZLo5w9shlxMlhgf/qMNNxmFMTd3vjNMO0HNQlUhmo6ud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/tuSx4rbGEZ7iKP1j2D7PwM1enAKR1RcNetahiiT1IWANeUCUpyZEFy4BuR/OyrjdzFs4M46Uy+rrM= 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: Propagate the per-queue stable_write flags into each bdev inode in bdev_add. This makes sure devices that require stable writes have it set for I/O on the block device node as well. Note that this doesn't cover the case of a flag changing on a live device yet. We should handle that as well, but I plan to cover it as part of a more general rework of how changing runtime paramters on block devices works. Fixes: 1cb039f3dc16 ("bdi: replace BDI_CAP_STABLE_WRITES with a queue and a sb flag") Reported-by: Ilya Dryomov Signed-off-by: Christoph Hellwig Tested-by: Ilya Dryomov Reviewed-by: Darrick J. Wong --- block/bdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/bdev.c b/block/bdev.c index f3b13aa1b7d428..04dba25b0019eb 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -425,6 +425,8 @@ void bdev_set_nr_sectors(struct block_device *bdev, sector_t sectors) void bdev_add(struct block_device *bdev, dev_t dev) { + if (bdev_stable_writes(bdev)) + mapping_set_stable_writes(bdev->bd_inode->i_mapping); bdev->bd_dev = dev; bdev->bd_inode->i_rdev = dev; bdev->bd_inode->i_ino = dev; 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/zOLgvsdVDfDabsUHn6UQIxzIpKKLr9bmvla+gB32SC8Mu4gG3TqIU6fOaZ5ELO7rFC3QYWnUrgp1X+hLwXaBn8V+05gykT7YfH18TJTU8BwnAA6GyOLz595/AyeReBJyDNxXuUEDR+u74crKtbBXv/4l2LCgUV7oi9HgOu3Ap7cTS+Sp1qM7El2JyV7AwrXgDa+NXNS80Xb4kXvJMXrSZN+BYoVoQJ+9z24hYJVhH1KfGyO81CxczdDOREuJiOhUpnKhRGdLaZxTQKR2RC9SlCVVOlQJuMUy++xEaJ07udmULPQjnkE22hHSLGGq6FZYqIgW+KZ+3i2LogjLAqM9wk415Yuan/jmfM6uuMmTilLLv7VuWjhnM0LPumYbvFGBro106KsX5vWJbsOGIT8IToSdk39mBkR34NnKT0VwrMKqmQ0fJpHT/aXCpwFq2H5oWRz1q/ER5VoIPtskv/vfO2UdBqUSrC4U+TI8f3jEabNMImifxoSQGovBQ6BCSK36NpyrLI0gPfiNmnKccdVTsnRG75vvHgWkr5DQo1SC3V1JdgZ/4FXiWj//ZNAcrqHuIekYLNo6QtKVKWgKhXrPOmWdX0uLlCxRPZuPvKUsKrDY8Tki83HV/tf6wDely3UZYq0oaRrG9SZuti1UwRc2/zateGQH/EA4ltCs3lFPNoS9lEOLfTMS3YSI0VlxpRky79+DX2xKmskM0Z621V0rF3hOOYMAIzcughUpxH4K5AqQyOZt/GpbG+SGSKoKvIIKX1iGoX9J7lEzdpgMXcstWo/kGiHdPglTeLz3B+vCHLOuyg11SHdj40ENQwCLU6IcpFmdagbK4q0h4FBfVJbFg3PQrJQeGCpAsPKp+b0/CSEgu44K0yyj2dw0uUFzCDWOhNu4rQWrW7w 3XkMtq9/ 2tthpiB64uJyMGzrAsvEys+I8/Eiw0rCpSNP8vzgluGw1hiNF9T9L8G/s0q2FGAshWZL1GKvNRT/GvAJmIKAmGEjUbx2v7LEK5VfDkROWKrZSEVhuMlD4e94YlNySBqbeCJUv2W9xClvTZrF69yXehbj8RwDivRRMOXvxCtnY6Syhi8sIAimpx+PNdt8GuuOxq6pJflKnr6VGNxphQ6lYUULdpj393FQz5XWx0II37S1rExb2x8MQNN0INE/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.