From patchwork Thu Dec 15 13:38:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seraphime Kirkovski X-Patchwork-Id: 9476137 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 EE9BE607EE for ; Thu, 15 Dec 2016 13:38:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F330E28766 for ; Thu, 15 Dec 2016 13:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6F2C28772; Thu, 15 Dec 2016 13:38:28 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 705C828766 for ; Thu, 15 Dec 2016 13:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932303AbcLONiZ (ORCPT ); Thu, 15 Dec 2016 08:38:25 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35677 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751214AbcLONiY (ORCPT ); Thu, 15 Dec 2016 08:38:24 -0500 Received: by mail-wm0-f68.google.com with SMTP id a20so6565815wme.2 for ; Thu, 15 Dec 2016 05:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7uTozx/AehMILJeRqVQXKyq7BeXxWnEPVMthZ5002gs=; b=WQi0TnXidzkMNmzaLYXKC4YoGxFeidh+16wp66FCgpgk4peYW7AQ+iZ1fzvKMXodvj 4eMCBZz/klbGN45GygS9la0pWWPDX43XZVi9v+YJd9108nj65YJgaumqiv6VlThXaup/ Zf9dKuEK43uW+B3z0mgkMNWEHzyZEIa3FLiQFnX1rCmV8LXH/CncSxFBSRO5d71IX97t OA4LiGm2kvrrCm3IWoRYPABwxxuF4E01OO8SkD1HN+QLbQ6Zzi2tV1gX6iGqeSbCXsIe L2TUu+w73Q/N2rEN1LzCDyaowJ+mamzr76NJ10bkouuYbd7bz6bA+uJQ2sMKT2kogUta Tqfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7uTozx/AehMILJeRqVQXKyq7BeXxWnEPVMthZ5002gs=; b=dt30jCbOdN7+QQJR5cdEcOinetnUS9kFd03LJNbMmx9epsbq1nG3G+IubSRZ3J2rSS OqPaQs8CptA1ZH5FI6eAwKSt0NlJ4sZUDwPa8Y/g0JBzgUtDddryfsg96F3ONk4C1W78 859VLhId0AV+QgZ8QUl4DxUbikQouC4Egic+323DtryoQvFE9LdXCYuqhep5gXmKkJt2 mKXDitfO0uki6fyMZernHpSfR1vinRIeLCinzY4awqSplinqz8zFi4+OUY0UMvNBj8Mh Cw4Fx5NpMNgE81H3f2PviVke3GJs1a424pJPWyMcV4rRYEpIHTxeGPbd1ZbeE9L1pzOU Lvvw== X-Gm-Message-State: AIkVDXJ9iQ2xNKR00dcpIVKyG4tFhCQN+fkdeqFaiZEHv+XUZENlRUVSrTf5QCV1Fqhl8w== X-Received: by 10.28.9.131 with SMTP id 125mr1479712wmj.22.1481809102636; Thu, 15 Dec 2016 05:38:22 -0800 (PST) Received: from localhost (cha92-19-78-239-153-115.fbx.proxad.net. [78.239.153.115]) by smtp.gmail.com with ESMTPSA id g17sm2091088wjs.38.2016.12.15.05.38.20 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 15 Dec 2016 05:38:22 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Thu, 15 Dec 2016 14:38:20 +0100 From: Seraphime Kirkovski To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, jbacik@fb.com, clm@fb.com, Seraphime Kirkovski Subject: [PATCH 3/4] Btrfs: ACCESS_ONCE cleanup Date: Thu, 15 Dec 2016 14:38:16 +0100 Message-Id: <20161215133816.25735-1-kirkseraph@gmail.com> X-Mailer: git-send-email 2.10.2 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This replaces ACCESS_ONCE macro with the corresponding READ|WRITE macros Signed-off-by: Seraphime Kirkovski Reviewed-by: David Sterba --- fs/btrfs/delayed-inode.c | 4 ++-- fs/btrfs/super.c | 2 +- fs/btrfs/transaction.c | 10 +++++----- fs/btrfs/tree-log.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 6b23ef8..68e0e09 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -85,7 +85,7 @@ static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode) u64 ino = btrfs_ino(inode); struct btrfs_delayed_node *node; - node = ACCESS_ONCE(btrfs_inode->delayed_node); + node = READ_ONCE(btrfs_inode->delayed_node); if (node) { atomic_inc(&node->refs); return node; @@ -1294,7 +1294,7 @@ void btrfs_remove_delayed_node(struct inode *inode) { struct btrfs_delayed_node *delayed_node; - delayed_node = ACCESS_ONCE(BTRFS_I(inode)->delayed_node); + delayed_node = READ_ONCE(BTRFS_I(inode)->delayed_node); if (!delayed_node) return; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 3e25cfe..a445d4cd 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -271,7 +271,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, function, line, errstr); return; } - ACCESS_ONCE(trans->transaction->aborted) = errno; + WRITE_ONCE(trans->transaction->aborted, errno); /* Wake up anybody who may be waiting on this transaction */ wake_up(&fs_info->transaction_wait); wake_up(&fs_info->transaction_blocked_wait); diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 1bddef0..e340db1 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -859,14 +859,14 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) && should_end_transaction(trans, root) && - ACCESS_ONCE(cur_trans->state) == TRANS_STATE_RUNNING) { + READ_ONCE(cur_trans->state) == TRANS_STATE_RUNNING) { spin_lock(&info->trans_lock); if (cur_trans->state == TRANS_STATE_RUNNING) cur_trans->state = TRANS_STATE_BLOCKED; spin_unlock(&info->trans_lock); } - if (lock && ACCESS_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) { + if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) { if (throttle) return btrfs_commit_transaction(trans, root); else @@ -1919,7 +1919,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, int ret; /* Stop the commit early if ->aborted is set */ - if (unlikely(ACCESS_ONCE(cur_trans->aborted))) { + if (unlikely(READ_ONCE(cur_trans->aborted))) { ret = cur_trans->aborted; btrfs_end_transaction(trans, root); return ret; @@ -2059,7 +2059,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, atomic_read(&cur_trans->num_writers) == 1); /* ->aborted might be set after the previous check, so check it */ - if (unlikely(ACCESS_ONCE(cur_trans->aborted))) { + if (unlikely(READ_ONCE(cur_trans->aborted))) { ret = cur_trans->aborted; goto scrub_continue; } @@ -2173,7 +2173,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, * The tasks which save the space cache and inode cache may also * update ->aborted, check it. */ - if (unlikely(ACCESS_ONCE(cur_trans->aborted))) { + if (unlikely(READ_ONCE(cur_trans->aborted))) { ret = cur_trans->aborted; mutex_unlock(&root->fs_info->tree_log_mutex); mutex_unlock(&root->fs_info->reloc_mutex); diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h index ab858e3..127eae0 100644 --- a/fs/btrfs/tree-log.h +++ b/fs/btrfs/tree-log.h @@ -48,13 +48,13 @@ static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, static inline void btrfs_set_log_full_commit(struct btrfs_fs_info *fs_info, struct btrfs_trans_handle *trans) { - ACCESS_ONCE(fs_info->last_trans_log_full_commit) = trans->transid; + WRITE_ONCE(fs_info->last_trans_log_full_commit, trans->transid); } static inline int btrfs_need_log_full_commit(struct btrfs_fs_info *fs_info, struct btrfs_trans_handle *trans) { - return ACCESS_ONCE(fs_info->last_trans_log_full_commit) == + return READ_ONCE(fs_info->last_trans_log_full_commit) == trans->transid; }