Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1068812ybl; Fri, 10 Jan 2020 11:31:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxWqg1mesAbud6a999A5DhMBpokNVasmm5p6WA4wew8iZrffLxyJlGG/KbKAeymVSxsprOt X-Received: by 2002:a05:6830:451:: with SMTP id d17mr3731942otc.53.1578684663740; Fri, 10 Jan 2020 11:31:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578684663; cv=none; d=google.com; s=arc-20160816; b=y+MS5zW/aksf0qvVNVQ087DbU97FrTOfptoztHyhMccvJltai3jMXDpHjRrcJhNFEG AV56MRrNuaaGEW3zV5OO1kWX2MAI+y5zDxDwDiksuoe8irj504zXBpy0DQgQGPySOG2g d+5nekS4Z6aI2gaN7W0+UK4L5HE1gQH+oRS5BdTXnAxnyZpFb3OvPy1uTWJljD5gq7lE gKzs1A5s2M2IYvT8PQJRp3Dj5TdujKtR87uAVMJgyFqqlpkNLb2dHanLOxH4DBDjcIUB I8zVCBvXfZmgw0IqiKNDY94rx3Hs6S5P0fWpTho4USg8mURJgmCkx2B9In/F5MwkHoUh DcjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xGkCiQiIAn/azJcoJdTshRWBZQV3ZtXzdcfkLWv2Lns=; b=GEj7NrMHVKqGMdmnqaUxZkI//w1ULrCerS4Gdcn9H4x86HXozIY3t/uRtJ4ehRlBO4 L6egNB6+qEmB4K2AabTFoe440aZfKxKy/TL33sdFzWu8L57OVjUzvXacmVJkox0A7c/c TbPgUosglD8c79a3YO0COUDaYz98wciKZwN6OSv5Tncc+7Rz1K1/52AxJ5bNcn0D88t1 92wZJlnke5sZg/MZEHrhUNOPBQxMx0M+dymV+7+Y/agTwKKsvRNHPZ0sK8IpRcqiBbjH wWOi9AbmZWFn+QW0PpGVGUVbGe8d2Y7s+t4InaNGDMfSGPTEg3hP/4qtPtdjq87xWQsl pUiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si1624778oix.27.2020.01.10.11.30.52; Fri, 10 Jan 2020 11:31:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729018AbgAJTaQ (ORCPT + 99 others); Fri, 10 Jan 2020 14:30:16 -0500 Received: from mga07.intel.com ([134.134.136.100]:43951 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729004AbgAJTaO (ORCPT ); Fri, 10 Jan 2020 14:30:14 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2020 11:30:14 -0800 X-IronPort-AV: E=Sophos;i="5.69,418,1571727600"; d="scan'208";a="218748606" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2020 11:30:13 -0800 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org Cc: Ira Weiny , Alexander Viro , "Darrick J. Wong" , Dan Williams , Dave Chinner , Christoph Hellwig , "Theodore Y. Ts'o" , Jan Kara , linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC PATCH V2 11/12] fs/xfs: Clean up locking in dax invalidate Date: Fri, 10 Jan 2020 11:29:41 -0800 Message-Id: <20200110192942.25021-12-ira.weiny@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200110192942.25021-1-ira.weiny@intel.com> References: <20200110192942.25021-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Ira Weiny Define a variable to hold the lock flags to ensure that the correct locks are returned or released on error. Signed-off-by: Ira Weiny --- fs/xfs/xfs_ioctl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 1ab0906c6c7f..9a35bf83eaa1 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1176,7 +1176,7 @@ xfs_ioctl_setattr_dax_invalidate( int *join_flags) { struct inode *inode = VFS_I(ip); - int error; + int error, flags; *join_flags = 0; @@ -1191,8 +1191,10 @@ xfs_ioctl_setattr_dax_invalidate( if (S_ISDIR(inode->i_mode)) return 0; + flags = XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL; + /* lock, flush and invalidate mapping in preparation for flag change */ - xfs_ilock(ip, XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL); + xfs_ilock(ip, flags); if ((fa->fsx_xflags & FS_XFLAG_DAX) == FS_XFLAG_DAX && !xfs_inode_supports_dax(ip)) { @@ -1215,11 +1217,11 @@ xfs_ioctl_setattr_dax_invalidate( if (error) goto out_unlock; - *join_flags = XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL; + *join_flags = flags; return 0; out_unlock: - xfs_iunlock(ip, XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL); + xfs_iunlock(ip, flags); return error; } -- 2.21.0