From patchwork Fri Oct 20 02:39:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10018817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 60BFC60224 for ; Fri, 20 Oct 2017 02:47:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C77A28E8B for ; Fri, 20 Oct 2017 02:47:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40F1B28E8E; Fri, 20 Oct 2017 02:47:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA62B28E8B for ; Fri, 20 Oct 2017 02:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751945AbdJTCqZ (ORCPT ); Thu, 19 Oct 2017 22:46:25 -0400 Received: from mga04.intel.com ([192.55.52.120]:60434 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbdJTCqW (ORCPT ); Thu, 19 Oct 2017 22:46:22 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2017 19:46:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,404,1503385200"; d="scan'208";a="1027184015" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga003.jf.intel.com with ESMTP; 19 Oct 2017 19:46:21 -0700 Subject: [PATCH v3 11/13] fs: use smp_load_acquire in break_{layout,lease} From: Dan Williams To: akpm@linux-foundation.org Cc: linux-xfs@vger.kernel.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, hch@lst.de, "J. Bruce Fields" , linux-mm@kvack.org, Alexander Viro , linux-fsdevel@vger.kernel.org, Jeff Layton , Ross Zwisler Date: Thu, 19 Oct 2017 19:39:57 -0700 Message-ID: <150846719726.24336.3564801642993121646.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <150846713528.24336.4459262264611579791.stgit@dwillia2-desk3.amr.corp.intel.com> References: <150846713528.24336.4459262264611579791.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 128a37852234 "fs: fix data races on inode->i_flctx" converted checks of inode->i_flctx to use smp_load_acquire(), but it did not convert break_layout(). smp_load_acquire() includes a READ_ONCE(). There should be no functional difference since __break_lease repeats the sequence, but this is a clean up to unify all ->i_flctx lookups on a common pattern. Cc: Christoph Hellwig Cc: Alexander Viro Cc: Ross Zwisler Cc: Jeff Layton Cc: "J. Bruce Fields" Signed-off-by: Dan Williams Reviewed-by: Jeff Layton --- include/linux/fs.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 13dab191a23e..eace2c5396a7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2281,8 +2281,9 @@ static inline int break_lease(struct inode *inode, unsigned int mode) * could end up racing with tasks trying to set a new lease on this * file. */ - smp_mb(); - if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) + struct file_lock_context *ctx = smp_load_acquire(&inode->i_flctx); + + if (ctx && !list_empty_careful(&ctx->flc_lease)) return __break_lease(inode, mode, FL_LEASE); return 0; } @@ -2325,8 +2326,9 @@ static inline int break_deleg_wait(struct inode **delegated_inode) static inline int break_layout(struct inode *inode, bool wait) { - smp_mb(); - if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) + struct file_lock_context *ctx = smp_load_acquire(&inode->i_flctx); + + if (ctx && !list_empty_careful(&ctx->flc_lease)) return __break_lease(inode, wait ? O_WRONLY : O_WRONLY | O_NONBLOCK, FL_LAYOUT);