From patchwork Thu Nov 8 08:18:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10673667 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A989D15E9 for ; Thu, 8 Nov 2018 08:18:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C6062D5A0 for ; Thu, 8 Nov 2018 08:18:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DF4F2D5CF; Thu, 8 Nov 2018 08:18: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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 A4B4E2D5A0 for ; Thu, 8 Nov 2018 08:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbeKHRwc (ORCPT ); Thu, 8 Nov 2018 12:52:32 -0500 Received: from mx2.suse.de ([195.135.220.15]:35014 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726133AbeKHRwc (ORCPT ); Thu, 8 Nov 2018 12:52:32 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8499AADF4 for ; Thu, 8 Nov 2018 08:18:11 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 1/3] btrfs: Move epd::extent_locked check to writepage_delalloc's caller Date: Thu, 8 Nov 2018 10:18:06 +0200 Message-Id: <20181108081808.16920-2-nborisov@suse.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181108081808.16920-1-nborisov@suse.com> References: <20181108081808.16920-1-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 If epd::extent_locked is set then writepage_delalloc terminates. Make this a bit more apparent in the caller by simply bubbling the check up. This enables to remove epd as an argument to writepage_delalloc in a future patch. No functional change. Signed-off-by: Nikolay Borisov --- fs/btrfs/extent_io.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 46c299560f4f..e1ce07b2d33a 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3215,8 +3215,6 @@ static noinline_for_stack int writepage_delalloc(struct inode *inode, int ret; int page_started = 0; - if (epd->extent_locked) - return 0; while (delalloc_end < page_end) { nr_delalloc = find_lock_delalloc_range(inode, tree, @@ -3472,11 +3470,14 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc, set_page_extent_mapped(page); - ret = writepage_delalloc(inode, page, wbc, epd, start, &nr_written); - if (ret == 1) - goto done_unlocked; - if (ret) - goto done; + if (!epd->extent_locked) { + ret = writepage_delalloc(inode, page, wbc, epd, start, + &nr_written); + if (ret == 1) + goto done_unlocked; + if (ret) + goto done; + } ret = __extent_writepage_io(inode, page, wbc, epd, i_size, nr_written, write_flags, &nr); From patchwork Thu Nov 8 08:18:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10673671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACE93109C for ; Thu, 8 Nov 2018 08:18:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A06872BDA6 for ; Thu, 8 Nov 2018 08:18:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94CFD2D5A0; Thu, 8 Nov 2018 08:18:16 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 C70712D19E for ; Thu, 8 Nov 2018 08:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbeKHRwd (ORCPT ); Thu, 8 Nov 2018 12:52:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:35020 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726469AbeKHRwc (ORCPT ); Thu, 8 Nov 2018 12:52:32 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C8083ADFE for ; Thu, 8 Nov 2018 08:18:11 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 2/3] btrfs: Remove extent_page_data argument from writepage_delalloc Date: Thu, 8 Nov 2018 10:18:07 +0200 Message-Id: <20181108081808.16920-3-nborisov@suse.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181108081808.16920-1-nborisov@suse.com> References: <20181108081808.16920-1-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 The only remaining use of the 'epd' argument in writepage_delalloc is to reference the extent_io_tree which was set in extent_writepages. Since it is guaranteed that page->mapping of any page passed to writepage_delalloc (and __extent_writepage as the sole caller) to be equal to that passed in extent_writepages we can directly get the io_tree via the already passed inode (which is also taken from page->mapping->host). No functional changes. Signed-off-by: Nikolay Borisov --- fs/btrfs/extent_io.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index e1ce07b2d33a..cca9d3cbe74a 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3202,12 +3202,12 @@ static void update_nr_written(struct writeback_control *wbc, * This returns < 0 if there were errors (page still locked) */ static noinline_for_stack int writepage_delalloc(struct inode *inode, - struct page *page, struct writeback_control *wbc, - struct extent_page_data *epd, - u64 delalloc_start, - unsigned long *nr_written) + struct page *page, + struct writeback_control *wbc, + u64 delalloc_start, + unsigned long *nr_written) { - struct extent_io_tree *tree = epd->tree; + struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; u64 page_end = delalloc_start + PAGE_SIZE - 1; u64 nr_delalloc; u64 delalloc_to_write = 0; @@ -3471,8 +3471,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc, set_page_extent_mapped(page); if (!epd->extent_locked) { - ret = writepage_delalloc(inode, page, wbc, epd, start, - &nr_written); + ret = writepage_delalloc(inode, page, wbc, start, &nr_written); if (ret == 1) goto done_unlocked; if (ret) From patchwork Thu Nov 8 08:18:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10673669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1298E17D4 for ; Thu, 8 Nov 2018 08:18:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03ACA2BDA6 for ; Thu, 8 Nov 2018 08:18:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBD5B2D5BC; Thu, 8 Nov 2018 08:18: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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 5764C2BDA6 for ; Thu, 8 Nov 2018 08:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbeKHRwe (ORCPT ); Thu, 8 Nov 2018 12:52:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:35026 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726474AbeKHRwd (ORCPT ); Thu, 8 Nov 2018 12:52:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 26DADAE00 for ; Thu, 8 Nov 2018 08:18:12 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 3/3] btrfs: Remove unused extent_state argument from btrfs_writepage_endio_finish_ordered Date: Thu, 8 Nov 2018 10:18:08 +0200 Message-Id: <20181108081808.16920-4-nborisov@suse.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181108081808.16920-1-nborisov@suse.com> References: <20181108081808.16920-1-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 This parameter was never used, yet was part of the interface of the function ever since its introduction as extent_io_ops::writepage_end_io_hook in e6dcd2dc9c48 ("Btrfs: New data=ordered implementation"). Now that NULL is passed everywhere as a value for this parameter let's remove it for good. No functional changes. Signed-off-by: Nikolay Borisov --- fs/btrfs/compression.c | 6 ++++-- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/extent_io.c | 12 +++++------- fs/btrfs/inode.c | 7 +++---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index bde8d0487bbb..717d9300dd18 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -251,8 +251,10 @@ static void end_compressed_bio_write(struct bio *bio) tree = &BTRFS_I(inode)->io_tree; cb->compressed_pages[0]->mapping = cb->inode->i_mapping; btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0], - cb->start, cb->start + cb->len - 1, NULL, - bio->bi_status ? BLK_STS_OK : BLK_STS_NOTSUPP); + cb->start, + cb->start + cb->len - 1, + bio->bi_status ? + BLK_STS_OK : BLK_STS_NOTSUPP); cb->compressed_pages[0]->mapping = NULL; end_compressed_writeback(inode, cb); diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8b41ec42f405..c48fcaf4004d 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3179,7 +3179,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, struct btrfs_root *new_root, struct btrfs_root *parent_root, u64 new_dirid); -void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state, + void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state, unsigned *bits); void btrfs_clear_delalloc_extent(struct inode *inode, struct extent_state *state, unsigned *bits); @@ -3231,7 +3231,7 @@ int btrfs_run_delalloc_range(void *private_data, struct page *locked_page, struct writeback_control *wbc); int btrfs_writepage_cow_fixup(struct page *page, u64 start, u64 end); void btrfs_writepage_endio_finish_ordered(struct page *page, u64 start, - u64 end, struct extent_state *state, int uptodate); + u64 end, int uptodate); extern const struct dentry_operations btrfs_dentry_operations; /* ioctl.c */ diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index cca9d3cbe74a..f3bf7f9c13c0 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2408,7 +2408,7 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end) tree = &BTRFS_I(page->mapping->host)->io_tree; - btrfs_writepage_endio_finish_ordered(page, start, end, NULL, uptodate); + btrfs_writepage_endio_finish_ordered(page, start, end, uptodate); if (!uptodate) { ClearPageUptodate(page); @@ -3329,8 +3329,7 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode, end = page_end; if (i_size <= start) { - btrfs_writepage_endio_finish_ordered(page, start, page_end, - NULL, 1); + btrfs_writepage_endio_finish_ordered(page, start, page_end, 1); goto done; } @@ -3342,7 +3341,7 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode, if (cur >= i_size) { btrfs_writepage_endio_finish_ordered(page, cur, - page_end, NULL, 1); + page_end, 1); break; } em = btrfs_get_extent(BTRFS_I(inode), page, pg_offset, cur, @@ -3379,7 +3378,7 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode, if (!compressed) btrfs_writepage_endio_finish_ordered(page, cur, cur + iosize - 1, - NULL, 1); + 1); else if (compressed) { /* we don't want to end_page_writeback on * a compressed extent. this happens @@ -4066,8 +4065,7 @@ int extent_write_locked_range(struct inode *inode, u64 start, u64 end, ret = __extent_writepage(page, &wbc_writepages, &epd); else { btrfs_writepage_endio_finish_ordered(page, start, - start + PAGE_SIZE - 1, - NULL, 1); + start + PAGE_SIZE - 1, 1); unlock_page(page); } put_page(page); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a097f5fde31d..c3f540933238 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -852,8 +852,7 @@ static noinline void submit_compressed_extents(struct inode *inode, const u64 end = start + async_extent->ram_size - 1; p->mapping = inode->i_mapping; - btrfs_writepage_endio_finish_ordered(p, start, end, - NULL, 0); + btrfs_writepage_endio_finish_ordered(p, start, end, 0); p->mapping = NULL; extent_clear_unlock_delalloc(inode, start, end, end, @@ -3152,8 +3151,8 @@ static void finish_ordered_fn(struct btrfs_work *work) btrfs_finish_ordered_io(ordered_extent); } -void btrfs_writepage_endio_finish_ordered(struct page *page, u64 start, u64 end, - struct extent_state *state, int uptodate) +void btrfs_writepage_endio_finish_ordered(struct page *page, u64 start, + u64 end, int uptodate) { struct inode *inode = page->mapping->host; struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);