From patchwork Tue Oct 25 18:41:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9395213 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 B1DC46077F for ; Tue, 25 Oct 2016 18:42:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A627C2970D for ; Tue, 25 Oct 2016 18:42:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AB8629711; Tue, 25 Oct 2016 18:42:57 +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=unavailable 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 9FB4129712 for ; Tue, 25 Oct 2016 18:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759475AbcJYSmo (ORCPT ); Tue, 25 Oct 2016 14:42:44 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:54546 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758503AbcJYSmf (ORCPT ); Tue, 25 Oct 2016 14:42:35 -0400 Received: from pps.filterd (m0044008.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9PIch52000622; Tue, 25 Oct 2016 11:42:11 -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=OQiIRgxYNSNJ7vv7SxMLIALQfFiNKLcPh6pGsbSz1G3jxyjGKqM45xc/7R9YraHKNuWp Eesz/eal+/83DfW3dHHefwku8JeVKzBf9vBcOdcH3zlHiyP4M1kbZULVoBihzsfW7vBn tAW0treMjPca6QaD+s1FG+JOIGPj0Z5af+0= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 26abems06b-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 25 Oct 2016 11:42:11 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.15) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 25 Oct 2016 11:42:09 -0700 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=QU02xDBf+t/0vwkVue1PQaAr7VdHLHnOsqXncfJNnRIhgQCp26SeByYSizva0LRaZ9I4lVlGWuhmEvzZKGjuEdHAbL1EKDKLMdkHKHCkb8xrxhQ+dQbHpLCkHbFoWfR6RJPdMjtrSgN43nf6i44A1PsTyRMxcNYWKHDM9BzlxPQ= 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.679.12; Tue, 25 Oct 2016 18:42:07 +0000 From: Josef Bacik To: , , , , , , , Subject: [PATCH 4/5] writeback: introduce super_operations->write_metadata Date: Tue, 25 Oct 2016 14:41:43 -0400 Message-ID: <1477420904-1399-5-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477420904-1399-1-git-send-email-jbacik@fb.com> References: <1477420904-1399-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 X-Originating-IP: [2606:a000:4381:1201:225:22ff:feb3:e51a] X-ClientProxiedBy: BN6PR12CA0017.namprd12.prod.outlook.com (10.168.222.27) To DM5PR15MB1324.namprd15.prod.outlook.com (10.173.210.14) X-MS-Office365-Filtering-Correlation-Id: 4766e4e1-90cc-4d96-7bc6-08d3fd069fb6 X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1324; 2:HRVOHcr5zkX8NqJQqgsiJBt8mAWM48OhuyiMm69XLdSjaBtowRpstqCvBwQ2uk0FFQfGudDjgUbiq4fwALFJmyaqvB0ixyRDdZg9Lv3DBUybAcStBeUspXSMhkALG9nMw3e/7uXY8cCq+Em6iHnBHfJrhXQ8u/P7S6dztoSWLgSqXypYJ5BW2DSwJup1vi4TjQA0Bx/XXmzzX323hIo+4g==; 3:sK18wWtN1Gyu/xZgs0wJZgz6rkSev25XwqN3s2/sr6nizTVmT1JmVk/ArxgjNRuQfk9iLkEAOR5TjJXlij30DCRpgDOifOP0ydJwjLS5AB5rwB9hk5uwzlPsDGN7ZDUsbNJxHxSnGZMIAOBCy4/8qg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM5PR15MB1324; X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1324; 25:zs/KMf/l/TnCgN3WCLo7UU6sKdPl4WM5QIPngIaMUGB2pLmCIJASSa/2Y/PHOeJBbxtG196Tln5o43vhyTOiLS8CoiaGjB3C1G24oxFBEob68OUhfEhsAdMBiuW9gTh63rTlCjHhONi+BP7oe0AFbGPJIVn+Jn7Ikz+I/I4mu5lWdg8MTPg/c88yc2Jofhw7v6pokK4IO9FpmWjzz/4Mj2M3nROqdbKgUZXiaJvFroRSBxAlqhkCY0UFRRJ+lce6XCWPoNoq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WuLEXHgnq6RsZrP4tOwmD9SdCMeH1WbAdpGfkg8MvoNYV+ht0YB+8l3vsRaaNjcd/ueQbb8sL/5dnluRdeYB/xClx6cIO123jp8UX0Kp3n5jA7kEhAr+MtuN8hJ0SUYUy34dXGcr3gPw+yyv7EeToUqZQg5XfF0BdrbrnE89HztlNAr8lxTkf6fGHNC5TWEm2MdFw/S8eYYVbmnhZd2OHkGZ2AJvXqezZxw/4HV/DJClBuhTEwAxNwDtqXCmtnAhk4j8wXPixQPyr88Lva9PR/SUaSoG19kP2Ro73+T+oMUBPDAZeLDt8dQfga/X1DZhjzyNdixeYb7OVrW+BVqh0acegC2vW1GDsvBSnOZsYD3tJEW3rsFSPabBGJ0GjxE+wsFuKPQHa3lHQ== 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: 01068D0A20 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(5001770100001)(97736004)(305945005)(50466002)(5660300001)(36756003)(48376002)(229853001)(101416001)(76506005)(76176999)(42186005)(105586002)(50986999)(189998001)(6116002)(107886002)(7846002)(7736002)(5003940100001)(586003)(33646002)(2906002)(19580395003)(6636002)(6666003)(106356001)(68736007)(19580405001)(92566002)(77096005)(81156014)(2201001)(81166006)(8676002)(86362001)(47776003)(2950100002)(50226002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR15MB1324; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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:uUPopmQmR8BkELDnTJOB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BH8QYzI9pP+RQIFTISuv5bpJwGrmSxLBrUVErLqOBoAHBMgYviIxD8KpCm+S7CPPidKyLBck6DuSICjZTHU/srgjcJSECRqULUa46H1oYRFxvVyWgkFBrgnUyJKYDFHK3uto4zJGIr9s2cFPoVmU75tYUUZa5grd61LKMmYA7+1/kKVhHxnfKVANfNeXjhP7oJGsLyBN3aGxd1RkEpAqpsIzUK44+bCa4so/maZRCGVUmC MMhVQ6KXYVEQdTvppe9pnE4I+yGRdqlDU/w= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1324; 20:TcfDgZEfJbmTPJ97An1udRoHk5Xe3Io2J0SjZcBrJ6RNoBtjH3E5uf3VRTFcyMWZI64UK7td3TGRdiB1pn0WU1Ze6v21mlp8KftfntvMsclB+4+/hedxsgi+YxWWh1MyENuANek7GWEhKf1nc5QM2FZ2iV4eLsoqj+tKWhQG4IM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2016 18:42:07.8878 (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-25_17:, , 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 Reviewed-by: Tejun Heo --- 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);