From patchwork Wed Oct 25 14:10:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13436234 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 7A3F3C0032E for ; Wed, 25 Oct 2023 14:10:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDE766B0302; Wed, 25 Oct 2023 10:10:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D8C9E6B0305; Wed, 25 Oct 2023 10:10:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7CA66B0307; Wed, 25 Oct 2023 10:10:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id ACACD6B0305 for ; Wed, 25 Oct 2023 10:10:41 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 56EF3C04F3 for ; Wed, 25 Oct 2023 14:10:41 +0000 (UTC) X-FDA: 81384169482.14.93DD165 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP id 173AE40023 for ; Wed, 25 Oct 2023 14:10:37 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=kjmYQYUX; dmarc=none; spf=none (imf11.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=1698243038; 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=xXpAs87vXAa9NcBEUc0wVOYAyOZDx4ei3lj0IRgnDRM=; b=bwQYTV2OW16yrrcwNPMV0tPVdnu54u9v5hTWvVJazY0X+gc6rSbUKSfoS4227+cwrLJ80E gNi5nlfbLCwOsZxCTT6FBtZRG4HnM8AVFD29p9+eONt01nZLyzFh9OjLPyRYr4av/8H5vL 1jhama5WpbG8aZG3IwrUkYz4hiW9e18= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=kjmYQYUX; dmarc=none; spf=none (imf11.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=1698243038; a=rsa-sha256; cv=none; b=YOSqsg/ZN+9mtghRmI+UFCiGI1tz8dakTIDrUKItnCuDl5Hp7HndA3K/uwt5FobzN1LM0E yYXNRvamHTYUJ41nU+3PCobrZqmUUzfskYWoIir0x023Dbg+5UxlEm1eL7LIIIceorsm/Y lsg3hkWu3xurV7hGsqld6YOvHy53kV4= 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=xXpAs87vXAa9NcBEUc0wVOYAyOZDx4ei3lj0IRgnDRM=; b=kjmYQYUXdwr23Na3Fs85kvexm3 tKafXooWcQ+nC1AYT81ALSCMPJQR1IxvgYrd9qXM+tmSkjdQEyKwqtzdO/Rh8OxjRl9dZnqw+iHzK lz6ZYNJPwUISI38kJGEDyJ+fd2T4cuCaDbcMWZFGZG/nhWNKhN5Lmmx9UHt/uuCBVBBQZ4VhgTwCy ZF8IqLEMn5OUDYhEXtH9j5e4F8nhz+zqvspVy/I/TQfhff41N4CxOdZ4yJtrhUsx6Q0SCa+1Z8p1t 1ICFXCt1HDWvaUE5GgJET3XdEzt3obj589ysFIjHVjgO9reBbkpYPXn9S2XmIc7excThupGm07EMF v1QPnScg==; 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 1qveag-00CTws-0x; Wed, 25 Oct 2023 14:10:34 +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, "Darrick J . Wong" Subject: [PATCH 1/4] filemap: add a per-mapping stable writes flag Date: Wed, 25 Oct 2023 16:10:17 +0200 Message-Id: <20231025141020.192413-2-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 173AE40023 X-Stat-Signature: 8aht97f8x41a119bewtck9kyqpd9qidj X-HE-Tag: 1698243037-270826 X-HE-Meta: U2FsdGVkX1/SjH2rmLaHA0T6cHwKCr8OXoG6prls/u/DcneZ/zsz/fbN6TTDs2NMmGRkB4EaAiwFTaxazMBb9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pLpMPUTYUv8k1UJUEFn5xGDuJFltQpxkxY1YnEZsy0t2hnnTpoYwwMGx55cdc4HIf44q3toJO8psY7v+8qZWe2m3QDhy4J1DXByqWYGwvg9U7Ap1jHAJalGu+kKKZEUTKeEYGkQQv/4K/7BKgk877+2ulNTiNDbv7i4JG2Gmu3KHIE5hyDk+lr6GEyMEvWJrBFsWyQfppFobQz70jIqHlIhfTDKB+enfyq7U4UhiGZ/rhJ83aqeM0ttYHaNBwrexI3TGrxph2z89s3yOe3f5ke1tzLZZ7QJFX+NjB7DgNkOczt1/hIwa8I1bL8PnW/B3UeJEpA2UTTEA10rsyQkx0SqfU6cAllT3Q3ufYccbrcHTOUquTycumXfgokl6yr24zg== 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) Reviewed-by: Darrick J. Wong Tested-by: Ilya Dryomov --- 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 Wed Oct 25 14:10:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13436235 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 C89CEC25B70 for ; Wed, 25 Oct 2023 14:10:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 293196B0305; Wed, 25 Oct 2023 10:10:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CF416B0307; Wed, 25 Oct 2023 10:10:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 047916B0309; Wed, 25 Oct 2023 10:10:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E99316B0305 for ; Wed, 25 Oct 2023 10:10:43 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B926A803AB for ; Wed, 25 Oct 2023 14:10:43 +0000 (UTC) X-FDA: 81384169566.19.62CFBBB Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf29.hostedemail.com (Postfix) with ESMTP id E8B3112001F for ; Wed, 25 Oct 2023 14:10:41 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=NkupXjjQ; dmarc=none; spf=none (imf29.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=1698243042; 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=eQkFS0CPXyYdJjvcxwO874+N6FHj6qkC07nIc5KQ7Fc=; b=0iUlt42aa5EGQrP6kQhRHPDXtppb3GrSEs4i269lt7lS2VWOxQI1y+xhbLRcok6KGZs6o1 yx6tPjs5Y3OWwFKWtC5/Fw/DGVItIKmNwEQ5uXpPkEd1NPE0q7DqnEXTJN0lU9UbSckY12 LsBwEQQn8QhuUMFc8blHo4FRw6Iwglg= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=NkupXjjQ; dmarc=none; spf=none (imf29.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=1698243042; a=rsa-sha256; cv=none; b=zknRO2yAnA88X4NTxXXAkGiDudeF/fSGLCRxjLLjfK4fXWHZ6N2eoPOErsS203yw1yvTBt JYZniJ+LQD54UwB2Ixo5KDGMdMCWrY/ur8KhYfe3M6kIUsRQCdXQLYywumFzE95r/Kr5LI bQXD1vahQOYeQyIq3g44TU7L8XHG+7A= 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=eQkFS0CPXyYdJjvcxwO874+N6FHj6qkC07nIc5KQ7Fc=; b=NkupXjjQ3bzL5mbyZ8icwT06pw ektizSCeFbKc39Orvb0x8fTzJ1oLB74rAYmYPqIbjS+fyCfCbMOy66EZxYkrekM6Cn6PghALK5LJ6 JtRDjTtq62PUPTC4s0HvcuM8KPOjeaSXWnNsbMThbqD9AKBUqzTUu7vJdIzrmxjJupxwgJAPXfiYk txfYJX8o7U5BHxwpLEcz4Se3hhRRYMrzEGaqL+b+tpoGOqW82ZVGsfn8vbkhhWPmS/lCmtBU/nVGK LKh8pkdcKzEaIruwf0QCn5HY8bWUuuTuz3kDbTflXeYwIRyujn0pcmEWGrPxaNsxJeeH1EWYwXsAu WyHCdRVQ==; 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 1qveak-00CTxA-04; Wed, 25 Oct 2023 14:10:38 +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, "Darrick J . Wong" Subject: [PATCH 2/4] block: update the stable_writes flag in bdev_add Date: Wed, 25 Oct 2023 16:10:18 +0200 Message-Id: <20231025141020.192413-3-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: E8B3112001F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: a8mqqq5ngpi7ouiwntyjjweaxibcew5t X-HE-Tag: 1698243041-557430 X-HE-Meta: U2FsdGVkX18gPokXh7iepTteB2ZqE5cPL7prCQjZV1T1Huiskltf7MzmLPocE575/j5I0plTzICnvvS4wNMHIcRyq4+EtWZA26cx1AZjYdnJV/GMduGmW3uXjjuFGfXCvvtPsifVvG5Td4DVsa9V9ZuSP/xHSI5qKxPZD2v5Wvvq0jTAZwt7wtRTsRSdyT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IQvf7vRkqBW0EtOZJpGiTlyIZdY81RBBcPCJq8dpOwARsdj5+9YjGSGn373//mODRF4jrqVZSD12Ygya/kLVe9RaXzZf57kN5Fxq5Y8ADuzTeinQJD3HOJVowjpBiFqgPis1SfAcmjPSw3iYPr6CA4RZjG5xbX1CqThvIDAyD8ub/hBWD1ed4hKcuoqDghbDtXOEExG0a4V/elXrAiXW1MSQ7HeEiMlKjNCjeFPRwr3oDdNGu0LGf+AxwqFGNgmH2R9HcB0I40PoyOrza 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 Reviewed-by: Darrick J. Wong Tested-by: Ilya Dryomov --- 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 Wed Oct 25 14:10:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13436236 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 74024C07545 for ; Wed, 25 Oct 2023 14:10:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF6C36B0307; Wed, 25 Oct 2023 10:10:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA81D6B0309; Wed, 25 Oct 2023 10:10:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FA2B6B030B; Wed, 25 Oct 2023 10:10:47 -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 75A576B0307 for ; Wed, 25 Oct 2023 10:10:47 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 539DCB557C for ; Wed, 25 Oct 2023 14:10:47 +0000 (UTC) X-FDA: 81384169734.06.E71A78B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id 58BFC100023 for ; Wed, 25 Oct 2023 14:10:45 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=bOq9qDAd; dmarc=none; spf=none (imf14.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=1698243045; a=rsa-sha256; cv=none; b=fUkJtcIr8Z87BSenPoXB+VOG/lbxY1iF/zHpFT3J9KaexYavrzEewqDeJp54KsZ+gfYiNx ANT4M6Rw8R+gvARPXLglohmGzNZmnpyRX2aiamBrC9XWkOaV4o8FUdkXxFjyIhug81MjJj au+3CVufPcEWggv80ZT3Q1cGigDXBhk= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=bOq9qDAd; dmarc=none; spf=none (imf14.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=1698243045; 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=ovjCiQ06cAyDAs81spcaUYTd/nSmVBQIeOWPuhdd988=; b=eXN2ElXp9FIJuuY1bQI/DFcMi+hJZevNlRvscuvJZ00Zk7PmwigQMVamaNnqqIWmpokG4U 2pKIw3zEQHQri0NphWfyS15eKJ/qw86BsiDPVKyW+Op31mOoZV7WsYVv24aIUNSI0FuMrX 26hHEsVJ26GNEbBjmXfAOamCKW3pKjQ= 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=ovjCiQ06cAyDAs81spcaUYTd/nSmVBQIeOWPuhdd988=; b=bOq9qDAdLVem3461ZjZwKrf7J0 ie8y1IIJOvq+Net1QLGYjOrIPKk7b7qSgyGOFC3BzE4AvPwZpcfz1Lo/zVQqgU8lwncWb1zyvegGO NnvWFUyhTTe0AvKQ7mHIOmnyhQprw64lBF25W0zs4w2Qeav9hiL53q/YFg7weqRSOZdUKEMMHK40z av+U0KLUWM14T2YVfYxprlWhcnWUuXzkRtdz+LQi9G42qsvu9Lg3IS3TZj90ddWF/84j6YKKcL6xt u5fUlBav/GqycUN1UeR9N03Y7Npgq/LJ6mq0FZQoaNjazSeCHQJQ7hinxbRQ6RCb5QlRhQQB2wroS yk61/hfw==; 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 1qvean-00CTxW-1t; Wed, 25 Oct 2023 14:10:42 +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/4] xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags Date: Wed, 25 Oct 2023 16:10:19 +0200 Message-Id: <20231025141020.192413-4-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 58BFC100023 X-Stat-Signature: rjdqpp9ua6meb541w69rjpm3w9sftaru X-HE-Tag: 1698243045-621628 X-HE-Meta: U2FsdGVkX18+JcJo9Gb6vp3Yhxs5sJ5KcKjFnV4aYen20Uxn9zgrlv5GumdEfDJ1J8630RBXy7DL/wlBoXF1iZxw0TxP6ScAgZW8Gbx4+GxTGwetjvhi1/77W1phPsj1UBhzTXmPijAEJ/PoSNTKXvSTiN+3ftC4adggh10IG6WrfFNFOoaeU0qHojYlYTQt0KhmCuVl+8RFyR4vsrNXohHLPYMwKleFB43nkeAcZyW4/EnF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UiRzf3R354UsdZV4tQyFZ4PNLfczrBKFxobn/NMO5Q9YXJE3dK1tE/3KR+UHmPHJSMQXkTuxxJy5H8XOPusvAwl8xATqdzEc7JuAhG/ZzIvfpXEFIGR2tpVC6ImgxdIHiCg1P9k4UyIkvvHwPlD7cglJDCxJQ= 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: Introduce a local boolean variable if FS_XFLAG_REALTIME to make the checks for it more obvious, and de-densify a few of the conditionals using it to make them more readable while at it. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_ioctl.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 55bb01173cde8c..be69e7be713e5c 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1120,23 +1120,25 @@ xfs_ioctl_setattr_xflags( struct fileattr *fa) { struct xfs_mount *mp = ip->i_mount; + bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME); uint64_t i_flags2; - /* Can't change realtime flag if any extents are allocated. */ - if ((ip->i_df.if_nextents || ip->i_delayed_blks) && - XFS_IS_REALTIME_INODE(ip) != (fa->fsx_xflags & FS_XFLAG_REALTIME)) - return -EINVAL; + if (rtflag != XFS_IS_REALTIME_INODE(ip)) { + /* Can't change realtime flag if any extents are allocated. */ + if (ip->i_df.if_nextents || ip->i_delayed_blks) + return -EINVAL; + } - /* If realtime flag is set then must have realtime device */ - if (fa->fsx_xflags & FS_XFLAG_REALTIME) { + if (rtflag) { + /* If realtime flag is set then must have realtime device */ if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 || (ip->i_extsize % mp->m_sb.sb_rextsize)) return -EINVAL; - } - /* Clear reflink if we are actually able to set the rt flag. */ - if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip)) - ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; + /* Clear reflink if we are actually able to set the rt flag. */ + if (xfs_is_reflink_inode(ip)) + ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; + } /* diflags2 only valid for v3 inodes. */ i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags); 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+othuReaIAeGL1h81SHqbcCl/oEYXC2qKocdvOusBwKgLgaBusLB5qVLNZpMmPl1PfdY/nd1jEe1VTqVMB+BrvRQERxgGnVQD/hYU6gycLtAFyMLMehNO9Q4R4JVjczXZWh5OF6vS/NCoCbI9HeeZY1Pu0dITUbixPoWDTYEg3/q3v5p6WE0Y+C2+3eprL4Xg5EsMJR3GL1OjE26T2+khO9tHG34w2KZ40rbcVoWNADLRNrnv0PC+7psgvjmc6BmC/uEzzsD7GWl2qR+fBoYTrDzoe5jO6kBhu0jg+dmGftBvyOEOR/pdRsapt1MBs0roi0JbokHEkEKHqEa72BUY/iASPmtLyv4RiOcWiObnb/LrwMoX+6P3Bfn1jXX47pCmk40itfkJQXpauDH1cFr97nG5tKrKJaXAUhMvGxm7mAEiBt8pOoz10s+9UQeMG/Rhb25aCEwa0Wi/C/TwX9QWd4VhNxHAT81KdaHWnD/dVi9FGYSI6zcabin0He6h5mwXwQK/EWOJsbyH3+D8d9/3z0OW78RgxIha8gld4i04OfWihrXP3L+o2xObeSSfSrkLMdJ+citxgBuTbSE1oEUWH6JAHLCBzocWZhj+ss8wCwXayma/ARVeMEGD8g59lPvK6DLdpo1JHVI56xX673WcPS/rZxHnGATDNx2oaNPq5WQbe+KLg/aefbc1PPecgDIxFkPpxK5LUta+jjS6af6QfLCy6myMLmpMYZlebK1KuU/wEskfUA037lI0dA08qjgHNpcpAbFRW+8cb5ur6SYroW5vOtTn90OsIeMkoxRH9k+POaiiwJcvj+ZYNprsJn5jmpSxRpeCIY1suJT0pAy6O241JYRnZBgVoZyRK/XTlMPDmKzGgQ7ClA phj2M+ZI PRXhhWp4C2LVaUMCrIZtBLPFE9tFfaRUH5gCPcCrNqagGQrv1MGfUWIzCRP+SFo/K197NHntKXKtcy1PMm45qmQsK4Ao2wGYdTCUskO4aSrEZX9HTZhjhS5odLWjLTaRwpqOboxN8hdkazKsgeVvoJUE3Ur2UKextN6q4D7RzsJykSN3L1U6iu3085athknwylL4LGu1BEAcnihu6nsNnJbMYqU7fQyet4lQk2M297jfMtf+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.