From patchwork Fri Feb 17 14:43:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 9579973 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 6A23F600F6 for ; Fri, 17 Feb 2017 14:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59D03286F6 for ; Fri, 17 Feb 2017 14:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EAF4286F8; Fri, 17 Feb 2017 14:44:15 +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 E9977286F4 for ; Fri, 17 Feb 2017 14:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934537AbdBQOoM (ORCPT ); Fri, 17 Feb 2017 09:44:12 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35089 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934530AbdBQOoK (ORCPT ); Fri, 17 Feb 2017 09:44:10 -0500 Received: by mail-wr0-f194.google.com with SMTP id q39so5487299wrb.2 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=YDTd7XjqdF9MlfLifmsBOydFyIWX0RnFgDPBRf7S1Js=; b=uBWFvFI6NbGAsaop9k5OgVJyVG6qzsaHjGf/yODE3aByx7yJT3w/EI/+bw7ROShsMZ +noVK69YQTpRK3KLoerSEfi/4HYVHtTAqv4YmOmqdo9fjerVccK0tMibpwE8iAQuVCEj uu8kKyq8Sr5csRJxY9AwYgrLJzX4jpUFW/MSYUwBR5V1zLFFW0reKHccv0TZDe4XITOI 8rQo8WtLnowslRpJtp0BdVTrD71IPyT7NYRhlEHk6F14x+5AYmDhMmpalL3eZFjDsBZE ojhzlO1JuBF7oG3x9racqVao5pMjcCm1K4ri8+nOWJqL6/0YOyjERl0CbP3xTtIqrAiO Kk6g== 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=YDTd7XjqdF9MlfLifmsBOydFyIWX0RnFgDPBRf7S1Js=; b=MnHNVFcQuYEBK9UwO+eO2HuyAVBXO49t6UfNRegcJccW1GUqnozlpY0n5NWo+0D7zd CAV3jENnGGwXvXhzq2Q0OJjHKP+r/iAQqYtlqlzf/1n6D2Q74PbZxdxxqzJh2ILN+LUt P3v2gpP0UMg3ruNLR7nZgCQ2QQKqd4gupNOCLIPuCAGijh9XjHxIEw4e9I1F6yE//O2M 9gs9HN6H7FlAyye8WFMqlH4erDhoVNzEcQNL7SZTs0UQXjI/PJnCe0Z0GWCNs/S+7B6Y brNMnG1ucepdjazHOV5w5DpkHgZ5n5DjjFh8KnaUr6rfmo9KbHWlw/CMyk9ducFi900e VPtw== X-Gm-Message-State: AMke39loFcjLbVMG5boxDOO2B0qhkRnNUKL0XXxzxqSEvvSRCWKY8nedisgqPUY0jRB4wg== X-Received: by 10.223.168.112 with SMTP id l103mr2154555wrc.184.1487342649181; Fri, 17 Feb 2017 06:44:09 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 06:44:08 -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 22/38] btrfs: Make lock_and_cleanup_extent_if_need take btrfs_inode Date: Fri, 17 Feb 2017 16:43:13 +0200 Message-Id: <1487342609-20652-23-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 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 8e223c78c8fe..2d534d6c5514 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1415,13 +1415,13 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages, * the other < 0 number - Something wrong happens */ static noinline int -lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages, +lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages, size_t num_pages, loff_t pos, size_t write_bytes, u64 *lockstart, u64 *lockend, struct extent_state **cached_state) { - 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 start_pos; u64 last_pos; int i; @@ -1432,30 +1432,29 @@ lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages, + round_up(pos + write_bytes - start_pos, fs_info->sectorsize) - 1; - if (start_pos < inode->i_size) { + if (start_pos < inode->vfs_inode.i_size) { struct btrfs_ordered_extent *ordered; - lock_extent_bits(&BTRFS_I(inode)->io_tree, - start_pos, last_pos, cached_state); - ordered = btrfs_lookup_ordered_range(BTRFS_I(inode), start_pos, + lock_extent_bits(&inode->io_tree, start_pos, last_pos, + cached_state); + ordered = btrfs_lookup_ordered_range(inode, start_pos, last_pos - start_pos + 1); if (ordered && ordered->file_offset + ordered->len > start_pos && ordered->file_offset <= last_pos) { - unlock_extent_cached(&BTRFS_I(inode)->io_tree, - start_pos, last_pos, + unlock_extent_cached(&inode->io_tree, start_pos, last_pos, cached_state, GFP_NOFS); for (i = 0; i < num_pages; i++) { unlock_page(pages[i]); put_page(pages[i]); } - btrfs_start_ordered_extent(inode, ordered, 1); + btrfs_start_ordered_extent(&inode->vfs_inode, ordered, 1); btrfs_put_ordered_extent(ordered); return -EAGAIN; } if (ordered) btrfs_put_ordered_extent(ordered); - clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, + clear_extent_bit(&inode->io_tree, start_pos, last_pos, EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 0, 0, cached_state, GFP_NOFS); @@ -1623,7 +1622,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, if (ret) break; - ret = lock_and_cleanup_extent_if_need(inode, pages, num_pages, + ret = lock_and_cleanup_extent_if_need(BTRFS_I(inode), pages, num_pages, pos, write_bytes, &lockstart, &lockend, &cached_state); if (ret < 0) {