Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2029462ybv; Sat, 8 Feb 2020 11:35:18 -0800 (PST) X-Google-Smtp-Source: APXvYqw8ongUA4fVo8n1FlWc8Qp5fpnH/OwCJ2L+Ur1BUPwB310uGB85SEY1kkLw/nW60qKHEjZT X-Received: by 2002:aca:ad47:: with SMTP id w68mr5932736oie.63.1581190518068; Sat, 08 Feb 2020 11:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581190518; cv=none; d=google.com; s=arc-20160816; b=WgQyfDx2IElHXfQLXcV2wj5x2VxhBwqn6zoJZzRygOpk6lqma8ruTnKcxSxK6RXOu+ ZP3j1mJOrdfcpXYwvTQZoiJss0C3nMnfqU17YrV+dK6Ez0zpqlpn2u4SDjdE99OLeE4l 5wG/hJOK9KuRaPQlXKKYxB4me1rPF68ZEy8Jo6UXPCIPSb4cYAtM3w0YpRZeb2O+eGWq u2gJ6ZMQt854EOHU1mB+foPpADGdUVGUGAfITEuIubS6BqyIY/e22OxXvXq8fcvhJHNj piRG0uoPgU6KFQzgpDcCV7mAd/Kl9DHhmxU/ELV+LWoldJnme6mqjXyAVAqWNmzSQLyI QeBw== 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=iChYVsTOtC5Q5udz0SvPD6Oek8abDqYRPu/eal8ddNk=; b=hTit4ugyt498JC4KUuO18lqc4accfjShWTToS3JFzZzQlzs3lR8lrMrOWz5VwDZQjg VhmJ3wWuIwjSB7VhDpMVBIbEjB4Womz/tOnbmiPFuCdAMpGlFtTqdaV4SLCeuk96IpyK ga92y1zqDkokBTUuRY9OesbhIFKzMgu+kLbUoyqp+yuCoGZssxBAhqJ8xXaVNngIFCrZ reFvi+sHM4bqmvUqkopgF24kUgt7jQdRLzKrJ1moO4SFpfnfcbTXV6dWFVD7kwqzqqDu Cxf2tUbbmJ5nJSaySc4UnaXlfSA7DUgJ62H7ECNEQe6T9rS8LgLX+yCfKVjcwWOGfrVU QBCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 u23si2004696otj.242.2020.02.08.11.35.07; Sat, 08 Feb 2020 11:35:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727665AbgBHTez (ORCPT + 99 others); Sat, 8 Feb 2020 14:34:55 -0500 Received: from mga18.intel.com ([134.134.136.126]:56785 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727563AbgBHTex (ORCPT ); Sat, 8 Feb 2020 14:34:53 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2020 11:34:53 -0800 X-IronPort-AV: E=Sophos;i="5.70,418,1574150400"; d="scan'208";a="225732414" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2020 11:34:52 -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: [PATCH v3 11/12] fs/xfs: Clean up locking in dax invalidate Date: Sat, 8 Feb 2020 11:34:44 -0800 Message-Id: <20200208193445.27421-12-ira.weiny@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200208193445.27421-1-ira.weiny@intel.com> References: <20200208193445.27421-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 faba232b1f31..0134c9e65efb 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1190,7 +1190,7 @@ xfs_ioctl_setattr_dax_invalidate( int *join_flags) { struct inode *inode = VFS_I(ip); - int error; + int error, flags; *join_flags = 0; @@ -1205,8 +1205,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)) { @@ -1229,11 +1231,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