From patchwork Tue Jun 6 23:45:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9770207 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 D7A916034B for ; Tue, 6 Jun 2017 23:45:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8A17284E4 for ; Tue, 6 Jun 2017 23:45:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADAC128520; Tue, 6 Jun 2017 23:45:57 +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_SIGNED, 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 9C47B284E4 for ; Tue, 6 Jun 2017 23:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751462AbdFFXpo (ORCPT ); Tue, 6 Jun 2017 19:45:44 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:33786 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751453AbdFFXpm (ORCPT ); Tue, 6 Jun 2017 19:45:42 -0400 Received: by mail-pg0-f46.google.com with SMTP id f185so39481227pgc.0 for ; Tue, 06 Jun 2017 16:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ob3uR3uIa/jGQR04SjOs9ULrJbMgMDl5SiDY3o1uTFc=; b=eyRHu8OXnXdRuL79iM0Kj0Ocd0vO6D0TtLc6vI3b0YshldYbKiXtGVDS4hpMi22jVq j2ZjDogybhDw7o+aJrVcy1H8yAYrn3W0lwV3rrx7w7u4xZxu19iBeFU5p8OZH47UZLjb R1SsKCfNkqFNT1YKrIAsI+FcdLc8/om2RtBVueMT2iP0ug1c3tRcEpQLlSVjy5/qgeEr K2T66Sb9Lll3eBQhv2CcLOHToF/5yDA/UjtT8ZpR5JKWiW/2TFN4UomnDdgAOYfuaMdI wC9/daP3QXTb64TD6L+a8eOLL/av9psx+l7npwpcG/kseyfRj5aUaYcjOjU1ME6pQI36 5dvA== 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:in-reply-to :references:in-reply-to:references; bh=ob3uR3uIa/jGQR04SjOs9ULrJbMgMDl5SiDY3o1uTFc=; b=cQaqKqnlxaBdFNBkhpEB6J92dZOcjaV/JkD25XstKjAIBMKnwWJ35B0K+0o+tAtaW9 GpoWBKvkvuLrdRXt2HSKF2fYCpgZ5zn1lWVN5s6igHP+uepaxDiQornz3l5Z/thVFeLP 1DxPKkz8QNwWXNIyhGBsTrlr+f4U3i4w51Dy+3guaWHF89hBfSgfY7B9g4XLY0KVc5/R 4eaLG5F8C7uqAQH8K5UXwSkeD5hbt8hN41XY7lv0pqOGmyfmwBi91K2TfTiGCvus5Ljz MBnC19nEAwshamWeqa98L53ekjLoCVevi3OMc9yTOkherIA2GVRP44i8kpwGid+bvjoT +XQg== X-Gm-Message-State: AODbwcCwXuyHRAJxI5qeSzw5ZVsbflj48GTeg1hknlUYHjf9/5h98Hsp EDVR3xUgxy6pzngsS9VBfA== X-Received: by 10.84.217.219 with SMTP id d27mr24582313plj.141.1496792741445; Tue, 06 Jun 2017 16:45:41 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::3:f879]) by smtp.gmail.com with ESMTPSA id u194sm60175680pgc.2.2017.06.06.16.45.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 16:45:40 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: Josef Bacik , Liu Bo , kernel-team@fb.com Subject: [PATCH 1/7] Btrfs: make add_pinned_bytes() take an s64 num_bytes instead of u64 Date: Tue, 6 Jun 2017 16:45:26 -0700 Message-Id: X-Mailer: git-send-email 2.13.0 In-Reply-To: References: In-Reply-To: References: 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 From: Omar Sandoval There are a few places where we pass in a negative num_bytes, so make it signed for clarity. Also move it up in the file since later patches will need it there. Signed-off-by: Omar Sandoval Reviewed-by: David Sterba Reviewed-by: Liu Bo --- fs/btrfs/extent-tree.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e390451c72e6..7c01b4e9e3b6 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -766,6 +766,26 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info, return NULL; } +static void add_pinned_bytes(struct btrfs_fs_info *fs_info, s64 num_bytes, + u64 owner, u64 root_objectid) +{ + struct btrfs_space_info *space_info; + u64 flags; + + if (owner < BTRFS_FIRST_FREE_OBJECTID) { + if (root_objectid == BTRFS_CHUNK_TREE_OBJECTID) + flags = BTRFS_BLOCK_GROUP_SYSTEM; + else + flags = BTRFS_BLOCK_GROUP_METADATA; + } else { + flags = BTRFS_BLOCK_GROUP_DATA; + } + + space_info = __find_space_info(fs_info, flags); + BUG_ON(!space_info); /* Logic bug */ + percpu_counter_add(&space_info->total_bytes_pinned, num_bytes); +} + /* * after adding space to the filesystem, we need to clear the full flags * on all the space infos. @@ -6793,27 +6813,6 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, return 0; } -static void add_pinned_bytes(struct btrfs_fs_info *fs_info, u64 num_bytes, - u64 owner, u64 root_objectid) -{ - struct btrfs_space_info *space_info; - u64 flags; - - if (owner < BTRFS_FIRST_FREE_OBJECTID) { - if (root_objectid == BTRFS_CHUNK_TREE_OBJECTID) - flags = BTRFS_BLOCK_GROUP_SYSTEM; - else - flags = BTRFS_BLOCK_GROUP_METADATA; - } else { - flags = BTRFS_BLOCK_GROUP_DATA; - } - - space_info = __find_space_info(fs_info, flags); - BUG_ON(!space_info); /* Logic bug */ - percpu_counter_add(&space_info->total_bytes_pinned, num_bytes); -} - - static int __btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_fs_info *info, struct btrfs_delayed_ref_node *node, u64 parent,