From patchwork Fri Feb 17 14:43:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9579971 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 35E23600F6 for ; Fri, 17 Feb 2017 14:44:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25475286F4 for ; Fri, 17 Feb 2017 14:44:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18B2C286F6; Fri, 17 Feb 2017 14:44:14 +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 A09A1286F4 for ; Fri, 17 Feb 2017 14:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934533AbdBQOoK (ORCPT ); Fri, 17 Feb 2017 09:44:10 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35329 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934140AbdBQOoH (ORCPT ); Fri, 17 Feb 2017 09:44:07 -0500 Received: by mail-wm0-f65.google.com with SMTP id u63so2926033wmu.2 for ; Fri, 17 Feb 2017 06:44:06 -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=RqjcKaKCuugVIziKu3v1LunhcCTzjQOtWPcfV3ybRBs=; b=NRpslxtmu1t1T0tln5FHMFxf5M9ajpZ9BylX3fHh6pWovxQJHIHxee6v2rbzaPGFxv RouwshHrNNCldAjbXtK5z28e5CegkOjsR9C117Y1u23KdRvilzWa4Sdddxb6OxAydfwK 7L/q9JxNp3TEJ6G7ZeVuu1I4D/5M5aXdjLiRk0zZ0wj18SE6NmnRekzS1OCtdgURGqb0 PE9wsNIBC8yydz+9u9wPShlheVkFYz/CbdTorx/oSv9OhPmZbOWn5RpiGl1l1P2CRKIS hWgPa7I8FC9cx+9a7fpHWfVJ+FoFyt6i5XrYO+oQ7hQtvr6Mh8Rx1YOttG27Z8A5+1Dq fL0Q== 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=RqjcKaKCuugVIziKu3v1LunhcCTzjQOtWPcfV3ybRBs=; b=Zh6L1sHjiCFH7ZBy+JmEdcucEAtvpTeQrXpVI0VQ4Jn4P00+TmhZpxKkvgbxLx0gIj kmqsEUrPAXgaD6dkiKhvW0+rlUSODfrQDxJHo7sKDXMCbVN/X032vnOvofwIs40ybeuG u8NBwzc1741h9BI6iZuu0Sw9r3X2+cLTVJDsflWtIzSBtXo/g4x+hiyBrphBE6n/Nsq9 a6fAaoZwMnOzv4CBK6SLuUpD46sudotjO/eILAkkeKm1HbefrpV9IFvLdyAtQ2GSMirE nkCuM6Wt14JqnnSe2WLXm49ivYJt/CNBWISEHZnNXQDYUxI2xGkbl3Aqx418R0Z3h03E rrcg== X-Gm-Message-State: AMke39nf3zMu/0VReLZQyskiAVOfWdUHN6JJZO+jw0wWYTs+/i/bL3NfP8CBwjz2nZ18dw== X-Received: by 10.28.93.138 with SMTP id r132mr3998697wmb.17.1487342645306; Fri, 17 Feb 2017 06:44:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 06:44:04 -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 18/38] btrfs: Make fille_holes take btrfs_inode Date: Fri, 17 Feb 2017 16:43:09 +0200 Message-Id: <1487342609-20652-19-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/file.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 53fedf3dcaef..e37b643205e1 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2222,22 +2222,22 @@ static int hole_mergeable(struct btrfs_inode *inode, struct extent_buffer *leaf, return 0; } -static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode, +static int fill_holes(struct btrfs_trans_handle *trans, struct btrfs_inode *inode, struct btrfs_path *path, u64 offset, u64 end) { - struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); - struct btrfs_root *root = BTRFS_I(inode)->root; + struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); + struct btrfs_root *root = inode->root; struct extent_buffer *leaf; struct btrfs_file_extent_item *fi; struct extent_map *hole_em; - struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; + struct extent_map_tree *em_tree = &inode->extent_tree; struct btrfs_key key; int ret; if (btrfs_fs_incompat(fs_info, NO_HOLES)) goto out; - key.objectid = btrfs_ino(BTRFS_I(inode)); + key.objectid = btrfs_ino(inode); key.type = BTRFS_EXTENT_DATA_KEY; key.offset = offset; @@ -2253,7 +2253,7 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode, } leaf = path->nodes[0]; - if (hole_mergeable(BTRFS_I(inode), leaf, path->slots[0]-1, offset, end)) { + if (hole_mergeable(inode, leaf, path->slots[0]-1, offset, end)) { u64 num_bytes; path->slots[0]--; @@ -2268,7 +2268,7 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode, goto out; } - if (hole_mergeable(BTRFS_I(inode), leaf, path->slots[0], offset, end)) { + if (hole_mergeable(inode, leaf, path->slots[0], offset, end)) { u64 num_bytes; key.offset = offset; @@ -2285,7 +2285,7 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode, } btrfs_release_path(path); - ret = btrfs_insert_file_extent(trans, root, btrfs_ino(BTRFS_I(inode)), + ret = btrfs_insert_file_extent(trans, root, btrfs_ino(inode), offset, 0, 0, end - offset, 0, end - offset, 0, 0, 0); if (ret) return ret; @@ -2295,9 +2295,8 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode, hole_em = alloc_extent_map(); if (!hole_em) { - btrfs_drop_extent_cache(BTRFS_I(inode), offset, end - 1, 0); - set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, - &BTRFS_I(inode)->runtime_flags); + btrfs_drop_extent_cache(inode, offset, end - 1, 0); + set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &inode->runtime_flags); } else { hole_em->start = offset; hole_em->len = end - offset; @@ -2312,15 +2311,14 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode, hole_em->generation = trans->transid; do { - btrfs_drop_extent_cache(BTRFS_I(inode), offset, end - 1, 0); + btrfs_drop_extent_cache(inode, offset, end - 1, 0); write_lock(&em_tree->lock); ret = add_extent_mapping(em_tree, hole_em, 1); write_unlock(&em_tree->lock); } while (ret == -EEXIST); free_extent_map(hole_em); if (ret) - set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, - &BTRFS_I(inode)->runtime_flags); + set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &inode->runtime_flags); } return 0; @@ -2550,7 +2548,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) trans->block_rsv = &fs_info->trans_block_rsv; if (cur_offset < drop_end && cur_offset < ino_size) { - ret = fill_holes(trans, inode, path, cur_offset, + ret = fill_holes(trans, BTRFS_I(inode), path, cur_offset, drop_end); if (ret) { /* @@ -2622,7 +2620,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) * cur_offset == drop_end). */ if (cur_offset < ino_size && cur_offset < drop_end) { - ret = fill_holes(trans, inode, path, cur_offset, drop_end); + ret = fill_holes(trans, BTRFS_I(inode), path, cur_offset, drop_end); if (ret) { /* Same comment as above. */ btrfs_abort_transaction(trans, ret);