From patchwork Wed Mar 13 15:47:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 10851389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92571139A for ; Wed, 13 Mar 2019 15:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 804832999A for ; Wed, 13 Mar 2019 15:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EA3C29FC9; Wed, 13 Mar 2019 15:46:00 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 1F7FC2999A for ; Wed, 13 Mar 2019 15:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726420AbfCMPp7 (ORCPT ); Wed, 13 Mar 2019 11:45:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:60768 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726292AbfCMPp6 (ORCPT ); Wed, 13 Mar 2019 11:45:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 12F81B117 for ; Wed, 13 Mar 2019 15:45:57 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id DA436DA875; Wed, 13 Mar 2019 16:47:12 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 6/9] btrfs: use assertion helpers for extent buffer read lock counters Date: Wed, 13 Mar 2019 16:47:12 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 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 Use the helpers where open coded. On non-debug builds, the warnings will not trigger and extent_buffer::read_locks become unused and can be moved to the appropriate section, saving a few bytes. Signed-off-by: David Sterba --- fs/btrfs/extent_io.c | 2 +- fs/btrfs/extent_io.h | 2 +- fs/btrfs/locking.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 30363cb97625..a74495bdb552 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4669,7 +4669,6 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, eb->bflags = 0; rwlock_init(&eb->lock); atomic_set(&eb->write_locks, 0); - atomic_set(&eb->read_locks, 0); atomic_set(&eb->blocking_readers, 0); atomic_set(&eb->blocking_writers, 0); eb->lock_nested = 0; @@ -4692,6 +4691,7 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, #ifdef CONFIG_BTRFS_DEBUG atomic_set(&eb->spinning_writers, 0); atomic_set(&eb->spinning_readers, 0); + atomic_set(&eb->read_locks, 0); #endif return eb; diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index e49310d2caf4..fee8c8c463b8 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -148,7 +148,6 @@ struct extent_buffer { /* count of read lock holders on the extent buffer */ atomic_t write_locks; - atomic_t read_locks; atomic_t blocking_writers; atomic_t blocking_readers; short lock_nested; @@ -171,6 +170,7 @@ struct extent_buffer { #ifdef CONFIG_BTRFS_DEBUG atomic_t spinning_writers; atomic_t spinning_readers; + atomic_t read_locks; struct list_head leak_list; #endif }; diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c index 947c66c01e34..e88a0a3d286f 100644 --- a/fs/btrfs/locking.c +++ b/fs/btrfs/locking.c @@ -164,7 +164,7 @@ void btrfs_tree_read_lock(struct extent_buffer *eb) atomic_read(&eb->blocking_writers) == 0); goto again; } - atomic_inc(&eb->read_locks); + btrfs_assert_tree_read_locks_get(eb); btrfs_assert_spinning_readers_get(eb); } @@ -183,7 +183,7 @@ int btrfs_tree_read_lock_atomic(struct extent_buffer *eb) read_unlock(&eb->lock); return 0; } - atomic_inc(&eb->read_locks); + btrfs_assert_tree_read_locks_get(eb); btrfs_assert_spinning_readers_get(eb); return 1; } @@ -204,7 +204,7 @@ int btrfs_try_tree_read_lock(struct extent_buffer *eb) read_unlock(&eb->lock); return 0; } - atomic_inc(&eb->read_locks); + btrfs_assert_tree_read_locks_get(eb); btrfs_assert_spinning_readers_get(eb); return 1; } @@ -248,7 +248,7 @@ void btrfs_tree_read_unlock(struct extent_buffer *eb) } btrfs_assert_tree_read_locked(eb); btrfs_assert_spinning_readers_put(eb); - atomic_dec(&eb->read_locks); + btrfs_assert_tree_read_locks_put(eb); read_unlock(&eb->lock); } @@ -272,7 +272,7 @@ void btrfs_tree_read_unlock_blocking(struct extent_buffer *eb) /* atomic_dec_and_test implies a barrier */ if (atomic_dec_and_test(&eb->blocking_readers)) cond_wake_up_nomb(&eb->read_lock_wq); - atomic_dec(&eb->read_locks); + btrfs_assert_tree_read_locks_put(eb); } /*