From patchwork Mon Oct 24 20:43: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: 9393241 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 C4C9D6077A for ; Mon, 24 Oct 2016 20:44:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B48D82574A for ; Mon, 24 Oct 2016 20:44:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8AC1288CD; Mon, 24 Oct 2016 20:44:42 +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 38F2C2574A for ; Mon, 24 Oct 2016 20:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964952AbcJXUof (ORCPT ); Mon, 24 Oct 2016 16:44:35 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:54102 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757784AbcJXUoa (ORCPT ); Mon, 24 Oct 2016 16:44:30 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9OKdNFV027617; Mon, 24 Oct 2016 13:44:07 -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=PTw7IIV+SS7queCJY3x7gQ0bMb6jPznFJ2VHVooa5Fs=; b=nLiuTB7JtNnFDr9U7EZxlPG45VZ6cD3b6DRiA6OpMo38Zi3vZe+QhwxqTIRAQ326S3T9 qrCVhCmj/cqj65ZycJTNTduwfiynqtpNsuurI86eaJBXvZwvfJquwTjmmyCbV9FEsNs1 kAXgzYpF/KbJ1nlqKVYxJi2lPrgtVMyc22w= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 269r960jk7-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 24 Oct 2016 13:44:07 -0700 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.12) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 24 Oct 2016 13:44:06 -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=4b9FIQJqUouqmmAiCaxyKRpLEU5lOq8s+E8mVKea838=; b=OYQug4HfxFEIFoNCRkPm4D36QHmGGysvD89/ahsJGysEsn9k9w6StvYnWKQb3ECRI0eRn6aYv/EXZaTfWrD2WCyVhZ0zXM0cesBAiLQfWk/rggHRelspXv1ppoUKRo/D6CuzgcNB4pz0zuQSgsypXmqI86Oicm9aHhEN4Rq3PgE= Received: from localhost (2606:a000:4381:1201:225:22ff:feb3:e51a) by BN6PR15MB1316.namprd15.prod.outlook.com (10.172.206.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Mon, 24 Oct 2016 20:44:03 +0000 From: Josef Bacik To: , , , , , , , , Subject: [PATCH 1/5] remove mapping from balance_dirty_pages*() Date: Mon, 24 Oct 2016 16:43:45 -0400 Message-ID: <1477341829-18673-2-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: DM5PR08CA0004.namprd08.prod.outlook.com (10.175.218.14) To BN6PR15MB1316.namprd15.prod.outlook.com (10.172.206.142) X-MS-Office365-Filtering-Correlation-Id: a7d17333-63b3-4c94-09b4-08d3fc4e7dc9 X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1316; 2:CWDdmtvbg9oPiqFlzgJBLT+NFFR4l/vMkxU86wv//ByxwTC+VnBb2r+hSx4ms5r/aE2w/pJoWJ826g7DNjqGcHF5dSHJvfITOM2o/m871RQ2L4X+axx0rLonUDX3CpLSIiXAlKOF1K9e+QwhT6mer6kRQ1roSRPqb/MVmXQum/6YfLQRXY6ctfLwwWviUhUYkWR3GhQvXoINNUILUVF4zg==; 3:Oor/OJfs6rr2XWzlbdRkyTyRRLu2HG316k9VOJwkvaMSKSJ/yrCAfF8OWYwTmTFgqcZ8+GS1u7TsJcPEUltnHNF0y5CnKBpzk4mSFtviTH7ZIhE+2kaBiJUEw+CcJiQLbkEeIrI7MuR+wLOWhe2/Wg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR15MB1316; X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1316; 25:EfZhUtVq8GJ6EZV3SQE1c6+w9sIIVjZBKYotCCgOc2u2WS3kexQwD225kVX2BxwBC9POtsv45kD0mSX4FzBPDeKo6hVZT70U+SsYTnBroQhoFoLTHQYjU9DWsWj6RiXbZC1IaPOwScl984cBZ/4QRLvJlMtqRY11wFQ/eW0v7ZBXRg2fpIjQgIRt9cLDzw4cMaQl+qAlYluygVlBNd4htou5dk2BnlgTghfshrnPB2irH/LYQ5EBaNS1rXmfj66srHYGKcKyL7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GAoXRSQ1Ojax3sTgk/t4S/jbSHV2C6lkHeyxPpfk8DTGtzzbq5fDvyfFo4hn6t16IsdppGU8alT/c/19aHbfKkgatksbfKArOLjAHEbYQNhKbBj27glhrrQgfi5usWwuVr1mqdJfe311EldCwoPeJKQpCoJGUpY8pBkBdkpOBFmhS4UNoQDWNuc+DBDjMAHiiVWk53YF7hTvpOK5j/jaJaSKQUbZDY0Q6UXEFnji8vP5GjpHcnlgdrskrTOZ76T3S9wnkCk+QsEwlTg42LvnS9nEZz9TmSah0aFp/WxqjNvizMZK0eczIf/a7cSjPsXT0gl4EueYec063iZVmKoHsFYHtJmb0Du9Kgpzrrlg== 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:BN6PR15MB1316; BCL:0; PCL:0; RULEID:; SRVR:BN6PR15MB1316; X-Forefront-PRVS: 0105DAA385 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(81156014)(107886002)(86362001)(189998001)(101416001)(575784001)(6666003)(5003940100001)(8676002)(5001770100001)(2201001)(81166006)(6636002)(7846002)(305945005)(76176999)(33646002)(50986999)(92566002)(77096005)(48376002)(76506005)(50226002)(42186005)(36756003)(50466002)(7736002)(6116002)(19580395003)(105586002)(2906002)(106356001)(586003)(68736007)(5660300001)(229853001)(2950100002)(19580405001)(97736004)(47776003)(14143004)(2101003); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR15MB1316; 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; BN6PR15MB1316; 23:EkAPXnq9MCnqVab/MQnQMGRsgrc8p7nv4vPErwNY8?= =?us-ascii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QyNqIZmyPPGVeRzbhvY7dZZbHihu5zA7RDvZihUlso44BPJvm38cJAPQ3dXSaCAKydis/JQ3ryKabuUgDmvwUErl+8QswfTqe8kYIwpJKyWk4JkCOXNtQ+d8i7v1WBE/twlerA4txlAtPCW+4layapsUwi6ts5dCIIVlxGO6hqI0d6+rPNxM3QAGN5jXzAZQj/UEeBQZztiM0N44Roo0oYLebj0hs8bhIemh85IxP3JJaeMQsMArcV0NgPcetczJMC1izRKU18kEyRie zLmZoXcbl4Y4Lpb49vtm8fn8+95PcqKTD7c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR15MB1316; 20:lOQf39yvyppgtguXpLDSyoojMwY2GYfJGuL5LYtTp9HUdY+FlUCWcfPkINlkAUgwHsQo334OK/wvM6gzHzOgmu4kPMGXYkzRSQ2Zh2a23R16IAeZbnl9F3n+bQgkvnNkJf8YauE/C51/k9mQuaYim24OXCbJiMQMJ0aTDB+M/Mw= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2016 20:44:03.4275 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR15MB1316 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 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 e720d3e..fa07e81 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4085,8 +4085,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 72a180d..cbefdc8 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1711,7 +1711,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 af69129..f68692a 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 0ec8ffa..de4f221 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -3228,7 +3228,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 706270f..9025c43 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 43b93a9..9eb2cf2 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -253,8 +253,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 @@ -263,15 +264,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); } /** @@ -414,6 +425,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 8a287df..03fa60a 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 793fe0f..b47a73f 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); }