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/wlBoXF1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gO1ayk8BGVTEHu1DITcO5k/NFiYv0lTGNHPF/nV1mkbC4O5CxepY1psvBNNHqPjxrSqYVuI3B9ymD+Nn6X0WBkvXn4f+SYqJZJ8j9dBdy8aShcLjm7dMPYV4dyP+Od3z8wSCleNvEc9dXUe0hBWyzBUiRzf3R354UsdZV4tQyFZ4PNLfczrBKFxobn/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);