From patchwork Fri Feb 17 14:42:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9580027 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 7F5F8600F6 for ; Fri, 17 Feb 2017 14:45:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E160286F5 for ; Fri, 17 Feb 2017 14:45:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61B87286F7; Fri, 17 Feb 2017 14:45:52 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 02A41286F5 for ; Fri, 17 Feb 2017 14:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934291AbdBQOpu (ORCPT ); Fri, 17 Feb 2017 09:45:50 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35241 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934391AbdBQOoB (ORCPT ); Fri, 17 Feb 2017 09:44:01 -0500 Received: by mail-wm0-f66.google.com with SMTP id u63so2925230wmu.2 for ; Fri, 17 Feb 2017 06:43:56 -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:in-reply-to:references; bh=Il5MXbXaFLhVXWbFgYMXL2fTDW4iB6cZPHiHi6pL+m0=; b=nvmjnn54JSHJzynRNFTlwPVOfMHdoE5pcH9ug14cSmcNkNHAwcVwKD/pJbXllfMkZo AI2YeZdFzU7pJDK4pvtpMrRg0oatAb9RPHTYeFfswPypZw8D5dHkndeym57o+WSK7/1h 9iblq+BshH0Wp7+onAWSSdSIKPb2IjLOfyGifNzrFbFFKflCnf+tGTWV7qhPtjXumyor VjTX36EZq1atew3rpo81owzrqT+W3Ycs/l66UXkPgO0LzWjiUEwAFUQx5iU3B1vKo7nl xhdipNOEL938ou3dZ6rg0JrLpy3rglmKtjXdZL38e7uqr1gooTNYwOHBzg4Gai40CvLe 1maw== 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; bh=Il5MXbXaFLhVXWbFgYMXL2fTDW4iB6cZPHiHi6pL+m0=; b=MgOdpLl9LrPacjcGWNcyehpCcPujU6w4XcbqemDOfOiQ9ESUadWG4ckusMZF8+58xd GAewz4I4qUE9xLLT79Rk4MDkucwqEVi4fXD/twfVJOaggLFh9CDi1RZmM+ujKQ8rT53C SDaXtlI7UcZnPJSA6Qmhqi2yyTV8/kXnB3fD6/5mhUQR4Qab8JxS98t/fo2PaQKc/UvG cT3n3wpuQOjqxmxLBJucC2KvGLmDFjjS5ugBPV9uoyQQBZ5TYKBzPdDg31oki3PAI/bZ IrFwSjksjrO40mkkz7OX+amxyl/GipVGHTdmylSWCb/jm1y9C5cQADQbexUoFZggvwSy jm0w== X-Gm-Message-State: AMke39mRbe2ObRHRUqkmjyV4mFSLMwkSIPEcEGJgqLJJBHegIsSuARqhIgzIwYNQvv5cTQ== X-Received: by 10.28.169.142 with SMTP id s136mr3950599wme.9.1487342635395; Fri, 17 Feb 2017 06:43:55 -0800 (PST) Received: from fisk.suse.de (ivokamhome.ddns.nbis.net. [87.120.136.31]) by smtp.gmail.com with ESMTPSA id y126sm1932713wmg.19.2017.02.17.06.43.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 06:43:54 -0800 (PST) From: Nikolay Borisov X-Google-Original-From: Nikolay Borisov To: dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, Nikolay Borisov , Nikolay Borisov Subject: [PATCH 08/38] btrfs: Make drop_outstanding_extent take btrfs_inode Date: Fri, 17 Feb 2017 16:42:59 +0200 Message-Id: <1487342609-20652-9-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487342609-20652-1-git-send-email-nborisov@suse.com> References: <1487342609-20652-1-git-send-email-nborisov@suse.com> 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: Nikolay Borisov Signed-off-by: Nikolay Borisov --- fs/btrfs/extent-tree.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 293ca5d34d44..74bfaf222973 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -5846,7 +5846,7 @@ void btrfs_subvolume_release_metadata(struct btrfs_fs_info *fs_info, * reserved extents that need to be freed. This must be called with * BTRFS_I(inode)->lock held. */ -static unsigned drop_outstanding_extent(struct inode *inode, u64 num_bytes) +static unsigned drop_outstanding_extent(struct btrfs_inode *inode, u64 num_bytes) { unsigned drop_inode_space = 0; unsigned dropped_extents = 0; @@ -5854,25 +5854,24 @@ static unsigned drop_outstanding_extent(struct inode *inode, u64 num_bytes) num_extents = count_max_extents(num_bytes); ASSERT(num_extents); - ASSERT(BTRFS_I(inode)->outstanding_extents >= num_extents); - BTRFS_I(inode)->outstanding_extents -= num_extents; + ASSERT(inode->outstanding_extents >= num_extents); + inode->outstanding_extents -= num_extents; - if (BTRFS_I(inode)->outstanding_extents == 0 && + if (inode->outstanding_extents == 0 && test_and_clear_bit(BTRFS_INODE_DELALLOC_META_RESERVED, - &BTRFS_I(inode)->runtime_flags)) + &inode->runtime_flags)) drop_inode_space = 1; /* * If we have more or the same amount of outstanding extents than we have * reserved then we need to leave the reserved extents count alone. */ - if (BTRFS_I(inode)->outstanding_extents >= - BTRFS_I(inode)->reserved_extents) + if (inode->outstanding_extents >= inode->reserved_extents) return drop_inode_space; - dropped_extents = BTRFS_I(inode)->reserved_extents - - BTRFS_I(inode)->outstanding_extents; - BTRFS_I(inode)->reserved_extents -= dropped_extents; + dropped_extents = inode->reserved_extents - + inode->outstanding_extents; + inode->reserved_extents -= dropped_extents; return dropped_extents + drop_inode_space; } @@ -6015,7 +6014,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) out_fail: spin_lock(&BTRFS_I(inode)->lock); - dropped = drop_outstanding_extent(inode, num_bytes); + dropped = drop_outstanding_extent(BTRFS_I(inode), num_bytes); /* * If the inodes csum_bytes is the same as the original * csum_bytes then we know we haven't raced with any free()ers @@ -6094,7 +6093,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes) num_bytes = ALIGN(num_bytes, fs_info->sectorsize); spin_lock(&BTRFS_I(inode)->lock); - dropped = drop_outstanding_extent(inode, num_bytes); + dropped = drop_outstanding_extent(BTRFS_I(inode), num_bytes); if (num_bytes) to_free = calc_csum_metadata_size(inode, num_bytes, 0);