From patchwork Fri Feb 17 14:43:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9580011 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 CDDD0600F6 for ; Fri, 17 Feb 2017 14:45:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC666286F3 for ; Fri, 17 Feb 2017 14:45:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B16F8286F5; Fri, 17 Feb 2017 14:45:10 +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 434EF286F3 for ; Fri, 17 Feb 2017 14:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934153AbdBQOpI (ORCPT ); Fri, 17 Feb 2017 09:45:08 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36608 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934444AbdBQOoJ (ORCPT ); Fri, 17 Feb 2017 09:44:09 -0500 Received: by mail-wr0-f193.google.com with SMTP id z61so4718050wrc.3 for ; Fri, 17 Feb 2017 06:44:09 -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=BSAZNJo66SzAsm4UoBQaIPMuc4mH/DCxN1Id5tsyyjQ=; b=uXCyzNkZ8+pJJsPEyExEdQNlTtQTQMkqQOYAQtgHlMV26vP9+x+heiaRPsLXnnqF3/ mJH8OkiZF3Ck8JzMwC3pEB1YjyNEWUrPbZIR3/7FxxOBcnYwIL9/0uQZuy3RN9WXo+44 CvGZ7gsa0DhEQx6uG8lwKK2/os2+raWZWSEztv6slu8IKgYxVvUouABVmzdODv8VZArh nQUWTT4c2J0oZbVUgO9/TslgWgY2vxoy15PfYDei1yJBMGziuISQk352MhmUIH7Viver GSdcVzx9VNJRhvlW5HmAEgRFXKiNMlwUufkqzFExkBCtRgUxTlOAXC9nNnma0gJ+e8kV p69Q== 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=BSAZNJo66SzAsm4UoBQaIPMuc4mH/DCxN1Id5tsyyjQ=; b=E52dEeM3KceE8pVaOPhCfdoHs0XZM7sIPXmFmGiwUTelH6m1BoWS+sKJvL1WNzwy6D AKDurTUORI9J9ccwRsWHoiM1BPlBx+HuQ4isYqb0DJBf4rflP3ORA6nJurjAuhEYZDJj nBuWE2kR7gB0hSuMafEJZHLNI/+IBQ3TU7FZCCrn/YxQ5jbqxNMSk8BCftRI9HGNjrXd Gx025hHMYOm1l8mt0YNalaz/bz6ICQDWcZzlRN+SKnXuyeJCtBsTgw6xY/+w1S0xiCHU VjfIX4JSaWUFFWsEtsaNiMC/EwOwZK4mw4CPpyV5JNlDGJn5YrVjEe+OScvUpeHWs4dg BWjQ== X-Gm-Message-State: AMke39kTVY0jKv4lyAr0Gw32LBIxOBh+m6E4auK9YPiUbGA7NgX2fVXHYTKUXRHZ8h7fLQ== X-Received: by 10.223.164.151 with SMTP id g23mr6950211wrb.86.1487342648275; Fri, 17 Feb 2017 06:44:08 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 06:44:07 -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 21/38] btrfs: Make check_can_nocow take btrfs_inode Date: Fri, 17 Feb 2017 16:43:12 +0200 Message-Id: <1487342609-20652-22-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 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index c12d7308205b..8e223c78c8fe 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1474,11 +1474,11 @@ lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages, return ret; } -static noinline int check_can_nocow(struct inode *inode, loff_t pos, +static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos, size_t *write_bytes) { - 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 btrfs_ordered_extent *ordered; u64 lockstart, lockend; u64 num_bytes; @@ -1493,19 +1493,19 @@ static noinline int check_can_nocow(struct inode *inode, loff_t pos, fs_info->sectorsize) - 1; while (1) { - lock_extent(&BTRFS_I(inode)->io_tree, lockstart, lockend); - ordered = btrfs_lookup_ordered_range(BTRFS_I(inode), lockstart, + lock_extent(&inode->io_tree, lockstart, lockend); + ordered = btrfs_lookup_ordered_range(inode, lockstart, lockend - lockstart + 1); if (!ordered) { break; } - unlock_extent(&BTRFS_I(inode)->io_tree, lockstart, lockend); - btrfs_start_ordered_extent(inode, ordered, 1); + unlock_extent(&inode->io_tree, lockstart, lockend); + btrfs_start_ordered_extent(&inode->vfs_inode, ordered, 1); btrfs_put_ordered_extent(ordered); } num_bytes = lockend - lockstart + 1; - ret = can_nocow_extent(inode, lockstart, &num_bytes, NULL, NULL, NULL); + ret = can_nocow_extent(&inode->vfs_inode, lockstart, &num_bytes, NULL, NULL, NULL); if (ret <= 0) { ret = 0; btrfs_end_write_no_snapshoting(root); @@ -1514,7 +1514,7 @@ static noinline int check_can_nocow(struct inode *inode, loff_t pos, num_bytes - pos + lockstart); } - unlock_extent(&BTRFS_I(inode)->io_tree, lockstart, lockend); + unlock_extent(&inode->io_tree, lockstart, lockend); return ret; } @@ -1579,7 +1579,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, if (ret < 0) { if ((BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | BTRFS_INODE_PREALLOC)) && - check_can_nocow(inode, pos, &write_bytes) > 0) { + check_can_nocow(BTRFS_I(inode), pos, &write_bytes) > 0) { /* * For nodata cow case, no need to reserve * data space.