From patchwork Thu Feb 13 15:57:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11380657 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 487201395 for ; Thu, 13 Feb 2020 15:58:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27CA9217F4 for ; Thu, 13 Feb 2020 15:58:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="WpNDW72b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388205AbgBMP6T (ORCPT ); Thu, 13 Feb 2020 10:58:19 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:60885 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728336AbgBMP6O (ORCPT ); Thu, 13 Feb 2020 10:58:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581609541; x=1613145541; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FXI3x3SaaDXEeOo7oRhcIQP8lMflANgTphvOQOyVA3k=; b=WpNDW72b+wBFgYOh+o4V28IZDrwABwrdDQxqTkXDs3woPb7gBAqE4TRD 9iA0SCu+VF7t+wHuXMEJi3nrnkJRpNi30pKfUUaWbbjGW7qys2j1SKbSU oSwlUhpDVFn2p/+5V9xOyt1oYYn2Mkd6vDqxAnZayrHWrAdECt7F9uAJ3 HpS1LSeyh3lmhUpU4rlq9wTAndublGIH+vow9QgKgqODqOUcAvpH1dpQ5 XG64TGMcZcC/Hmlj+6HkdC4QZ0+rxbgKeYFzIpH0qsv+33gRHN39kThlx 3S8zYa02VSuqy0O9Yi50WRQ+huCee4IS9EuglAKHjpOb0haMHVFRhrxND A==; IronPort-SDR: HF6NxTz+9h8n16+OhAKSrrWpZ+1dymA7kT7lOvgS6p199wkoY96xQfPkbrELyCdwaKNCfZsJLq 1jMNvrNAf+NU4/VxpMjiMEmd96SzNC/zvMws7s3AJGIXKBfh9M36rtk/eldfnzy/E4T6gZ3Hqf b4abQtNp7uHl4MDJvEnAs5PR1qY4fmzNwO0oBufXMmTqSOYcPr8KrtrEqHMHaIAHcJM48imVHw p/1+g5Kj4bo8QWQTXqycjA5uL1cpimKqYAsb6+G7cUr6RbVZTb/BCG+7Vwu4NDwWcI71TB5myq fao= X-IronPort-AV: E=Sophos;i="5.70,437,1574092800"; d="scan'208";a="231587562" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2020 23:59:01 +0800 IronPort-SDR: wJirmjZIGI1ov/M/XQyAq4dvvLGass54GyOkHhQW9DTQf6DCsuSmtbUZjjgtP4SjsRcnomqkJg n9o368sRB3ZJfxEEzcRy04NWv73e+UOZ/1iHT5eNpc2QbPTOmaQ2sUwbrn2k1P99bdXU34w8o5 mXWAO5W8Y3uSj/wjPN8z1+6rtympptGQu3QJ/evRvgpK5nkJRn/NfZEz49ZpCAqmJi+IzsGW+3 mjETxU3IlfIQnmzojmRxAVaM3PVsa95ecPkIeoPiXqzzEilOe1y2Yk7MmHaFhFCYjfcbwG+6jU HctOl7++5S0HOlc4gbSGRP5L Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 07:51:02 -0800 IronPort-SDR: 3rta8Clgt7AmycDpzslvwwx8LvQK9QfFEh0HgYfTcwvYBnx3X9Gan7KYW1sTg0MXYSc6pOOO79 7ThzjCg5EsucIn917Amzq0XcJTo9QQD5/Oy70WXMrSxMUoy8FJqD2GTqrgxluHLuj7tMLdj8Us jhueZPXJPs1mwaxVhV7jKYfjGoc8WAXZTfmpJxtFEwXIFdROiQOYCe3DQ1tTniBjtvIgAe0qAK 1mEzmj04JUBJUgCGA8emzCgjMX/02FR54ZgVEF+0k2UJrMAL8vrECGO9/KehUXyRQBfb6XHoOy Ekc= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Feb 2020 07:58:14 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH v2 1/5] btrfs: free allocated pages on failed cache write-out Date: Fri, 14 Feb 2020 00:57:59 +0900 Message-Id: <20200213155803.14799-2-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213155803.14799-1-johannes.thumshirn@wdc.com> References: <20200213155803.14799-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org When we fail to write out a dirty block group, we leak the pages allocated for a block-group's io_ctl. This can be seen with generic/475 and kmemleak turned on: unreferenced object 0xffff8882249c9000 (size 128): comm "fsstress", pid 1791, jiffies 4294902054 (age 32.100s) hex dump (first 32 bytes): 80 0e 42 08 00 ea ff ff 00 0d 42 08 00 ea ff ff ..B.......B..... 00 eb 0e 08 00 ea ff ff 00 e8 0e 08 00 ea ff ff ................ backtrace: [<00000000cd20c449>] io_ctl_init+0xa2/0x110 [btrfs] [<00000000281944cc>] __btrfs_write_out_cache+0x71/0x410 [btrfs] [<000000005d518c07>] btrfs_write_out_cache+0x82/0xd0 [btrfs] [<000000002bb2675c>] btrfs_start_dirty_block_groups+0x1f6/0x440 [btrfs] [<000000004f955ad0>] btrfs_commit_transaction+0xb7/0x970 [btrfs] [<00000000a69c8761>] btrfs_sync_file+0x28f/0x390 [btrfs] [<00000000fa939e06>] do_fsync+0x33/0x70 [<000000002ff0388b>] __x64_sys_fdatasync+0xe/0x20 [<00000000fdbf32d4>] do_syscall_64+0x43/0x120 [<00000000b782d265>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 When cleaning up a block group release all allocated pages. As the data in the pages is already lost, we can at least free the memory occupied by them. Signed-off-by: Johannes Thumshirn --- fs/btrfs/disk-io.c | 6 ++++++ fs/btrfs/free-space-cache.c | 6 ++++++ fs/btrfs/free-space-cache.h | 1 + 3 files changed, 13 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 018681ec159b..b79c194b1126 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4460,6 +4460,12 @@ static void btrfs_cleanup_bg_io(struct btrfs_block_group *cache) { struct inode *inode; + /* + * If we end up here, we want the pages to be already released + * otherwise we'll leak them. + */ + btrfs_drop_dirty_io_ctl(&cache->io_ctl); + inode = cache->io_ctl.inode; if (inode) { invalidate_inode_pages2(inode->i_mapping); diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 0598fd3c6e3f..3c7660b04a81 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -371,6 +371,12 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl) } } +void btrfs_drop_dirty_io_ctl(struct btrfs_io_ctl *io_ctl) +{ + io_ctl_drop_pages(io_ctl); + io_ctl_free(io_ctl); +} + static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, struct inode *inode, int uptodate) { diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h index 2e0a8077aa74..cbe25c31041d 100644 --- a/fs/btrfs/free-space-cache.h +++ b/fs/btrfs/free-space-cache.h @@ -147,6 +147,7 @@ int btrfs_trim_block_group_extents(struct btrfs_block_group *block_group, int btrfs_trim_block_group_bitmaps(struct btrfs_block_group *block_group, u64 *trimmed, u64 start, u64 end, u64 minlen, u64 maxlen, bool async); +void btrfs_drop_dirty_io_ctl(struct btrfs_io_ctl *io_ctl); /* Support functions for running our sanity tests */ #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS From patchwork Thu Feb 13 15:58:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11380665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E214D1395 for ; Thu, 13 Feb 2020 15:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C147420675 for ; Thu, 13 Feb 2020 15:58:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="q437U6wk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728336AbgBMP6U (ORCPT ); Thu, 13 Feb 2020 10:58:20 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:60885 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728442AbgBMP6R (ORCPT ); Thu, 13 Feb 2020 10:58:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581609544; x=1613145544; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ocD1DeGcrpk7hS1e3Dd2W5x9nZUmy/dSs27jsyp3PDc=; b=q437U6wkRUGjXkT5tyPQuDPS+9R+N4PFE12kzJ2LhFdP2mLwo1MBL2dP zxaklNrR3PSutmUpxvkYlkUWA9hHaCIvll0y8wsLON70BNxRiLPMR+dVG 9/1nIe3crHvGqeV4EYPw/wrMQpUm3jbrrhavxJd6IF7tJIsifmrasS434 h5sEmKgelfianx0NH2K+AuLqk9qNsijjmg9J0W3yTts0ykDe2cS8bL72q IWeFVMHv8F3hj/X4eJs5iEl4aknqDAJlGGXlmz3LwB9P3MbCShudSWceU YQ3wCfYp0E+UoMLZUYX/K2+fmaXzSx/mjBjKwqgPIVnq0bX+oDFS9Jebl A==; IronPort-SDR: 6y+saXc/QzEaBaUjRrWkVaqyR3FK1New2t+qPkBbFwTfm7pKASa6D4tH4tJmR3hfjMNWo0qCIw H5cQXkGveHYkOT6gccUmlFGeyZbLwYOk5t3KDfab5ilhN6SVK+9GV73rYaYWiLLm5HB42KCZqK 8gJRJ45VKR6qhMrSRZR85A322M8kHb9YlKMxnXDG/6T51UcYVy/lOBgbTK3UYxoOmPswzvBpoN cPKo9nxwLTPTW/4SBMP5FHA0QUsQxi0EVM4RewHOFn7edVOP8PNitQSc5zYDzI2xYdOUpSryOZ Dzk= X-IronPort-AV: E=Sophos;i="5.70,437,1574092800"; d="scan'208";a="231587565" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2020 23:59:02 +0800 IronPort-SDR: k13ykpgjrq+BbqmKRhcXQOtnlerfS5npsKuaaQfnidEPCgBdi3zD4utB5v5YH9NMViUXsa3FIV xVAEnWxw3VhcKiYcrVx9D0x/ctLqbxggtG69AQkZQuSG0DBq9Djs3raLyX/M27o9ycrEmOZy1C 6fdOCYw9Z5uZDhKACCKy6O/RBAI0qR5ERjYbtcHJo3koya9HCNTg0A5YomQ3Vud6nu2FqArufH 1L1SyWMZRYcpARcSphaMGZQ+h3OJLXK0MgIk6i7LtnpukMrtClTq/KQqQ/kUTxZXxrrUu6s9KR dJfWV00fjOWOdSEyd9jO3xds Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 07:51:02 -0800 IronPort-SDR: fDOL8Q4qjZnLgA/WpVCC9iikbUvSIijRn/QRGeodiE8Fm7ZZR5e4Gl4pODUpFo00mVMUm/FAQv MdkYx2C58QeQrYBYL9YyZlChy6Exx3JlbVDlTdt/aQ1q899JLJ1FeoRPCbeaX0KIJzJ3ybdix9 NPKOUlwDcGl0cvDAX1CkDif9P1wcDp25SjUEzcPIBcn4KWV+B4QU2zQNvtn4q4NvTHsydH1qB2 1uH0BxDmnyb2Ri5BPVKOGE2hOaGt+Oj/unIGTEmdSg3xVyJJBxsVCWG5Dflh2yu3Dos5BMhXn7 6lo= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Feb 2020 07:58:15 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH v2 2/5] btrfs: use inode from io_ctl in io_ctl_prepare_pages Date: Fri, 14 Feb 2020 00:58:00 +0900 Message-Id: <20200213155803.14799-3-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213155803.14799-1-johannes.thumshirn@wdc.com> References: <20200213155803.14799-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org io_ctl_prepare_pages() get's a 'struct btrfs_io_ctl' as well as a 'struct inode', but btrfs_io_ctl::inode points to the same struct inode as this is assgined in io_ctl_init(). Use the inode form io_ctl to reduce the arguments of io_ctl_prepare_pages(). Signed-off-by: Johannes Thumshirn --- fs/btrfs/free-space-cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 3c7660b04a81..657a969a93ad 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -377,10 +377,10 @@ void btrfs_drop_dirty_io_ctl(struct btrfs_io_ctl *io_ctl) io_ctl_free(io_ctl); } -static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, struct inode *inode, - int uptodate) +static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, int uptodate) { struct page *page; + struct inode *inode = io_ctl->inode; gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping); int i; @@ -738,7 +738,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, readahead_cache(inode); - ret = io_ctl_prepare_pages(&io_ctl, inode, 1); + ret = io_ctl_prepare_pages(&io_ctl, 1); if (ret) goto out; @@ -1297,7 +1297,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, } /* Lock all pages first so we can lock the extent safely. */ - ret = io_ctl_prepare_pages(io_ctl, inode, 0); + ret = io_ctl_prepare_pages(io_ctl, 0); if (ret) goto out_unlock; From patchwork Thu Feb 13 15:58:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11380659 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5E3313A4 for ; Thu, 13 Feb 2020 15:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 948E0217F4 for ; Thu, 13 Feb 2020 15:58:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Upwu5Xo/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388219AbgBMP6W (ORCPT ); Thu, 13 Feb 2020 10:58:22 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:60891 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729158AbgBMP6R (ORCPT ); Thu, 13 Feb 2020 10:58:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581609544; x=1613145544; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=325QAbuPh1UjGuykfs465BipbXIHHvqK9iVL+yKUCXc=; b=Upwu5Xo/eUPtBLsW7e7lP+uhuUgYrw2It8TTvs36jWVyqYywxW85KdmS qCD1e/ZDZMT/r5mDlxLRWAYYzP3SLw+FnY/UmmZBajVYP+d3ZPwTRmi7Z pHjuJw5VrLwLPBQdaO3gDnkJ1jypITT85N5P6OApnzSi9dbahVkf9ItI9 9V0j2CO2YG7CoT9KpZg2YM8Xru5yOL6adL1kolSUzU+AA6wvyz5Q3ujSn 2Bd2jrfn+FEMEj/6bXtQF0TdGXPSIPNNEc8D5skO5dN0OyUcEbhd2BjdR GUB1YPhicDIZQWuEo344ns+tQ69WhsDhZ9Vv6DVeERfLot3BuQf5HfH1h g==; IronPort-SDR: FBbdBF4jyf9N2h/YO42+eZJ1whGedF8RSfgGA1HUQr/2gqMvEu+q4YAIwXc/yV1Fge7oaFFzO1 z8qW0nxI3AjyBYIlBip72xsT+zAPvoPWQOpGf39hyBJlMIHwBzgNUNQi3HE3DZNuJIZsZsU4PV js3w4bKK2FJ6ERHl1ghdTgzuhXeLN9i3xcgrLTdrUdlFsAjB89NysMzO8/aUHTGQO3gPn4ghbt 4n/KUMZTsU3a/81xTC4masKlJb797fWWZjPJ6VuIUBKZM4mJqpw/trX81GWjYHuLYOmLtxzVTu Sf0= X-IronPort-AV: E=Sophos;i="5.70,437,1574092800"; d="scan'208";a="231587566" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2020 23:59:03 +0800 IronPort-SDR: MoRVJ1vxXEVgfZqNeV4VzvcZD4GKNbxD3gAcsr6OsMFs7P9FjpRp8uKYYO9CjMoue2MOmK9NVB /4Hk4QkMaTCAsF89D6K0RcFAzlmJcjaRhFYCJcF+INDMnvoDKD9mhZ+WhiKvjGaO0KTquofOWc wnSIWm50VbnQHf4nKGRp86OAYbAQ6ZAoUPB6htbMQLHuKKPSz+6YYbwXZSvrlm5HWqJMlPaJUk 6ab2b1tCDDROGAX86EhcM9ldC9liqFQUWh7wTJHCxxY4+nh7J4ZzJCxJvvGX4TZW7IZ3zhzLxk UPfBAPSOkLW4M2+2LZcoE2Z5 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 07:51:03 -0800 IronPort-SDR: GxkJRVeZVQwgwpex4FnDcH4HltvvxtDk/jYbLgklIfPc9E9fOL8MAjI0tEmD1swZ3zmJWXH+FJ lcJjAme4927PvMAc6uzCnqoxmd3VrGdGB9kJ3mGeyQUUG3d8Z9Je+5MU45jGZ4GIGuHVWDtx52 s0/55QCjpDRlthlQnpCdlgANbwMfl5ZHrKbLriozsw8ApD+I3t3iaaeTSFggT6b0lN+bnz4f0M QMg0sTYrg+/g5ej4TwezQXKsP2EOI+fw3RIu017HhFeR75i76cN1vvMGcx4DRo5Y1OIHE5hDKZ z7A= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Feb 2020 07:58:15 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH v2 3/5] btrfs: make the uptodate argument of io_ctl_add_pages() boolean. Date: Fri, 14 Feb 2020 00:58:01 +0900 Message-Id: <20200213155803.14799-4-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213155803.14799-1-johannes.thumshirn@wdc.com> References: <20200213155803.14799-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Make the uptodate argument of io_ctl_add_pages() boolean. Signed-off-by: Johannes Thumshirn --- fs/btrfs/free-space-cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 657a969a93ad..8da592eaf6f8 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -377,7 +377,7 @@ void btrfs_drop_dirty_io_ctl(struct btrfs_io_ctl *io_ctl) io_ctl_free(io_ctl); } -static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, int uptodate) +static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate) { struct page *page; struct inode *inode = io_ctl->inode; @@ -738,7 +738,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, readahead_cache(inode); - ret = io_ctl_prepare_pages(&io_ctl, 1); + ret = io_ctl_prepare_pages(&io_ctl, true); if (ret) goto out; @@ -1297,7 +1297,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, } /* Lock all pages first so we can lock the extent safely. */ - ret = io_ctl_prepare_pages(io_ctl, 0); + ret = io_ctl_prepare_pages(io_ctl, false); if (ret) goto out_unlock; From patchwork Thu Feb 13 15:58:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11380661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78E8213A4 for ; Thu, 13 Feb 2020 15:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58AC5217F4 for ; Thu, 13 Feb 2020 15:58:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="EkI9ZQt/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728950AbgBMP6W (ORCPT ); Thu, 13 Feb 2020 10:58:22 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:60892 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387438AbgBMP6R (ORCPT ); Thu, 13 Feb 2020 10:58:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581609545; x=1613145545; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7ZeCHCcflvcCwv6jgAyyLcuEDPIhjPzAQPoXSRPeNe4=; b=EkI9ZQt//WHcbMQJ+VQ4XB3MMbz8wJ3fpFSvn+BT2AzzizPB2rJ/V3lC Mt0HDTvOFNpCoVg4oM/Y193dFmsCDzzQjz0vLJxlHwdYoifa9qjehWPvz ECwG/0A++X7lYyowUgJkekFIM5yV17D3KKLIdBDrziEbJRpfusl9Xxawo 1MpYxxOYtIIrR8hX39dJxSJuls8NYDbuJ3ABls/yuupR/P38qoD+Zc8wx MhYpB5Qztz4pOayZosgkr5CPJRjYN2FF9fGSX0HScLGwH1t7nN9uEJ3eN e5PDZqbQexbDSLezm86oSFNKjF3jnjTOnfp5l0H1KeeRhcIxUN4iW/OJZ A==; IronPort-SDR: mJrbBV3O0BkVM+ToMXh6QcMS2op0jCgTLzisQotdPbHBNrG6gITHGuy6tV5QgiVgw2zc+/Ks/T efkqYaeKs/SLCKkHFfME10eXKCy4C29D1SIeJKh5E74qCCCix68HvpVSyO2zGTxYS3vOJI/zxE BaXV/pa1o1UTYjVuYYw80C01bbCMIS3r/nLv0oPSnLaJ2uxTVAjs5SrTlGzXrZ8pCsete4kGvq /rNdF4ohecJmXkH2WunBTPDuuiH6hAtBrBrWmVoFSNUuTcwKLKvTZ99tljAqyUvldOUglHdkLs NUY= X-IronPort-AV: E=Sophos;i="5.70,437,1574092800"; d="scan'208";a="231587568" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2020 23:59:05 +0800 IronPort-SDR: YPd/0CNHMtKWy96xf89gcShUlPvm8KuyzlCC2CbHbE6Wi28gCmm2tDUq7vcIKTjO8bOK8IfzRv C2g8mXZwmgD5BBioYti29hh5+exWml4hLiM+K8br5arx2IE7A9rJUL2Ff/ISJ1elXAlm1+jCIH 99oOXNglw86/vTCnmeyqHncU8APt4MbKr74admpWETtE0wVghHo8FMr31VRH/I3sdDvHDrVBww XK3uuFrbKLBej+6opJiHH7ys9HU146mehjPBNvCxWlBBiGtxhBmPvHt/CtsDu7+iiL3tAL60VB TXWs1cgsr6f3O1pTxSvH+wjA Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 07:51:04 -0800 IronPort-SDR: zM7u0nseUHMuVQtvKiHbzDcOqUSa/nqJDIFgAlkJYbJFdZxrh+31gx4/MaIW2W4tHfAjhmbfJs SQkQkkbHncKIL3k1ssNZzUC5lSlrg7I+zo1Acbjhmnj5F6uP4gik4hOWX2GfnlS2T5mzrJLpf8 Psw5JW+1Xr0SWL/5Fr3baL6oXCHsJUwxwNCNHewbrbPpc8NnrPs0L/2PDGHTO1OjwGCT0PBXkq 8DBkIiiDM6m9yOzUWwri/6IvrpvT+zHa12qbJhvtQHhVGik0vzI2MywWTUXHajd1R3JxSXlZgx 7Mo= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Feb 2020 07:58:16 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH v2 4/5] btrfs: use standard debug config option to enable free-space-cache debug prints Date: Fri, 14 Feb 2020 00:58:02 +0900 Message-Id: <20200213155803.14799-5-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213155803.14799-1-johannes.thumshirn@wdc.com> References: <20200213155803.14799-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org free-space-cache.c has it's own set of DEBUG ifdefs which need to be turned on instead of the global CONFIG_BTRFS_DEBUG to print debug messages about failed block-group writes. Switch this over to CONFIG_BTRFS_DEBUG so we always see these messages when running a debug kernel. Signed-off-by: Johannes Thumshirn --- fs/btrfs/free-space-cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 8da592eaf6f8..41e138f2ae12 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1196,7 +1196,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root, invalidate_inode_pages2(inode->i_mapping); BTRFS_I(inode)->generation = 0; if (block_group) { -#ifdef DEBUG +#ifdef CONFIG_BTRFS_DEBUG btrfs_err(root->fs_info, "failed to write free space cache for block group %llu", block_group->start); @@ -1422,7 +1422,7 @@ int btrfs_write_out_cache(struct btrfs_trans_handle *trans, ret = __btrfs_write_out_cache(fs_info->tree_root, inode, ctl, block_group, &block_group->io_ctl, trans); if (ret) { -#ifdef DEBUG +#ifdef CONFIG_BTRFS_DEBUG btrfs_err(fs_info, "failed to write free space cache for block group %llu", block_group->start); @@ -4042,7 +4042,7 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root, if (release_metadata) btrfs_delalloc_release_metadata(BTRFS_I(inode), inode->i_size, true); -#ifdef DEBUG +#ifdef CONFIG_BTRFS_DEBUG btrfs_err(fs_info, "failed to write free ino cache for root %llu", root->root_key.objectid); From patchwork Thu Feb 13 15:58:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11380663 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05E471395 for ; Thu, 13 Feb 2020 15:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9544217F4 for ; Thu, 13 Feb 2020 15:58:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="A+mJIY/9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388214AbgBMP6V (ORCPT ); Thu, 13 Feb 2020 10:58:21 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:60892 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388206AbgBMP6U (ORCPT ); Thu, 13 Feb 2020 10:58:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581609549; x=1613145549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JfRFdlrmoYYFIpRot9KcZcVaDyhxUckjtUXezigMDZE=; b=A+mJIY/9XsZu5aaHHGBK0JVqwnZB07XF1ja23C7wKE6VDMw1V35bsd// Ii5mRCG4S21yevW/ldocTktMO2YU7qXuNjNlYCIk6WnIJa/ICdq51iB2j Eaz/KAa86B12Glz+fHaZ9dvBLGzVqv64ndnIkw6/i2cViiHlkVRbePGma HSN7DYWlHmQRgpdJPN4IuB+pxyaoArbsp1O/tA8gvCQM3f2VHGvuVQtWr QqTm9QNCNBKOUBMkJtWSbamyQQIVQWK2rLi3+FoDFGrgcUBUZWwXu4rQq HoBtmo0r4oTaRHx6sNJy9x+TDbO/tIIgD3lkpTNhJEmQrW11c9szNGEue w==; IronPort-SDR: xd/BoR8sZ7iTkCQiO3fzLfZ/Uovkz1sglHmuWQ0ofn7RUOv5AbPhPNC7IwDc7qMEFPIupVS0Qc IPbD0k9DxCMG4x99l1cz3XXTIwdHSlh5L0WpF36TATD99/jmuc7gnZg/mD9KBc5Lsz0+M2idM8 d8neW96tChYKO/tnpFexk3DyJSbQac/AUzPFXnllaN1DQBlf600wuM465I7m2doZwQTIgUEPex 13+O7c3eY9pVn4Fw6JwH0tQcV2nkXiZD4hlM4AXqnbBRGtp3tUkq+0LnAA9Qiuab08t9NvIVVb k50= X-IronPort-AV: E=Sophos;i="5.70,437,1574092800"; d="scan'208";a="231587570" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2020 23:59:06 +0800 IronPort-SDR: j4ydFfcDHmG9XEFTo7R6Bl+vlaSpoxXLd5qCh6PR4QB/bayLwTNIhA3sxhx0sNIfdba+WOKExM FA7eJWhUbsgu6id5OmKypU5YMBf8ugXxbPhed4g6j7fjynZwu3d7IDjgbx7+xFJZEJvU05uDsp XVNcdz7HA8LHQUJA8HCzPaqgf4KHOkec9QsK9DnV5rDYi6vnu1Eh45VWjMDzJGTuqZywb9VbbD WbbOUMYnAib0eD5kGs5NJPYLsnwM8ryBZpj1gZsNXGbZ+cjqRxlhgiNeJrx4y6C4rG9VuZh1an Pjb9tSQe8gtYEgwl5MnEbRLk Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 07:51:05 -0800 IronPort-SDR: tKv2KffTxYgWt0k0nDUc7syIbW/oXmJJqW0hT6ZiOdsksSbfPucTdVzr9JOj1LECv4zdTd5uli 9nh+imcXYv3M9Uak/q52UQMZvZ9yi+gdXpKFgzRwnOlrQTuIkkTdWml19wknU22Nqk8kOfEPRU C60wViqH3Ifc0/+vxHiPtZhtXQMD4/qg9aDFvV1AH0qlUKP/vttPzCzUfKn1uukmIb3nQg1KK6 2vPJddwnJDYzUt0X2w2/P54aAwzghh4/ZVLvMg5nHlh04Dpfg7BAF/KqU37cdV6Saba8QK0vkU m60= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Feb 2020 07:58:17 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH v2 5/5] btrfs: simplify error handling in __btrfs_write_out_cache() Date: Fri, 14 Feb 2020 00:58:03 +0900 Message-Id: <20200213155803.14799-6-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213155803.14799-1-johannes.thumshirn@wdc.com> References: <20200213155803.14799-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The error cleanup gotos in __btrfs_write_out_cache() needlessly jump back making the code less readable then needed. Flatten out the labels so no back-jump is necessary and the read flow is uninterrupted. Signed-off-by: Johannes Thumshirn --- fs/btrfs/free-space-cache.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 41e138f2ae12..c7ba2b393b33 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1372,18 +1372,6 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, return 0; -out: - io_ctl->inode = NULL; - io_ctl_free(io_ctl); - if (ret) { - invalidate_inode_pages2(inode->i_mapping); - BTRFS_I(inode)->generation = 0; - } - btrfs_update_inode(trans, root, inode); - if (must_iput) - iput(inode); - return ret; - out_nospc_locked: cleanup_bitmap_list(&bitmap_list); spin_unlock(&ctl->tree_lock); @@ -1396,7 +1384,17 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA)) up_write(&block_group->data_rwsem); - goto out; +out: + io_ctl->inode = NULL; + io_ctl_free(io_ctl); + if (ret) { + invalidate_inode_pages2(inode->i_mapping); + BTRFS_I(inode)->generation = 0; + } + btrfs_update_inode(trans, root, inode); + if (must_iput) + iput(inode); + return ret; } int btrfs_write_out_cache(struct btrfs_trans_handle *trans,