Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp704299ybf; Wed, 26 Feb 2020 21:34:51 -0800 (PST) X-Google-Smtp-Source: APXvYqyl3U8i4LJuAcBNSoTY75IAEOFrXlMr5OaODo94lNras9jlp4KKpVjOMfNcC/VgWNJWnq6A X-Received: by 2002:a9d:6f82:: with SMTP id h2mr1926219otq.69.1582781691222; Wed, 26 Feb 2020 21:34:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582781691; cv=none; d=google.com; s=arc-20160816; b=UXHWhX8LRFAWgxMIOsX3LBx6QInD2E5mwyTYAyKdEIivIbPFr37exgqSZJWQ7nFyXn zda8F0P3B3q7gU2Ow3vqlFY2K+3XSZCdszj2O8IDzfuTv2vZFoO2lSPX0GDV/Z3mT7i1 Ah5BQ2ezyr4BVRMTRGy9KHq4qotkbK/NEV9KFRqA7mSwyZQialnlja9r7r7/zZw/GlBM yCNSt6VT08xQ2tfw8cH7+Gu/Zv9QED4NkpCXeeIBM10DQ7jyhgv48EmLYs1iSTZ/6DU0 B7iFY5XwJnTXp7m5vVItvuiCComzCizp6Z0KrJi3oPBDXtWqbMp17o6BTSxt25fWaJmm G8bA== 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=zv0GTvb4j3JkNegTsaHaMckZcNQw6DMfG3Ig93ucgFA=; b=P6k4suQYeaLK7Zub+JQVYjCwal4LC1BifVPkygzMRkXDIYIUxLG65DDvhpJvta1M5C exN3p22MurfHst5F0EWyOpRXLNcgjiGk4mgZoocpJTjIcXNCx+XiVgEF6abuslKp3qHb PeEMRXm88cQW9mHFyqGtA68eOc67CNJ4Mf+CIDwv2EAtgpro+kEOG8jeklZ2cCHTsOZe qf+SM4nk5kHF7rog+a/G1IwpwAe0VhRJlDHd299pqfmYwaUvRZOdcupxbXfKCg205F32 WZAfajHJJSa6XpMqg1KT6O2ZVk16+MU032RJc4AiVKEiWPaufzcUsnrTd2l5ncsj0avb AQ/w== 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 v126si788770oia.106.2020.02.26.21.34.40; Wed, 26 Feb 2020 21:34:51 -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 S1728593AbgB0FdY (ORCPT + 99 others); Thu, 27 Feb 2020 00:33:24 -0500 Received: from mga05.intel.com ([192.55.52.43]:37515 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728416AbgB0Fcp (ORCPT ); Thu, 27 Feb 2020 00:32:45 -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 fmsmga105.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="232052990" 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; 26 Feb 2020 21:32: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 V5 08/12] fs/xfs: Hold off aops users while changing DAX state Date: Wed, 26 Feb 2020 21:24:38 -0800 Message-Id: <20200227052442.22524-9-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 XFS requires the use of the aops of an inode to be quiesced prior to changing the aops vector to/from the DAX vector. Take the aops write lock while changing DAX state. Signed-off-by: Ira Weiny --- Changes from v4: Open code the aops write lock Obsolete: Clean up lock name in comments Obsolete: Change #define: XFS_DAX_EXCL => XFS_AOPSLOCK_EXCL Changes from v3: Change locking function names to reflect changes in previous patches. Changes from V2: Change name of patch (WAS: fs/xfs: Add lock/unlock state to xfs) Remove the xfs specific lock and move to the vfs layer. We still use XFS_LOCK_DAX_EXCL to be able to pass this flag through to the transaction code. But we no longer have a lock specific to xfs. This removes a lot of code from the XFS layer, preps us for using this in ext4, and is actually more straight forward now that all the locking requirements are better known. Fix locking order comment Rework for new 'state' names (Other comments on the previous patch are not applicable with new patch as much of the code was removed in favor of the vfs level lock) --- fs/xfs/xfs_ioctl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 498fae2ef9f6..6c4d4ea3b6b6 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1444,7 +1444,11 @@ xfs_ioctl_setattr( * or cancel time, so need to be passed through to * xfs_ioctl_setattr_get_trans() so it can apply them to the join call * appropriately. + * + * Further we hold off aops users until we have completed any potential + * changing of aops due to attribute changes. */ + inode_aops_down_write(VFS_I(ip)); code = xfs_ioctl_setattr_dax_invalidate(ip, fa, &join_flags); if (code) goto error_free_dquots; @@ -1527,6 +1531,7 @@ xfs_ioctl_setattr( xfs_qm_dqrele(udqp); xfs_qm_dqrele(pdqp); + inode_aops_up_write(VFS_I(ip)); return code; error_trans_cancel: @@ -1534,6 +1539,7 @@ xfs_ioctl_setattr( error_free_dquots: xfs_qm_dqrele(udqp); xfs_qm_dqrele(pdqp); + inode_aops_up_write(VFS_I(ip)); return code; } @@ -1603,7 +1609,11 @@ xfs_ioc_setxflags( * or cancel time, so need to be passed through to * xfs_ioctl_setattr_get_trans() so it can apply them to the join call * appropriately. + * + * Further we hold off aops users until we have completed any potential + * changing of aops due to attribute changes. */ + inode_aops_down_write(VFS_I(ip)); error = xfs_ioctl_setattr_dax_invalidate(ip, &fa, &join_flags); if (error) goto out_drop_write; @@ -1630,6 +1640,7 @@ xfs_ioc_setxflags( error = xfs_trans_commit(tp); out_drop_write: mnt_drop_write_file(filp); + inode_aops_up_write(VFS_I(ip)); return error; } -- 2.21.0