From patchwork Fri Feb 17 14:43:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9579995 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 72DAF600F6 for ; Fri, 17 Feb 2017 14:44:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6312B286F3 for ; Fri, 17 Feb 2017 14:44:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57FC6286F7; Fri, 17 Feb 2017 14:44:42 +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 D9C4D286F3 for ; Fri, 17 Feb 2017 14:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934464AbdBQOok (ORCPT ); Fri, 17 Feb 2017 09:44:40 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33542 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934302AbdBQOoW (ORCPT ); Fri, 17 Feb 2017 09:44:22 -0500 Received: by mail-wm0-f68.google.com with SMTP id v77so2937977wmv.0 for ; Fri, 17 Feb 2017 06:44:21 -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=Kxw5cdcjKuW4axn87xQo/jc2NuvzUVyASHaEOIfG9RY=; b=crq238tnQt1QB/wNrXSODgZ096ymccdZkjK4JU0hrWcLq4cTp3cgcZGI6B/ZMcAXbg Q+S3NFDH731+zISm76k6B3rImajEp3pv8Ome5EPNRO2TtCKYQ3YcrXbdCOZEo+brjoNB xEDZbsDWgPYrywYPfIBbhe5SVaNkDj+1rcV5P2Q4+OBMMGq4MhPp2IF/eT+54kGs9NVb RhMtHDoOxZ4na6ipeTL+Hg5d8nm35a25mZnZ1uIqPo8xyFsEd4vuNya9CkHEwxz8d78u YlpYf0AqbJBAthmm+wqrzit9rP7oW1KrehXDtVcDJRqKPYrNJ9nzuov+wCLUr549WcbP kYgw== 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=Kxw5cdcjKuW4axn87xQo/jc2NuvzUVyASHaEOIfG9RY=; b=R5KaWIett8grAn611xidzhL0sSKNJA8uyWH1k1dPdCjtleGBOK2WqZxZFjwW/yFZgd gMfnm1kI3NSDbw5EA4KvkseuQrHKHD475fILbG7+j1lpI2N+8M5tZLB+XF7OO3ErgPKv 9etVh7mPRGV1VHq19jZB2MUqRxJOm+mwe8KjAANe71y6m/egcstitllL31z5Y3Tq/bWs mHKWbu7mL/9G9myB2BoYCKvlHBB/eV+3Kj/5YbvqvB/dkPp01TcB5yVbEyMWLzwPNbsS Osx5StzeMu5RV6dXwUV8wHjInZ7vioFHg6dEmmTHavFHp8Hg6Z7mDzHouioVkIDGlT97 mSRA== X-Gm-Message-State: AMke39nw9cLuVkwbVAhXfMY1vWSF2zFXqSpA6Y3UJ7V87Fws4MoJXIFBdqqJGw5pVqu4+Q== X-Received: by 10.28.228.213 with SMTP id b204mr4102180wmh.59.1487342660503; Fri, 17 Feb 2017 06:44:20 -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.44.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 06:44:20 -0800 (PST) From: Nikolay Borisov X-Google-Original-From: Nikolay Borisov To: dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, Nikolay Borisov Subject: [PATCH 34/38] btrfs: Make btrfs_clear_bit_hook take btrfs_inode Date: Fri, 17 Feb 2017 16:43:25 +0200 Message-Id: <1487342609-20652-35-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 Signed-off-by: Nikolay Borisov --- fs/btrfs/extent_io.c | 2 +- fs/btrfs/extent_io.h | 3 ++- fs/btrfs/inode.c | 37 ++++++++++++++++++------------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index aecc3d87255e..fad5b2030c37 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -428,7 +428,7 @@ static void clear_state_cb(struct extent_io_tree *tree, struct extent_state *state, unsigned *bits) { if (tree->ops && tree->ops->clear_bit_hook) - tree->ops->clear_bit_hook(tree->mapping->host, state, bits); + tree->ops->clear_bit_hook(BTRFS_I(tree->mapping->host), state, bits); } static void set_state_bits(struct extent_io_tree *tree, diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index a6150f1be662..302e64be2e20 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -84,6 +84,7 @@ extern void le_bitmap_clear(u8 *map, unsigned int start, int len); struct extent_state; struct btrfs_root; +struct btrfs_inode; struct btrfs_io_bio; struct io_failure_record; @@ -107,7 +108,7 @@ struct extent_io_ops { struct extent_state *state, int uptodate); void (*set_bit_hook)(struct inode *inode, struct extent_state *state, unsigned *bits); - void (*clear_bit_hook)(struct inode *inode, struct extent_state *state, + void (*clear_bit_hook)(struct btrfs_inode *inode, struct extent_state *state, unsigned *bits); void (*merge_extent_hook)(struct inode *inode, struct extent_state *new, diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5545a49a3396..1ba412440979 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1706,18 +1706,18 @@ static void btrfs_set_bit_hook(struct inode *inode, /* * extent_io.c clear_bit_hook, see set_bit_hook for why */ -static void btrfs_clear_bit_hook(struct inode *inode, +static void btrfs_clear_bit_hook(struct btrfs_inode *inode, struct extent_state *state, unsigned *bits) { - struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); + struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); u64 len = state->end + 1 - state->start; u32 num_extents = count_max_extents(len); - spin_lock(&BTRFS_I(inode)->lock); + spin_lock(&inode->lock); if ((state->state & EXTENT_DEFRAG) && (*bits & EXTENT_DEFRAG)) - BTRFS_I(inode)->defrag_bytes -= len; - spin_unlock(&BTRFS_I(inode)->lock); + inode->defrag_bytes -= len; + spin_unlock(&inode->lock); /* * set_bit and clear bit hooks normally require _irqsave/restore @@ -1725,15 +1725,15 @@ static void btrfs_clear_bit_hook(struct inode *inode, * bit, which is only set or cleared with irqs on */ if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { - struct btrfs_root *root = BTRFS_I(inode)->root; - bool do_list = !btrfs_is_free_space_inode(BTRFS_I(inode)); + struct btrfs_root *root = inode->root; + bool do_list = !btrfs_is_free_space_inode(inode); if (*bits & EXTENT_FIRST_DELALLOC) { *bits &= ~EXTENT_FIRST_DELALLOC; } else if (!(*bits & EXTENT_DO_ACCOUNTING)) { - spin_lock(&BTRFS_I(inode)->lock); - BTRFS_I(inode)->outstanding_extents -= num_extents; - spin_unlock(&BTRFS_I(inode)->lock); + spin_lock(&inode->lock); + inode->outstanding_extents -= num_extents; + spin_unlock(&inode->lock); } /* @@ -1743,7 +1743,7 @@ static void btrfs_clear_bit_hook(struct inode *inode, */ if (*bits & EXTENT_DO_ACCOUNTING && root != fs_info->tree_root) - btrfs_delalloc_release_metadata(BTRFS_I(inode), len); + btrfs_delalloc_release_metadata(inode, len); /* For sanity tests. */ if (btrfs_is_testing(fs_info)) @@ -1753,18 +1753,17 @@ static void btrfs_clear_bit_hook(struct inode *inode, && do_list && !(state->state & EXTENT_NORESERVE) && (*bits & (EXTENT_DO_ACCOUNTING | EXTENT_CLEAR_DATA_RESV))) - btrfs_free_reserved_data_space_noquota(inode, + btrfs_free_reserved_data_space_noquota(&inode->vfs_inode, state->start, len); __percpu_counter_add(&fs_info->delalloc_bytes, -len, fs_info->delalloc_batch); - spin_lock(&BTRFS_I(inode)->lock); - BTRFS_I(inode)->delalloc_bytes -= len; - if (do_list && BTRFS_I(inode)->delalloc_bytes == 0 && - test_bit(BTRFS_INODE_IN_DELALLOC_LIST, - &BTRFS_I(inode)->runtime_flags)) - btrfs_del_delalloc_inode(root, inode); - spin_unlock(&BTRFS_I(inode)->lock); + spin_lock(&inode->lock); + inode->delalloc_bytes -= len; + if (do_list && inode->delalloc_bytes == 0 && + test_bit(BTRFS_INODE_IN_DELALLOC_LIST, &inode->runtime_flags)) + btrfs_del_delalloc_inode(root, &inode->vfs_inode); + spin_unlock(&inode->lock); } }