From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D98715F54E; Tue, 13 Feb 2024 17:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845283; cv=none; b=BMCe6MEIcF5bvQ7NiZNd7zATW9DgUno0gnkmfoPBQD3tQGHboi/bB5lB3vg7D9ev7GKFgjfPt6WP1PQdSfV2d7atE4khEgzNpKbRt+gYrOvwIIVGgSgMKsTozq/Cx1t+LD26c8/q7wSQyV8GfNoGCAWOnJtnzpSfx3kWNA7aCxo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845283; c=relaxed/simple; bh=e/MgmcDUJMEMNOA9Zcl12vH5N7hoqom8eSVlUlnPn50=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OgR0IwaZaOwbKii+WWOJzOKLfWrRDyeNH6rZAyDUhkoH6lpKWzMES4CTuNm89Ms+3WpwqvNvVmjoHQ09JTZZRVGy1VdQbkjWtKLUpshdtdjeWS3MY7RlgoZbo//osV8XkOMo8V36bTnPFqQK/pGdQUzlOgLGRwK7v6DsF/Zxj00= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yWAfpO76; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yWAfpO76" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DC7EC433F1; Tue, 13 Feb 2024 17:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1707845283; bh=e/MgmcDUJMEMNOA9Zcl12vH5N7hoqom8eSVlUlnPn50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yWAfpO76N8f9ihSxwvGNR2Y4hlmDBz24FmCUUpETfrseDdQ5utLRu4l4cOO++qoqF ZG7qXWlqd7foZ8zR3T0vkcpOcGfBo5S7EsTJxIHKxf0+XT+1Ci0RivUVGTycHrt9ix C9KwLzd2+75tvEIOr01erXK/Z4yAa1PxwfIn2BEg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , "Darrick J. Wong" , Christian Brauner , Catherine Hoang , Chandan Babu R , Sasha Levin Subject: [PATCH 6.6 036/121] xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags Date: Tue, 13 Feb 2024 18:20:45 +0100 Message-ID: <20240213171854.054172077@linuxfoundation.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240213171852.948844634@linuxfoundation.org> References: <20240213171852.948844634@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christoph Hellwig commit c421df0b19430417a04f68919fc3d1943d20ac04 upstream. 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 Link: https://lore.kernel.org/r/20231025141020.192413-4-hch@lst.de Reviewed-by: Darrick J. Wong Signed-off-by: Christian Brauner Signed-off-by: Catherine Hoang Acked-by: Chandan Babu R Signed-off-by: Sasha Levin --- 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 55bb01173cde..be69e7be713e 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); -- 2.43.0