From patchwork Tue Feb 11 15:10:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11375741 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 E2659109A for ; Tue, 11 Feb 2020 15:10:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C239220870 for ; Tue, 11 Feb 2020 15:10:31 +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="CvFmTF4q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728656AbgBKPKb (ORCPT ); Tue, 11 Feb 2020 10:10:31 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:35875 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbgBKPKa (ORCPT ); Tue, 11 Feb 2020 10:10:30 -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=1581433830; x=1612969830; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+3grZabNE0tctZ91UB143uJ7lmRoYet3S8VPqzKxLEk=; b=CvFmTF4qPIVjo8TdrekoK2oVMpIbZfd0ss9BhhwQVby0gBZ7voJMjP3M 59THANx9Ot03+syChjT4jW9U1EcI+DnaZ7/QrN9Jq1ULP1AARGTa3SUUg n/PwFQq4zQMYCdoDqdpA0YlA1+c2IhJTLR7zjb6erD0JWTl7xJ7XlSPLJ h916lNCgzAFRHu0BVfba2AKqQ0cgM9Y8wJLQSWI56aVGkKU3dqgNsciKd e3oHrrH7J6fpeOzc9KkUq6+fm6JO10doFBOTudwhIhsZbiWm7dwx4e16Z az6QodEsuK3CEULWQC/tm5F0XLAYNKAVX7RrGZaYfpdObCZuxkj9uSnSe A==; IronPort-SDR: Dp2HGsINwAa62eYD6gSr5WuCejD552AO8G9zqg3X+h5fDpS7jGRxQ7t0eDjTAWgFzWIjm4LdxG SUkv9iTDF9iEyuzxX5MSKGgYirl0s4/6UeDplbTt8tIMe/y5JfyZITKtk0Pg9uOTx3ZmvzUvLy hFm9e8fVOX6aURxILFXRorbv+id0m0Ue7mkufi51s0d7Ls18aenyQPSmLc6lvcgrEOMaOtSDSf HofMXz3IwEwhpDGaNsevNwlfO3mD6eyyxbUGntgKDWNhA8R44aEG5nTQZ1rxCzzAJ0B4xyoF6H DBI= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="130128671" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2020 23:10:30 +0800 IronPort-SDR: a+ReiYhPdbzwAZQqPW/WW96CfVAWZypfi44hYV+nAUfQXUTZ8r15v5E/oCT9wPejMs+Yr29ifE nU6NyZ7Wr8QfUXX542uk1shMWFNs/h/Ph6d2k7yXo7K8eRRBNAJuw2UESBGigs4yz3fblcYDVG 7Q27evCXRIxsJ/AlejrIReQKs2xHUzbKB336PIx6qAtvQfOmgCxRTrfsYZZTEu2nfOyKaeUY3g YE2hi5ALKHhRIwSckZllARaKElF1t9soxbLEpZ82ERCOYcNiwVMnWCYBr24ghaLSnASJb4YoOC 2fNoRwr1kiQoAUV7v+zKVHQC Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 07:03:20 -0800 IronPort-SDR: rdRphJFEF9mhUyJkZIF9KKMQJG+17WmoHf5AmTasoFDHj9X8j+ZbNdUSIyaXAS2ocBgBUWsp/n 5eGlzmPVSpd4pAWgsieIC3xcF7sK6bhOBGrtDeZHh0LZZ3iqxBT/lMJxQpk0ScvDNQFJlRgtdI 6omYfq8AA3nz1EsuwOMY9tqslhYosVudwA64zEeAQx5/wVlfBpB6b5/+uleSxRmk2vt746XK2f fba8PU5s53NoFggAtmW0frMQZhlFl/3OlwaQSPFx/vg+h4XBAYmY+U9gHZ0yNdtjcIgwDJygqS MCM= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 07:10:29 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH 1/5] btrfs: use inode from io_ctl in io_ctl_prepare_pages Date: Wed, 12 Feb 2020 00:10:19 +0900 Message-Id: <20200211151023.16060-2-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211151023.16060-1-johannes.thumshirn@wdc.com> References: <20200211151023.16060-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 0598fd3c6e3f..f4ae7629a0e7 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -371,10 +371,10 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *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; @@ -732,7 +732,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; @@ -1291,7 +1291,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 Tue Feb 11 15:10:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11375743 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 DE88113A4 for ; Tue, 11 Feb 2020 15:10:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE06B2086A for ; Tue, 11 Feb 2020 15:10:32 +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="SpPcyVhY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728952AbgBKPKb (ORCPT ); Tue, 11 Feb 2020 10:10:31 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:35875 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728576AbgBKPKb (ORCPT ); Tue, 11 Feb 2020 10:10:31 -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=1581433831; x=1612969831; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oI3lM21taxH8n1gKhqZom7DbyYjWr+yCj5ESoL5FNrg=; b=SpPcyVhYkS6qEuS8+q5g/y83KmtkY3FFZWi51c1LlyDWConCBapIiSqX Xl+U0gdRphOs9ClLm74Kai006LJpUcrTY+bC6iqhcEU6TDTuKowMqpPBK EXi7q4of9SLHrVm+1uejGfxLKyb5XI7Orw1lGlkrH4Ee0911EMsIKzKdO lTjSBLI/wkkRkItHKKi1/j8sbUDf9Q0XXFQqEMd+ffVZUCC7bQ5EaKa/g P1/Kgg7rCgxnvG6jZeFV3o/c5l2LwxJZE9zKBdXIZy55lWGUv4VIxMOKg RHmcJXAxKnAAMb6hkLMfQZWA4ykEYNbaJVWweUaRvp/7psXhfCDY3fVrJ Q==; IronPort-SDR: +K6KX1gj87QhfiH4JOhFlJFN9Y+5/enHVSGxe/V4UUEEuUOcu9e7Vd8czRkACgwTYSra8sVST7 ocWke9aedBzGRVG7wSmrmsIpWrisjEC1EG7eIv8uAVQFw9WdmEPvxGqZIzpt3p2/EOjr88MRDE Xa41IptA8YpUJA411YxUdXSwLULBOX00RWON9wz7be3G2CLXWfBRUyLVCHf+Hz9NR2yQo3/y3Y fxXT4at0pcpPH8SHMs3rhrYAZGmhzOHGEL7ykPYOrMR4X6a2LTT4cHAOFSVw6SpAHuurw27DkK UxI= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="130128673" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2020 23:10:31 +0800 IronPort-SDR: 0acQMuv95zmXE1KaQBtZ4Gzy+taetUh5hHKDU16IS1KMyAYC39l3xZxQHMQ3wAb3tF0TRc52MJ tLcUCOYcyN8p8/KWF9FXhlAJhK3GZRBcWH1ROFQ12eeAQYMbYM7fAkIJUQpmsU81q7lOiOgPok 4fM+3RHlX7G9uFUBUB1zycql1A17cKdoPw4mmfGNDxiDhvwsD0nWmHFPNthCaFeVWK2fPE/L1F oZxzMYRYV+yfrBd4K/UOy/wH7qMpvSm7GNyPX+PlLAdv6ccy1eh0fnmhGfZN3xapIAII5DquOP xZodnIWgVsiaJNCpvPt/VzCp Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 07:03:21 -0800 IronPort-SDR: Z8JKCXnKQEu3Oeat+MX2m3Ayu0dxeu37rphcZqIyEM14k5QhR64NOoVOp+tzcxZkmHzSIdi9Rj kisXxWuKYuhtvw5QQitT7Vw4if3FmFpGD6pdOuM7xbyQvPgj/s4EuzksWwb+ayFWCAjfE11hRB I5L7uNueq3XD9CtaBc0SaqXROeopUbvw/JRtb0VRXrG6Cxt6FVO3YlzAq2+i+ioxzkcMEeulSD wjtsTJIBZxQNIUx1RUGGimHqTCyO4JVPCM+nr5NN2QLOdJ6jsCZ9KLbWBHX82JiKLL1zx+gZvC w04= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 07:10:30 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH 2/5] btrfs: make the uptodate argument of io_ctl_add_pages() boolean. Date: Wed, 12 Feb 2020 00:10:20 +0900 Message-Id: <20200211151023.16060-3-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211151023.16060-1-johannes.thumshirn@wdc.com> References: <20200211151023.16060-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 f4ae7629a0e7..98f547e87bb4 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -371,7 +371,7 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *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; @@ -732,7 +732,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; @@ -1291,7 +1291,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 Tue Feb 11 15:10:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11375745 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 2451A13A4 for ; Tue, 11 Feb 2020 15:10:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0414620870 for ; Tue, 11 Feb 2020 15:10:35 +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="Xyr73yqV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730095AbgBKPKd (ORCPT ); Tue, 11 Feb 2020 10:10:33 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:35881 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbgBKPKc (ORCPT ); Tue, 11 Feb 2020 10:10:32 -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=1581433832; x=1612969832; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9p9CwSeXupNCM9jnIYnpHRH38xmM1qzKlKT+fZwFin0=; b=Xyr73yqVt2aeBVHQirrfwmSz4Jqpr8rxWXrv/fYTz6ekXHDrBZbSJVll 59S8zX7hWkq4TyeXJLsP2c6Hq1pXBa4el61m5l4vMa3pb67NvmaM255nB 8fXEkqgqohtSSHGfrrJRv+nH4aV/Q32vDmWqeNWIe8YLULeQKcXW5FIg7 vSrvnnGYQELFMYLw2LZDJl1+WYR5dLG6grB/5QU1zMrR7t/VDy/eELZLy wd7rxbapoaJY///vhwVDztHUXiz4JhPe+l5NjN/VTwLk8Q46GMyrn4CtV vd7FkK/s1p0N/r5Du3gsKcnpymPv/gpSKqb+Z5qQBp3AD8kQovWjB6ctc g==; IronPort-SDR: tuRVEocHvP5jZd3WlkVsH7I3hv2TBWSU5cEfE7ycltLmy9ejQzRIE8bJUD6p0QMDDqWRhNnnIs xqgPS07EUT/MJ6w5wtPr00/iWbqYKX+29JlpEpbY4olTGKXN6GGW94OIC/je1lE2O5EeLMAljg BvUFgS2QsNmUY0ICpbXPlIPCX0jgJxH7un4xv2H7qYBx2OwxgNWeRP76tVkh/YmG4g3c6xJqmP be01nhV2Qdlu8SU2Mt9EqT4+2r4PipJJ/0oRppvkZmNjAB+6yXlbQznSlJb4Mo4A2pOqSXL+zP QKQ= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="130128674" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2020 23:10:31 +0800 IronPort-SDR: PlsP1Efigm9bG8r9MZIJ35EoAwY377jU+qkFj7I1N/X/qoRP7FF2p93geVyfmIkdhS+0kh0IuR Pi/t+PtzkEGjZ0IKIZzeaf2GwVXmDL12pMk4J4ODflEpTdXQfY2kNn08eNMFA75GrrRSZM35x/ 2O4tV3YpKNXibp7tpIwyrI0ZfANJiJcTIEh0v8Czzr3caoP+8XYNHuzAZQJhQzFQw8wmcYfvf1 Buot7yOPKCkK3KfS4ryXmndvo0nm7ILkiT8Zp7RB9Yl2ozK449549AKLNSoRFIxJATl4SOOmZ8 XTxqfs874zyI1kVR2u/RFVng Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 07:03:21 -0800 IronPort-SDR: /NmXw4YTjp33R5lxb255jeVkneqolJSZJ9qtM4pmVilUbG5EJvCnouICRMiotDhCWXT4blN4Q7 F9/tfhsxdlduoJ0InXRuS7IrmT/TXvwRGhURY91EvUZYeIeIJC/vYMBfyBB+Evb2Q0g+tjZOi0 q0aY3ln5kApv7W7+BcJyFttB2/W/CeB0jxacDSng8Jc0G8rfKfOfVSAG1qFY1EbqRKBosJ9Dh9 p39b6EAvxQxP5pOkQJQH85h5kiW0oQFyJ6HorMhR84aJkBunWae70BW8IWZar96Ebotr84cuDQ jsQ= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 07:10:31 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH 3/5] btrfs: use standard debug config option to enable free-space-cache debug prints Date: Wed, 12 Feb 2020 00:10:21 +0900 Message-Id: <20200211151023.16060-4-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211151023.16060-1-johannes.thumshirn@wdc.com> References: <20200211151023.16060-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 98f547e87bb4..7d6d6aa7b7d6 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1190,7 +1190,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); @@ -1416,7 +1416,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); @@ -4036,7 +4036,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 Tue Feb 11 15:10:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11375747 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 00ED9109A for ; Tue, 11 Feb 2020 15:10:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D591F20870 for ; Tue, 11 Feb 2020 15:10:35 +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="ZSwyUodo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730175AbgBKPKe (ORCPT ); Tue, 11 Feb 2020 10:10:34 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:35881 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728576AbgBKPKd (ORCPT ); Tue, 11 Feb 2020 10:10:33 -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=1581433833; x=1612969833; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r/XeVTTpHIzCXQJSJS9W1+Ng69r6dxMzAyfe0uCJwIY=; b=ZSwyUodowlAYNHzPaEIiOfZOJWj+geAnBfYOqQzNYTFgUpOaytCSG8Cy erzEKhip766jKkynrunqAIrda1kPqhzMnr0MTab+YIXwYC4SRL1cc8koc hDPjasj9mpp1dBmwCFIrMN6nEgIRUuj4F5eYg2DnT7QQsRCYsO10q0q3S Hn0X3aO26vRNwB8Ry+TyVQ8Yx5/3cfWqFFO//Hpu0CSGkmhGd0bTaZX7Q s+nGmXm6EgUUehKQJ19dodDOdak2erEd3ED0LfsQJgMquOLoHa551W05x U7oGihwhXHX1/DHmOiR4d32TiNvq+tk537LeIWss1O9OWhxC3pAOmbG0N Q==; IronPort-SDR: 1/olxHnmsHQ012ILmitqg/RtHAYPrxHYZqZ8uWCDr14oFksVoRjoOrGyhD8NuvS6qz997LD0e8 sng7DY6PdJwSOqjiTXzntICUJtykFHA7v61TNbe8dTNexS95p8+gRDPp/XceNpRyy08E6T66Q/ NNtEvsGQZwIMUrDLG/ZNatt4IG8s8Q7J8+t08bFTqAQ35Eg3YdWCLyEYbCPNbC5Hb/sO3GEZJD d5YW9Cthkr8Y9Oi0xtbMZAItZZTFEZg784fqYTPcaT/ci6vWNMV0gEvKaPgXS76Qb39IAPQnVp B/c= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="130128675" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2020 23:10:32 +0800 IronPort-SDR: o6eAep86Y38TQa3ri1eB+ulkarw2uWjVU6E7mYcQgOUb8lpQ/V1y5lmWSGm2jqf0w554yGdwcV CRqzjeNgKwStcPvaN5wAnqrIDnRt9R5NlRuzowm5DdfSXqdHm1lBa48GCr99/mFvnukEUOP+HY YOYU5pHs8z/Rquwu2vlBh6BG0a5HmKg2LQoEbiVjc7J/ojiK133qZe0ikJjl4+P3BUks/hlnpx 2CmxVRYC/+mj4qiKq8c4DJ75tv2Nbp9w4dXwbFPpLhULesIwDJeaDm2bEI2yW5Mwo0rbN96/xz Ipde3cFAkNgZvkSVExUMtz+8 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 07:03:22 -0800 IronPort-SDR: Sfrk5LRdxva7v1nbzGAIiUFsONxlbnbL+DgWyg6BfrzV2+L80RRrn/GkBWBpW9fOhOqRMoa54Q Ocp+ZQ3PS+nMwixY0yr6nQPNrlr0Tg4hskOPBWSlYWBXx9DF6KC5odLNRNIH9fFC/gdM/NhoYa YzHmdZisaoJVkWsTEnk3X9hz421eZKQczmAN2DYw0kVgFN3ntNeh3iBLX/dXv3KsvBQpbqiK4o qUuacolzKTmjYVM+cHzsEFrRwnmDv0H0S9vst6ZY6a04lTOwCV7bEty8/E+LCEYDkUc6EcEfQI NfQ= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 07:10:32 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH 4/5] btrfs: simplify error handling in __btrfs_write_out_cache() Date: Wed, 12 Feb 2020 00:10:22 +0900 Message-Id: <20200211151023.16060-5-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211151023.16060-1-johannes.thumshirn@wdc.com> References: <20200211151023.16060-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 7d6d6aa7b7d6..705589daeffa 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1366,18 +1366,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); @@ -1390,7 +1378,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, From patchwork Tue Feb 11 15:10:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11375749 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 6F7CE17F0 for ; Tue, 11 Feb 2020 15:10:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E7E72086A for ; Tue, 11 Feb 2020 15:10:36 +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="lVcU+zh8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730188AbgBKPKf (ORCPT ); Tue, 11 Feb 2020 10:10:35 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:35881 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729733AbgBKPKe (ORCPT ); Tue, 11 Feb 2020 10:10:34 -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=1581433834; x=1612969834; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qNpMIlpEif353iFcRYUIxrnCxXy8pTlGKLytGvY+s2M=; b=lVcU+zh8aju5xXzN8JNCX4atUYSKTKRn7nlbB/TOc3PrFyzz03enf+UO uZk50BAeXdzo1KiG3YUiVu93Nigjwrk5NlTrDcgFGB8GXUJVqbVysktHx tgSZ/HNlwsE8e0vSq8k296jgPD2xa1wDxdv9ASb+RHmWYkrAXfNOUPM4i iO78hVD+yKbjvYu7dEXRkQn5p2lQ0fhUfiNGQT+rVhul3lhtd/exZvaCC uQ7F+quXSdpQRJkkUpBOUsBAE/7EVpTq4DuPUsn6otLsioM1aFUzHBypn BO/a0Tnq0mANghNwO/YGfb85TMF+pydqLfdBJXhcoP9altoqAs6Gv1uup Q==; IronPort-SDR: TDHlgPGIffMVigRKkI4XoWfJwYtWmJd/PRkw+/cq4jFkYRm/Yi/H1gCsAdyCyckn6dmVw1rZqV 2CfhJnlZYOnoRQgKBIplsi778SJ5dFO+szcdIXUX5Aacc8d7Bv16exQjkWa1nrO89Qxs7PJFwy 2bb83tXNQOIS4flMFy3xJa4S0tEdiUqykWL8PT2TXZoDhPvLvvI7WU48/vNplj6csVu9ZQZVD9 0UGxLYlhSuplV1Na4nxjwBdRR224dPNExwVsX858sZ53eArZ40FWEK1+q4w8a9NgatZGZoRss8 t+Y= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="130128678" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2020 23:10:33 +0800 IronPort-SDR: dyP+MhU3MleSwW++hk+5VF8SWBuZobTfVbpb8Hb4c/QzC0PWguTQfbb31CFfg/0n49JNCk18p9 ogsYI5EXoG8zZ2ywaBUaZXls4rKEjSpF/sISzqDtmLg4I/arWIC9n27whVNDp6SXyPrQn11gK/ hgY0k7i8B0FCPPNmeVN6mUNhO0HtTSNY1lCW1Lnk8PfT2Uy6ePOiHlUZbIDhu+hQevQyC/jq7H 1eqnZpTJ/TdQFx9/2jPZT2GQ5NOSsc3HDPSWzmaiVtX7n4x9g2O0DFn44AB71RUwrfyNz+KdHG r+6wEvr1tautwvatPc7C4onQ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 07:03:23 -0800 IronPort-SDR: vKE29oDZ6LiHof3qpJmuWkJ6KA9bBRaXkoGe7JyOmWtijA2rGCBJVFMauTgKyHYdnP+i8y8IJj 6BQAaeMJpruMtZU1/v8S0vxd388LCQkT7S899kR//p8r2fIJRwpHhyX2ApN2zzsri1SBSyQ/pE aPchb+1u9VCGIFThqGgNc7u59SgPU/mO5N4AkfCX43KXKDPWP4t/4Cd07VUtzIZzg967ccC8KG Awa7zUr9cVsW4hHKsbk4UpOJxVok9fqcN/QIH0DNAckOloZIri2kJ2vpCTDpl9QFNPmOT7te5D aOM= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 07:10:32 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH 5/5] btrfs: free allocated pages jon failed cache write-out Date: Wed, 12 Feb 2020 00:10:23 +0900 Message-Id: <20200211151023.16060-6-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211151023.16060-1-johannes.thumshirn@wdc.com> References: <20200211151023.16060-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 705589daeffa..c7ba2b393b33 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, bool uptodate) { struct page *page; 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