Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp703434ybf; Wed, 26 Feb 2020 21:33:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyPxUk43huXZB93BAAcYRknjWll+tipwHnsnQsNiLVhjh0LkL52cdHnt2dsM9ZR/Tb8Bdkc X-Received: by 2002:a05:6808:c3:: with SMTP id t3mr36024oic.130.1582781624958; Wed, 26 Feb 2020 21:33:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582781624; cv=none; d=google.com; s=arc-20160816; b=Id82pgvCB2ObiATzblDjl6+tiTdCmMRlFUNis8uR3eCVaCVq2U8Kmpr5vRX9gED9b2 jlJ2+wzCDamVQ9rcw7lNZuk6onXnA/Tcu43Z28NSX8KXkhsxH0n2IIhcjZdmDILYzol1 d+Q7t7FbdEctdfsSsx+8QHqL/MBBrrY2USPLXHRHeX8Vl4b+hcijvRB5J+UuonSUYMff 6sqYnpaZqQsyeCEatNxk2Qj39HweIoYusy1M71e/35BceALuuykQT2dF4fY4lF4l9Avn KTNq+riTUG11vRLrS/uHpXPNhrSRSYBJQyhKtxT4cwfnUcC3vrj6/rxwWVAGtBdaPsXM Uvsg== 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=jsubtN3gTdBlH+6iY0ysRUjIu+oLRhd3LCt9NHTSwVg=; b=GDBq1JBnjZa/bGyt/Ran/vKQi7hbsGngU/8ienZtGjt1rtMf8ixrliBofcbC4J+v0Y BM74Bq7BO4p3KOBSnzQn3jE5aBzd1SMwcc6v0korG0IY/U8owyfhd5kkZiOaIKRSoTQn U0YaWqLVNrRAEb/Jfpty01A7vjKHLg5/ssUN/vhJOj7fkB/0C1dSgkU8nYgjb5C/chq9 NIB0E9z0xYoxyYyMV+ULcq5RMRuBAiE82tsVCHffoNuKv40ineF/aEjtllILH3RnGCKm dkUmGGAhFY18G+SFipXYyV5oQK+cKyhHgFWucgbV00ZezjBw6uI1OnqiCESidTYyp5Cj wbnw== 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 d6si757574oic.190.2020.02.26.21.33.34; Wed, 26 Feb 2020 21:33:44 -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 S1728459AbgB0Fcr (ORCPT + 99 others); Thu, 27 Feb 2020 00:32:47 -0500 Received: from mga01.intel.com ([192.55.52.88]:17726 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbgB0Fcq (ORCPT ); Thu, 27 Feb 2020 00:32:46 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Feb 2020 21:32:45 -0800 X-IronPort-AV: E=Sophos;i="5.70,490,1574150400"; d="scan'208";a="230676227" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Feb 2020 21:32:45 -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 V5 09/12] fs/xfs: Clean up locking in dax invalidate Date: Wed, 26 Feb 2020 21:24:39 -0800 Message-Id: <20200227052442.22524-10-ira.weiny@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200227052442.22524-1-ira.weiny@intel.com> References: <20200227052442.22524-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 6c4d4ea3b6b6..40ae791cfb41 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 there is a mapping in place we must remain in our current state. @@ -1223,11 +1225,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