Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1265590ybv; Thu, 20 Feb 2020 16:42:56 -0800 (PST) X-Google-Smtp-Source: APXvYqyLER5QgRkqs5nab21uZUCGFtL/NONvVh2ia7Pxp4qTib2UAramYjXrjVDU9sKLG5wZ5bMx X-Received: by 2002:a9d:1ca3:: with SMTP id l35mr25335224ota.271.1582245776559; Thu, 20 Feb 2020 16:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582245776; cv=none; d=google.com; s=arc-20160816; b=bIOZ25qtZxYRgfT1A8aE7JEz5f/B4XuJtadAl8HT2GSUIkE3kno4woQe2525971N/e 0vZEUMCbYOiB0jPzFKPpTuUn5fpXKtqMM3W419Kb3yAuVb5h/qTBj9D9GLjIHWNlXyfW CiqMOZvsltcwweOGQR5xetEvdgDI3LXZp4cP9ZzCAw0p2X+VnZ0BDy4eS9iyETBDsaFC m1j/IYAKkr6IUJ9dFjaL1RFecCPZt7DEe6xRBeCDIIdrMZIy4BeT2gbqR9QQ8Vu62vQj eC3lP8No/Avg/iGa+2BeBsnzHViRXFz8PS1T2QBB9CmXDEk/xPbc+t6PBmd5ndLJuHiq v8+Q== 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=wA8iA9XyP0rx7jlxUr6HPsG/bviwAKmVvvFbto5kTBw=; b=cD4saCqttTbANAUqxOFXXUhEsJr/2dEtPHvFNSOOhHAcme9LUiL8zbZPX9BSLbB0zP fctCzs2KvjyIqlBTDjKC5aP73iQxM3QvV0KRgTHepv6NalndKDew96MzOrcpQltuqalB YL5h68e7CvWlhSxQjW8iwhXIx6jqtUEIWo1zlgIg3c/2jfyVIlCxp5bwWbKlnD2EvSlQ of7ATFNRHH1ELFej6VQYl4VEzuywz+4xGQkbXQ5IAFUBrBguKo3sUt7aG7oFXLw1uEOi MiTQ94QH+xCYHTB6/VhXGlW2roRB6C3K7twfBavEGO46Z2NOU1ftQ8T4W6rvDUhvdrh2 MtYQ== 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 i8si499619oih.206.2020.02.20.16.42.44; Thu, 20 Feb 2020 16:42:56 -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 S1729721AbgBUAmS (ORCPT + 99 others); Thu, 20 Feb 2020 19:42:18 -0500 Received: from mga11.intel.com ([192.55.52.93]:31906 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729618AbgBUAlo (ORCPT ); Thu, 20 Feb 2020 19:41:44 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2020 16:41:44 -0800 X-IronPort-AV: E=Sophos;i="5.70,466,1574150400"; d="scan'208";a="269799108" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2020 16:41:44 -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 V4 10/13] fs/xfs: Clean up locking in dax invalidate Date: Thu, 20 Feb 2020 16:41:31 -0800 Message-Id: <20200221004134.30599-11-ira.weiny@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200221004134.30599-1-ira.weiny@intel.com> References: <20200221004134.30599-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 498fae2ef9f6..321f7789b667 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