From patchwork Tue Sep 20 20:57:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9342419 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 92C8560B16 for ; Tue, 20 Sep 2016 20:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 808D829B20 for ; Tue, 20 Sep 2016 20:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 751E129B35; Tue, 20 Sep 2016 20:58:40 +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 8C08329B21 for ; Tue, 20 Sep 2016 20:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754199AbcITU6g (ORCPT ); Tue, 20 Sep 2016 16:58:36 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:40511 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754050AbcITU62 (ORCPT ); Tue, 20 Sep 2016 16:58:28 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8KKqdsU023726; Tue, 20 Sep 2016 13:58:17 -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=Da630xmmQBnXLUmP14jji7SK4gAU+PVwikwppufTd1g=; b=plLuI22PQ67x3cKe8DPq8QzW8RrUjJmnCF3hzMrR6lH2B5CZjstgucGZofF8XvWiuGZ2 lLwwDgTHZP0xKqUwC1x9DaguRTWFhmmdfX0YTHKeUQA81NyVC3JFxWCSuiGfLpkzxsIg YcX5lb2iWOkwFb7ExMyQ5rc/fFgZ/lHmY2U= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 25k78g9rve-4 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 20 Sep 2016 13:58:15 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.16) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 20 Sep 2016 13:58:00 -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=r5x59m33m6p7O7WsfrKNWptuB5Sz2kcDhbSoHcWBTmo=; b=DRDKQyHSV1PONJ3WwIieSVNoMHTgG47Elc4P1O5Q+Nhs6IOUBF+FeRk0LwCcXJS+6Ne2hQV35LRQ3NafgDlPixI9Z59aCT3PST8dnbozV9jutnd/kDUykPWRAWr5afjORnf1ygHJm1nVui71EQgeMhtLR6rSUpKbA2yF04tHzSM= Received: from localhost (107.15.72.49) by BN6PR15MB1313.namprd15.prod.outlook.com (10.172.206.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Tue, 20 Sep 2016 20:57:58 +0000 From: Josef Bacik To: , , , , , , , , Subject: [PATCH 1/4] remove mapping from balance_dirty_pages*() Date: Tue, 20 Sep 2016 16:57:45 -0400 Message-ID: <1474405068-27841-2-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474405068-27841-1-git-send-email-jbacik@fb.com> References: <1474405068-27841-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 X-Originating-IP: [107.15.72.49] X-ClientProxiedBy: BN6PR01CA0053.prod.exchangelabs.com (10.172.194.143) To BN6PR15MB1313.namprd15.prod.outlook.com (10.172.206.139) X-MS-Office365-Filtering-Correlation-Id: 5c9b1271-7720-4f13-a8e7-08d3e198cd61 X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1313; 2:OB9uWY3tqiFKO8kC+93WtCXTO3ZkZkO6tXRjNR56/kOX3g4yPo2UlUCwTwBB/J3AAs/Qe57gWcDQREltKpdTFSSkh4/zmoFz5OCm74Sy7YqxAyMzhO5UcGY8Tjwfh17TgxMWdDtAKMnFziLaduypbFKq3Wrl+TS9wErH71pny4ucn+zkFa9ApflZxQFcuIkp; 3:e2teG9qNmL1fSVUn3hvRk3kEpZr0ppOFa6G+2Jbd+OiwITivuYC6rFlQUm3w3emghb/hUBGJVxgnBqK6J7FS+4tBxgvkWW7l8S0FwralQ6NwCmYxmCRvbQYAnwV1Kx9r X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR15MB1313; X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1313; 25:6npfOwbf68r51DGPzoqTzuZ1pbzgPno2ZSdRNzXYdN2B4DA4FCf7eu8wEcntdEaK1Q1k+9FMzULUqEK4WyIfS+8OtS4+k6rkABOu8RayUQzPXP5lym9FFGMyytpZOyQr3BUohqsLw2BC5Z/5Fs0/1D9fvaQ+vSqc2GbdfG64UWd75AzjOIyIXz0dgNStPqSAIdDDsxCqZH3NerPqVMV2SL7rcyZMggOEw8RDeB5Z1nd3mjQbc8rt0kQF74a4B19uhd9WxJTwIlxcfImqqZPS6i+pd2kmk7jNXUcvsR4SaV6OXzU5WTYBzq2rHtbWTuv3ZbLetfyo1nv+6nYLxK8zMi+sdugCFV93dACA/9OW9T6BPE73F6I0kofXfetGWhuk+4++nkRQHDFc4EITEw+5qEYeRmAIBjhA3on3HhxXYjQjazsYKm9lRpd1vWKsCAl+OzsNNNE4LstMkBherPglRtlz5hDQ6k68tlCjWGR67Ih8NQPFSczQc7nndt+mSIV7Tdt241K+lsJ1O3uQamJOOQmlm2lnUkOdwgFspST8npHEUsypi9EbwutOMMZEoCjcSU0VGnEsZ93ZLaB6p8JYTJNxKohYqKf23tEU06ld5Nk0o+c7DIg5OlsluYb0IYAV5urAOmbB68cfacCXaVRYZQ7BdpthsDdran3OVMvajQwgbnil/2z1NT0BJeDeP87EpGG8tutkf9vRDBh2OdriaE7f+43H3egGxf6SkYO0vw8= X-LD-Processed: 8ae927fe-1255-47a7-a2af-5f3a069daaa2,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1313; 31:Ed9Uh5owZjcoO4dqI0McEDJGj47M7+CBiS1sM0kEsof1jtZrfo8UNtnnYEDKPvotvwLgJ1PfVuP5lMY0TNP32RZRNQhHvjbUFSEeeGEqVMqYBXjUduoX7s7QhA0ozZaYNedRVXQgHpyV5RatqRcqLIhwOImYd+hcG/S+J2xrn/OkH4lCjFBMJn23ELryTEfp9bTKSS5PxlXN14J0juyxPN/m76/x/VhKWhal7qJk4Do=; 20:iCtw3Mm5dMVfhRFIgivprhwXdFAstmfgrqUSqKI794YX06OsSxCFP7xmdki9cinR92TRv2xPNS6+bo9UZxcxLhbub9QbDNhfwuj7CUMZIu5DuISR3ibpt8TOhRAe0X7WUA10zxH35bNHRnNE7GfxNHEM8JnhwLA3F9+kwF8ilps=; 4:F+NRpPzPVbXqX21evjCyXnFhWdnGQ7+rwY3z1wJzJuCB6Iwt/0W8V8FwNjFJV18wjO9ZiL695kf0hOK3AjUN5QHQVZBDppuXWeXeeXU4UsUBEISOi6zg2KVluXLpJer8DGZKoKuwdiyQ6NowLYi1lfJ1jWIMIJ3J5+GVcjXxWPDyBS7q4jA0IySocdZ9IVCBCV7dwjmE13TE6qrsP/yFyP7nCCZJZw8k6t6kp+r1JDDlmd9qpDKS8PpkRLhXF+YHpt9hJ6hBrJ+e34vC5MNdRrza/wvlzoh4KKd5dr0tgn6WZ1lU+7zFmlGEmLmB+mOJJ1gG2ClXFU+sX7ZSZYWg40QlA7/HhbxOP8mqs/jjE3NY2bYZsZtvh3woOcNvcjAt0CqP6lpxBXozQeuxT8mmMo77PUx+G7GF3M4I0/xUxmIW/xCy3YSmW1M5130DBvTj 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)(8121501046)(5005006)(3002001)(10201501046); SRVR:BN6PR15MB1313; BCL:0; PCL:0; RULEID:; SRVR:BN6PR15MB1313; X-Forefront-PRVS: 0071BFA85B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(7736002)(50226002)(2906002)(305945005)(81156014)(68736007)(97736004)(7846002)(107886002)(81166006)(586003)(5001770100001)(5660300001)(47776003)(66066001)(3846002)(6116002)(77096005)(2950100001)(8676002)(50466002)(106356001)(33646002)(76176999)(101416001)(229853001)(50986999)(76506005)(105586002)(19580395003)(19580405001)(36756003)(5003940100001)(575784001)(92566002)(48376002)(86362001)(42186005)(2201001)(189998001)(14143004); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR15MB1313; 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; BN6PR15MB1313; 23:eoYnP90ODKDB5qsOFHVsFoNZetkr191rsWdy6TxCD?= =?us-ascii?Q?jdk8y1yjWH+xgrWom7RAhUr59Mvun/18XEF2Gw/Gqp9qYkT34xFNAqZ+zW/2?= =?us-ascii?Q?bzPHsXf/zYGljM3IKEaRROP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1sFU+kgSW0DpIuRwC/47+uTjqZ8NcAgzckjVKbWre3QTUqj3pvSVyUuS5fypi1tRGewGpL8//uhAzKz0JyfhSraOzjBp4i8InrtfU5C/M5A SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1313; 20:WySgxheNlkf4H5RXYFCV1+2MMWykLYmo/IZlUM7kNTjHmI5HHuPhxBlA5CTUSlYY7eAGoUzQz7+TuDxtSZt0RwIxS700qR2ZPkALQetS/muolmwGGHuOaEkmyAytFwIvwKVd8iAUclYRssXMh4+/qL5oZvLWQAWD2lRH1xWZcew= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2016 20:57:58.4828 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR15MB1313 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-09-20_08:, , 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 The only reason we pass in the mapping is to get the inode in order to see if writeback cgroups is enabled, and even then it only checks the bdi and a super block flag. balance_dirty_pages() doesn't even use the mapping. Since balance_dirty_pages*() works on a bdi level, just pass in the bdi and super block directly so we can avoid using mapping. This will allow us to still use balance_dirty_pages for dirty metadata pages that are not backed by an address_mapping. Signed-off-by: Josef Bacik Reviewed-by: Jan Kara --- drivers/mtd/devices/block2mtd.c | 12 ++++++++---- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/file.c | 3 ++- fs/btrfs/ioctl.c | 3 ++- fs/btrfs/relocation.c | 3 ++- fs/buffer.c | 3 ++- fs/iomap.c | 3 ++- fs/ntfs/attrib.c | 10 +++++++--- fs/ntfs/file.c | 4 ++-- include/linux/backing-dev.h | 29 +++++++++++++++++++++++------ include/linux/writeback.h | 3 ++- mm/filemap.c | 4 +++- mm/memory.c | 9 +++++++-- mm/page-writeback.c | 15 +++++++-------- 14 files changed, 71 insertions(+), 34 deletions(-) diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 7c887f1..7892d0b 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -52,7 +52,8 @@ static struct page *page_read(struct address_space *mapping, int index) /* erase a specified part of the device */ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len) { - struct address_space *mapping = dev->blkdev->bd_inode->i_mapping; + struct inode *inode = dev->blkdev->bd_inode; + struct address_space *mapping = inode->i_mapping; struct page *page; int index = to >> PAGE_SHIFT; // page index int pages = len >> PAGE_SHIFT; @@ -71,7 +72,8 @@ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len) memset(page_address(page), 0xff, PAGE_SIZE); set_page_dirty(page); unlock_page(page); - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); break; } @@ -141,7 +143,8 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf, loff_t to, size_t len, size_t *retlen) { struct page *page; - struct address_space *mapping = dev->blkdev->bd_inode->i_mapping; + struct inode *inode = dev->blkdev->bd_inode; + struct address_space *mapping = inode->i_mapping; int index = to >> PAGE_SHIFT; // page index int offset = to & ~PAGE_MASK; // page offset int cpylen; @@ -162,7 +165,8 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf, memcpy(page_address(page) + offset, buf, cpylen); set_page_dirty(page); unlock_page(page); - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } put_page(page); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 87dad55..4034ad6 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4024,8 +4024,8 @@ static void __btrfs_btree_balance_dirty(struct btrfs_root *root, ret = percpu_counter_compare(&root->fs_info->dirty_metadata_bytes, BTRFS_DIRTY_METADATA_THRESH); if (ret > 0) { - balance_dirty_pages_ratelimited( - root->fs_info->btree_inode->i_mapping); + balance_dirty_pages_ratelimited(&root->fs_info->bdi, + root->fs_info->sb); } } diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 9404121..f060b08 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1686,7 +1686,8 @@ again: cond_resched(); - balance_dirty_pages_ratelimited(inode->i_mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); if (dirty_pages < (root->nodesize >> PAGE_SHIFT) + 1) btrfs_btree_balance_dirty(root); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 14ed1e9..a222bad 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1410,7 +1410,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, } defrag_count += ret; - balance_dirty_pages_ratelimited(inode->i_mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); inode_unlock(inode); if (newer_than) { diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index b26a5ae..6e194a5 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -3202,7 +3202,8 @@ static int relocate_file_extent_cluster(struct inode *inode, put_page(page); index++; - balance_dirty_pages_ratelimited(inode->i_mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); btrfs_throttle(BTRFS_I(inode)->root); } WARN_ON(nr != cluster->nr); diff --git a/fs/buffer.c b/fs/buffer.c index 9c8eb9b..9bbe30d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2386,7 +2386,8 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping, BUG_ON(err != len); err = 0; - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); if (unlikely(fatal_signal_pending(current))) { err = -EINTR; diff --git a/fs/iomap.c b/fs/iomap.c index 48141b8..937e266 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -226,7 +226,8 @@ again: written += copied; length -= copied; - balance_dirty_pages_ratelimited(inode->i_mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } while (iov_iter_count(i) && length); return written ? written : status; diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 44a39a0..0a8a39e 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -2493,6 +2493,7 @@ conv_err_out: int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val) { ntfs_volume *vol = ni->vol; + struct inode *inode = VFS_I(ni); struct address_space *mapping; struct page *page; u8 *kaddr; @@ -2545,7 +2546,8 @@ int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val) kunmap_atomic(kaddr); set_page_dirty(page); put_page(page); - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); cond_resched(); if (idx == end) goto done; @@ -2586,7 +2588,8 @@ int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val) /* Finally unlock and release the page. */ unlock_page(page); put_page(page); - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); cond_resched(); } /* If there is a last partial page, need to do it the slow way. */ @@ -2603,7 +2606,8 @@ int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val) kunmap_atomic(kaddr); set_page_dirty(page); put_page(page); - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); cond_resched(); } done: diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index f548629..66082eb 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c @@ -276,7 +276,7 @@ do_non_resident_extend: * number of pages we read and make dirty in the case of sparse * files. */ - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(vi), vi->i_sb); cond_resched(); } while (++index < end_index); read_lock_irqsave(&ni->size_lock, flags); @@ -1914,7 +1914,7 @@ again: iov_iter_advance(i, copied); pos += copied; written += copied; - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(vi), vi->i_sb); if (fatal_signal_pending(current)) { status = -EINTR; break; diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 491a917..089acf6 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -252,8 +252,9 @@ void wb_blkcg_offline(struct blkcg *blkcg); int inode_congested(struct inode *inode, int cong_bits); /** - * inode_cgwb_enabled - test whether cgroup writeback is enabled on an inode - * @inode: inode of interest + * bdi_cgwb_enabled - test wether cgroup writeback is enabled on a filesystem + * @bdi: the bdi we care about + * @sb: the super for the bdi * * cgroup writeback requires support from both the bdi and filesystem. * Also, both memcg and iocg have to be on the default hierarchy. Test @@ -262,15 +263,25 @@ int inode_congested(struct inode *inode, int cong_bits); * Note that the test result may change dynamically on the same inode * depending on how memcg and iocg are configured. */ -static inline bool inode_cgwb_enabled(struct inode *inode) +static inline bool bdi_cgwb_enabled(struct backing_dev_info *bdi, + struct super_block *sb) { - struct backing_dev_info *bdi = inode_to_bdi(inode); - return cgroup_subsys_on_dfl(memory_cgrp_subsys) && cgroup_subsys_on_dfl(io_cgrp_subsys) && bdi_cap_account_dirty(bdi) && (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) && - (inode->i_sb->s_iflags & SB_I_CGROUPWB); + (sb->s_iflags & SB_I_CGROUPWB); +} + +/** + * inode_cgwb_enabled - test whether cgroup writeback is enabled on an inode + * @inode: inode of interest + * + * Does the inode have cgroup writeback support. + */ +static inline bool inode_cgwb_enabled(struct inode *inode) +{ + return bdi_cgwb_enabled(inode_to_bdi(inode), inode->i_sb); } /** @@ -413,6 +424,12 @@ static inline void unlocked_inode_to_wb_end(struct inode *inode, bool locked) #else /* CONFIG_CGROUP_WRITEBACK */ +static inline bool bdi_cgwb_enabled(struct backing_dev_info *bdi, + struct super_block *sb) +{ + return false; +} + static inline bool inode_cgwb_enabled(struct inode *inode) { return false; diff --git a/include/linux/writeback.h b/include/linux/writeback.h index fc1e16c..256ffc3 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -364,7 +364,8 @@ unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh); void wb_update_bandwidth(struct bdi_writeback *wb, unsigned long start_time); void page_writeback_init(void); -void balance_dirty_pages_ratelimited(struct address_space *mapping); +void balance_dirty_pages_ratelimited(struct backing_dev_info *bdi, + struct super_block *sb); bool wb_over_bg_thresh(struct bdi_writeback *wb); typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc, diff --git a/mm/filemap.c b/mm/filemap.c index 3083ded..abb0e98 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2667,6 +2667,7 @@ ssize_t generic_perform_write(struct file *file, struct iov_iter *i, loff_t pos) { struct address_space *mapping = file->f_mapping; + struct inode *inode = mapping->host; const struct address_space_operations *a_ops = mapping->a_ops; long status = 0; ssize_t written = 0; @@ -2746,7 +2747,8 @@ again: pos += copied; written += copied; - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } while (iov_iter_count(i)); return written ? written : status; diff --git a/mm/memory.c b/mm/memory.c index 83be99d..d43e73b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -2105,11 +2106,13 @@ static inline int wp_page_reuse(struct fault_env *fe, pte_t orig_pte, put_page(page); if ((dirtied || page_mkwrite) && mapping) { + struct inode *inode = mapping->host; /* * Some device drivers do not set page.mapping * but still dirty their pages */ - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } if (!page_mkwrite) @@ -3291,11 +3294,13 @@ static int do_shared_fault(struct fault_env *fe, pgoff_t pgoff) mapping = page_rmapping(fault_page); unlock_page(fault_page); if ((dirtied || vma->vm_ops->page_mkwrite) && mapping) { + struct inode *inode = mapping->host; /* * Some device drivers do not set page.mapping but still * dirty their pages */ - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } if (!vma->vm_ops->page_mkwrite) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index f4cd7d8..121a6e3 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1559,8 +1559,7 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc) * If we're over `background_thresh' then the writeback threads are woken to * perform some writeout. */ -static void balance_dirty_pages(struct address_space *mapping, - struct bdi_writeback *wb, +static void balance_dirty_pages(struct bdi_writeback *wb, unsigned long pages_dirtied) { struct dirty_throttle_control gdtc_stor = { GDTC_INIT(wb) }; @@ -1849,7 +1848,8 @@ DEFINE_PER_CPU(int, dirty_throttle_leaks) = 0; /** * balance_dirty_pages_ratelimited - balance dirty memory state - * @mapping: address_space which was dirtied + * @bdi: the bdi that was dirtied + * @sb: the super block that was dirtied * * Processes which are dirtying memory should call in here once for each page * which was newly dirtied. The function will periodically check the system's @@ -1860,10 +1860,9 @@ DEFINE_PER_CPU(int, dirty_throttle_leaks) = 0; * limit we decrease the ratelimiting by a lot, to prevent individual processes * from overshooting the limit by (ratelimit_pages) each. */ -void balance_dirty_pages_ratelimited(struct address_space *mapping) +void balance_dirty_pages_ratelimited(struct backing_dev_info *bdi, + struct super_block *sb) { - struct inode *inode = mapping->host; - struct backing_dev_info *bdi = inode_to_bdi(inode); struct bdi_writeback *wb = NULL; int ratelimit; int *p; @@ -1871,7 +1870,7 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) if (!bdi_cap_account_dirty(bdi)) return; - if (inode_cgwb_enabled(inode)) + if (bdi_cgwb_enabled(bdi, sb)) wb = wb_get_create_current(bdi, GFP_KERNEL); if (!wb) wb = &bdi->wb; @@ -1909,7 +1908,7 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) preempt_enable(); if (unlikely(current->nr_dirtied >= ratelimit)) - balance_dirty_pages(mapping, wb, current->nr_dirtied); + balance_dirty_pages(wb, current->nr_dirtied); wb_put(wb); }