From patchwork Mon Oct 24 20:43:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9393251 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 0D46E6086B for ; Mon, 24 Oct 2016 20:45:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F30B22574A for ; Mon, 24 Oct 2016 20:45:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E799028F47; Mon, 24 Oct 2016 20:45:08 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 1F902288CD for ; Mon, 24 Oct 2016 20:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965453AbcJXUpA (ORCPT ); Mon, 24 Oct 2016 16:45:00 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:55423 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965180AbcJXUoy (ORCPT ); Mon, 24 Oct 2016 16:44:54 -0400 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.17/8.16.0.17) with SMTP id u9OKfhAa014857; Mon, 24 Oct 2016 13:44:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=Sy/nAmOAAMBsF8P4q3+eluC9By1t8RPK474h/0dsMmk=; b=igUJiYpT5XjV8GbzuWAtHXmS3JmKP+OMaxCIXEaq6+vQfbE/jkPmArSwOMjAJfY6dD9a +MsrShPyC8g8OxOCd0eM8D/AoBgd1Rd7wXn6LHogP69N7pPN8yHOrMvAo9K9qTOt+yfg hYxlIhFhjSXJOqcrkL2ykILPObsqCYjz8Zw= Received: from maileast.thefacebook.com ([199.201.65.23]) by m0001303.ppops.net with ESMTP id 269pb9242m-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 24 Oct 2016 13:44:27 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.24) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 24 Oct 2016 16:44:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BcsZ+ugJJaWi8lFCv9HBtXHdT6uW6Zwp4j4JdzlQ95k=; b=j44theO9DwveFDUOwB/3wJX1eSCrZI0qGYKbCD2nwkx/SadbvKzTo8J/4KxC2ACKSnliXv5QIkKsYisk/3SUoXclwEkSK4C+2BQIVKML9yLorjSi6O74IjzIZ5L3bULT32EpvHLDCdDTtfgNs9xS3iLHnGPXj6joT9JKnWIdGXQ= Received: from localhost (2606:a000:4381:1201:225:22ff:feb3:e51a) by DM5PR15MB1324.namprd15.prod.outlook.com (10.173.210.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.16; Mon, 24 Oct 2016 20:44:24 +0000 From: Josef Bacik To: , , , , , , , , Subject: [PATCH 4/5] writeback: introduce super_operations->write_metadata Date: Mon, 24 Oct 2016 16:43:48 -0400 Message-ID: <1477341829-18673-5-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477341829-18673-1-git-send-email-jbacik@fb.com> References: <1477341829-18673-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 X-Originating-IP: [2606:a000:4381:1201:225:22ff:feb3:e51a] X-ClientProxiedBy: CY4PR09CA0021.namprd09.prod.outlook.com (10.172.65.31) To DM5PR15MB1324.namprd15.prod.outlook.com (10.173.210.14) X-MS-Office365-Filtering-Correlation-Id: 56183116-a13b-4566-8c14-08d3fc4e8a5a X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1324; 2:PNbzeYmwpqM91FAWdQed7L8SFvHox/im2ZohAt1UC7XBegXdzy4rHpmaePsZJHZoefxAf9quq7mBhQNsxRh7lX506eYHFiH/C9+c4/Ys2V9g/wAFyfYvxFdq/3r4pP3Q53Zs+TTEWGuUE3N596EoLn6qkyQX37yzG7G9KIhbnB4YxfTAZUVxK5n6jo9vvyiVrBeyBZPTEhihWgDLw9Azog==; 3:rI52D1kf6Pa6qczCfAlrAjw5B9GPmQ5cPRbTpclYLoDbZ6muBuqRnEjlxEDYpUhcUx9QjKVAV6/i64D82C9oJjNHqWqA19081YP77rkwh0I5hqKOfSpuge9NEv9EWNw43mpmYz9VAOQfq7beS6OEBw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM5PR15MB1324; X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1324; 25:fUsqkoThJEOFcezTa6xmY0EqzefbPmyBMdCkc04tp3kcqUSFw5MuZD8gnJ89Fdmg+uYrYMVObPYJaGFB3hB3QYC/ADlAcHrRu1k/XC1gUjBlx5QGDmArpWt777KixigskkH9dR9lnY66h68jaZX4M0gU2/pTBXORSRb6UqxgQChTr0BAcgZ5W22GyL06pe/izVGaVzVB5/biXSP2yKhzCfNo204JRgmBQltuXBfdN94M4UnukvYeccuTz00oow02NeUt/lSh7retGBvLNmjTRDIamq5up3gz0uTymsnclhL6dfFVdVn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5Lg7gMLZp2cYgpSKGP8mRFXfJK7SGPIEde+V6YHvOguA4uCp2n5rvv8nUkdWuhSpzURn0F/HjWIU2cKHtwqg2xowY1ypW4/aVL3Z7OmLydR008bGMGovNMyOES/s0U0SAxAjM3dOCifgbg/w+6MroOgbbLK9268rmhuTd88PuGQu0j+YKa7L3rOPRIY0Pjvr4a9y63R2hHS44hBHRRf0beTyc6iySRbLSEZ0f737VP8He+HD24KWgFraM3acgeH7jH1UiInBavXaffG9kW7ATso5eM1OYk6TqRTBe29MhWPKYBdaNocFamwGUW55ojuFV5EBbNBrQNkTxhZX1LHH5WuHl/5Ha6oSn2ZsEDA5S6CmI0/A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:DM5PR15MB1324; BCL:0; PCL:0; RULEID:; SRVR:DM5PR15MB1324; X-Forefront-PRVS: 0105DAA385 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(199003)(189002)(6636002)(47776003)(107886002)(101416001)(86362001)(97736004)(5001770100001)(2201001)(105586002)(77096005)(68736007)(81166006)(5003940100001)(81156014)(50226002)(229853001)(106356001)(33646002)(189998001)(76506005)(19580395003)(92566002)(19580405001)(2906002)(50986999)(8676002)(50466002)(586003)(6116002)(42186005)(5660300001)(305945005)(76176999)(36756003)(6666003)(7846002)(2950100002)(48376002)(7736002)(2101003); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR15MB1324; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR15MB1324; 23:38eW1dpNetIp/sMAFZiDXaB9Uc0t1gVt2OARH0eJ6?= =?us-ascii?Q?t1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HcDVC/LkJaippFgmDoyaXP8m1Is+ealnf9eHcxn/R0HAakWrXm3qSAQO+cyh+vaZMSGIfDsyVGzy/xHyBmxYSaai1y7H1ub1XFQZJDhy+i1T+ZwqUwWunLJl4KLWFtcqj1Vj00+522lusKiZVWDHqL1eCBc4ZRhI5Xem0fNlgWaMNqMYiaCH7/fm7oDPu+NHxCBshdAc73IiaKL Ag+cYhWF6lVTjIwvVqbsBpsJBKOV6wDr+Yg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1324; 20:algKFIYA1Z2Pgwe/RKFl6qinJK5nAsdGmdpUjv5/E5olxhEg5XsPLvwJNyEdU73R6GE2iHQ9Dv9Jf2BuaecQOfFnFpfzvY+8/06u5ye9pqbrH0WEQmtTZRFyQzlL6XMGWHZ1FxpsOYWC1eaaD9zFIiRW3r9c1YGANEW1Wi5zSXc= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2016 20:44:24.5668 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1324 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-24_14:, , signatures=0 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 Now that we have metadata counters in the VM, we need to provide a way to kick writeback on dirty metadata. Introduce super_operations->write_metadata. This allows file systems to deal with writing back any dirty metadata we need based on the writeback needs of the system. Since there is no inode to key off of we need a list in the bdi for dirty super blocks to be added. From there we can find any dirty sb's on the bdi we are currently doing writeback on and call into their ->write_metadata callback. Signed-off-by: Josef Bacik Reviewed-by: Jan Kara --- fs/fs-writeback.c | 72 ++++++++++++++++++++++++++++++++++++---- fs/super.c | 7 ++++ include/linux/backing-dev-defs.h | 2 ++ include/linux/fs.h | 4 +++ mm/backing-dev.c | 2 ++ 5 files changed, 81 insertions(+), 6 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index a5cb1dd..8e392b2 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -1465,6 +1465,31 @@ static long writeback_chunk_size(struct bdi_writeback *wb, return pages; } +static long writeback_sb_metadata(struct super_block *sb, + struct bdi_writeback *wb, + struct wb_writeback_work *work) +{ + struct writeback_control wbc = { + .sync_mode = work->sync_mode, + .tagged_writepages = work->tagged_writepages, + .for_kupdate = work->for_kupdate, + .for_background = work->for_background, + .for_sync = work->for_sync, + .range_cyclic = work->range_cyclic, + .range_start = 0, + .range_end = LLONG_MAX, + }; + long write_chunk; + + write_chunk = writeback_chunk_size(wb, work); + wbc.nr_to_write = write_chunk; + sb->s_op->write_metadata(sb, &wbc); + work->nr_pages -= write_chunk - wbc.nr_to_write; + + return write_chunk - wbc.nr_to_write; +} + + /* * Write a portion of b_io inodes which belong to @sb. * @@ -1491,6 +1516,7 @@ static long writeback_sb_inodes(struct super_block *sb, unsigned long start_time = jiffies; long write_chunk; long wrote = 0; /* count both pages and inodes */ + bool done = false; while (!list_empty(&wb->b_io)) { struct inode *inode = wb_inode(wb->b_io.prev); @@ -1607,12 +1633,18 @@ static long writeback_sb_inodes(struct super_block *sb, * background threshold and other termination conditions. */ if (wrote) { - if (time_is_before_jiffies(start_time + HZ / 10UL)) - break; - if (work->nr_pages <= 0) + if (time_is_before_jiffies(start_time + HZ / 10UL) || + work->nr_pages <= 0) { + done = true; break; + } } } + if (!done && sb->s_op->write_metadata) { + spin_unlock(&wb->list_lock); + wrote += writeback_sb_metadata(sb, wb, work); + spin_lock(&wb->list_lock); + } return wrote; } @@ -1621,6 +1653,7 @@ static long __writeback_inodes_wb(struct bdi_writeback *wb, { unsigned long start_time = jiffies; long wrote = 0; + bool done = false; while (!list_empty(&wb->b_io)) { struct inode *inode = wb_inode(wb->b_io.prev); @@ -1640,12 +1673,39 @@ static long __writeback_inodes_wb(struct bdi_writeback *wb, /* refer to the same tests at the end of writeback_sb_inodes */ if (wrote) { - if (time_is_before_jiffies(start_time + HZ / 10UL)) - break; - if (work->nr_pages <= 0) + if (time_is_before_jiffies(start_time + HZ / 10UL) || + work->nr_pages <= 0) { + done = true; break; + } } } + + if (!done && wb_stat(wb, WB_METADATA_DIRTY_BYTES)) { + LIST_HEAD(list); + + spin_unlock(&wb->list_lock); + spin_lock(&wb->bdi->sb_list_lock); + list_splice_init(&wb->bdi->dirty_sb_list, &list); + while (!list_empty(&list)) { + struct super_block *sb; + + sb = list_first_entry(&list, struct super_block, + s_bdi_dirty_list); + list_move_tail(&sb->s_bdi_dirty_list, + &wb->bdi->dirty_sb_list); + if (!sb->s_op->write_metadata) + continue; + if (!trylock_super(sb)) + continue; + spin_unlock(&wb->bdi->sb_list_lock); + wrote += writeback_sb_metadata(sb, wb, work); + spin_lock(&wb->bdi->sb_list_lock); + up_read(&sb->s_umount); + } + spin_unlock(&wb->bdi->sb_list_lock); + spin_lock(&wb->list_lock); + } /* Leave any unwritten inodes on b_io */ return wrote; } diff --git a/fs/super.c b/fs/super.c index c2ff475..eb32913 100644 --- a/fs/super.c +++ b/fs/super.c @@ -215,6 +215,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, spin_lock_init(&s->s_inode_list_lock); INIT_LIST_HEAD(&s->s_inodes_wb); spin_lock_init(&s->s_inode_wblist_lock); + INIT_LIST_HEAD(&s->s_bdi_dirty_list); if (list_lru_init_memcg(&s->s_dentry_lru)) goto fail; @@ -305,6 +306,8 @@ void deactivate_locked_super(struct super_block *s) { struct file_system_type *fs = s->s_type; if (atomic_dec_and_test(&s->s_active)) { + struct backing_dev_info *bdi = s->s_bdi; + cleancache_invalidate_fs(s); unregister_shrinker(&s->s_shrink); fs->kill_sb(s); @@ -317,6 +320,10 @@ void deactivate_locked_super(struct super_block *s) list_lru_destroy(&s->s_dentry_lru); list_lru_destroy(&s->s_inode_lru); + spin_lock(&bdi->sb_list_lock); + list_del_init(&s->s_bdi_dirty_list); + spin_unlock(&bdi->sb_list_lock); + put_filesystem(fs); put_super(s); } else { diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h index b1f8f70..8758d31 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h @@ -169,6 +169,8 @@ struct backing_dev_info { struct timer_list laptop_mode_wb_timer; + spinlock_t sb_list_lock; + struct list_head dirty_sb_list; #ifdef CONFIG_DEBUG_FS struct dentry *debug_dir; struct dentry *debug_stats; diff --git a/include/linux/fs.h b/include/linux/fs.h index 901e25d..0217820 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1431,6 +1431,8 @@ struct super_block { spinlock_t s_inode_wblist_lock; struct list_head s_inodes_wb; /* writeback inodes */ + + struct list_head s_bdi_dirty_list; }; /* Helper functions so that in most cases filesystems will @@ -1806,6 +1808,8 @@ struct super_operations { struct shrink_control *); long (*free_cached_objects)(struct super_block *, struct shrink_control *); + void (*write_metadata)(struct super_block *sb, + struct writeback_control *wbc); }; /* diff --git a/mm/backing-dev.c b/mm/backing-dev.c index da3f68b..10d9286 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -785,6 +785,8 @@ int bdi_init(struct backing_dev_info *bdi) bdi->max_prop_frac = FPROP_FRAC_BASE; INIT_LIST_HEAD(&bdi->bdi_list); INIT_LIST_HEAD(&bdi->wb_list); + INIT_LIST_HEAD(&bdi->dirty_sb_list); + spin_lock_init(&bdi->sb_list_lock); init_waitqueue_head(&bdi->wb_waitq); ret = cgwb_bdi_init(bdi);