From patchwork Tue Oct 25 18:41:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9395201 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 0302D6077F for ; Tue, 25 Oct 2016 18:42:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA88829714 for ; Tue, 25 Oct 2016 18:42:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE49129718; Tue, 25 Oct 2016 18:42:44 +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 883FA2970D for ; Tue, 25 Oct 2016 18:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933210AbcJYSme (ORCPT ); Tue, 25 Oct 2016 14:42:34 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:43943 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758016AbcJYSm3 (ORCPT ); Tue, 25 Oct 2016 14:42:29 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9PIeEAJ026296; Tue, 25 Oct 2016 11:41:59 -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=A7KrdZTcMmjdQ7ZNEAqi2KurRHml6LAk1ulfhxCwtENla5TShc1soDatTij2iTeBcqLi +YtE9HtDDBmmsJOSIXRKxaC2rHvS/ZKVad5ujaM+LGCTVz9pcnm+T/qkxswOM76JnDpk cAesDQF9B9aSRlx8XaXBoV7w5jQt2skJt2c= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 26aaag9rx9-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 25 Oct 2016 11:41:59 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.23) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 25 Oct 2016 11:41:58 -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=abjYwMR/KTx/Z/C+eYG4B33m5TU/gYHvtVwRipIxmqUI0ejhU4PIwg1abxLyAIX2X+ffEC7vlf5UntyqWlRBrX44gUqGCyJ7ozTNLD/0UfpN238PsmNETm/ItXUvIJ6V39VI+DleZl5xDnXCHoLKIeHiNbumOIFCyz36cRyXang= Received: from localhost (2606:a000:4381:1201:225:22ff:feb3:e51a) by CY4PR15MB1318.namprd15.prod.outlook.com (10.172.181.136) 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:41:55 +0000 From: Josef Bacik To: , , , , , , , Subject: [PATCH 1/5] remove mapping from balance_dirty_pages*() Date: Tue, 25 Oct 2016 14:41:40 -0400 Message-ID: <1477420904-1399-2-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: MWHPR02CA0010.namprd02.prod.outlook.com (10.168.209.148) To CY4PR15MB1318.namprd15.prod.outlook.com (10.172.181.136) X-MS-Office365-Filtering-Correlation-Id: f792860b-bcc3-4c45-dcc4-08d3fd069875 X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1318; 2:00UT8tBBVPx4+RVo6kalzos0PnSu9MvFtJsyyQWyrzjJEk8SYU818+bRNtw6nI1//nMmC1ZOFoRtcrQgaXbq98Xj8IOOrlnCOON2xuHNxKBHVZQ6g61p50IcvhJfg6NAd51drI1jRPlIWVFy/4P3gYm8eIE4y/PX2PO3DhCQyYqizs/zw6GYqfy+g3zxIfAtQbIGwOPBMs7cVWNQHU7/0A==; 3:Yv1vHLIQfb4lpY98ycZOJHAH+E8+1EuYDwuhWQKUAR/B5La8NO3dQTSfwH+PaHbnnJYBSOQXrjaJnsPRr8KZFcDsvlc1rGivwg8ycjYWP08jELgcVQF3Nf7mpA/3pgOwecw9egU/gbb7/izcUkMdKA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY4PR15MB1318; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1318; 25:IHW71rNJj+fhuKq+mxvNUQ8fvTREZC72N3cyyIirHI7A1HugGBEhZBWvgV8K6j5XKuT8amCMk5GqCKNDChy5wEnmd9na6EfYUNcmF/KUy+1hhvozpVN0hDWxN5eMTQZPeCitjuIjULuFO9rxL35P7q2QrQqGSNAgwrzcS3NwvACgZwPqXJZTjC9xAc+RzWzJGgftVfOmu2O/GXq5g/5day5HMg3y8y/UnTfeHkBwP1cKyDqH1plLtbGhiI8li8C/EjxkhCnygVpUvwflgQJyiMs5SyWps+CN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M/Mp6XodJhnimHU81AfYx314xarWWzKgnzFgxgIGQW9SpLKD9Y+BaWRUlONh2WyHoXOqXrgBAZ5Vb0IsbB+lfHrFahvpnhdAkmUxrPvhp77L9DL7TfbiE3HMyJ09fTymdZD/lCERHRnVVYei3l3kJRHMGAhtJSQK3BbfEaw6xgjnPzHF20VpDkmYR6TCcWTlks301V161Ne9/wQgje5KZJBIVNOX68Q4e48xH4MEaI481F+fMUPW/1gzEr3qL1zbr5eePFYo4HOgvKELKlx/oUx+u8+hEgxNq5+2tY8MYP5bN9zpGiHE3B9ktkJoYiA9WDeLeVpdmEjeiPXkJHj60UZhsm/X2zUnlkWkVg4auFQ== 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)(10201501046)(3002001); SRVR:CY4PR15MB1318; BCL:0; PCL:0; RULEID:; SRVR:CY4PR15MB1318; X-Forefront-PRVS: 01068D0A20 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(199003)(189002)(33646002)(6636002)(50986999)(68736007)(7846002)(48376002)(305945005)(7736002)(107886002)(106356001)(47776003)(92566002)(50466002)(105586002)(76506005)(189998001)(6116002)(76176999)(36756003)(2906002)(575784001)(5660300001)(5003940100001)(86362001)(42186005)(2950100002)(8676002)(586003)(97736004)(81156014)(229853001)(2201001)(50226002)(6666003)(19580395003)(77096005)(19580405001)(81166006)(101416001)(5001770100001)(14143004); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR15MB1318; 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; CY4PR15MB1318; 23:6QdDVYogb7PCNFimm7olRshnyheejLX1LY4MfK9Pi?= =?us-ascii?Q?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XCg/F0F4w4/WQGLTWOEbX2CsoFM8H8vLXh81RHxnz2xK80zlIta1FT7inBGPaQ5avaaXh2AvJr4n6Xz+3bPDchAeVbHDtx8o9T6QxZc4rwHaeadqK2FLWVsnxxqTeZQE/RL8bj/hhkoLtOiZKpLiyi8ISLtpMeziKxSgCNTuYWyw4WW0Oh9vgu8EAeZKYnkn1bIQgWHylBx8L6vZ9JSmsIy/pWeE/Zz8p8BFRCmyU49XJeRDj4b03hs4dl U78tYE04WjHnymfLUSc2sVgMLsX969Xk12M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1318; 20:OzrMLfh2Nl0vF9LFATq1ryOvQ0G66d4biwnGjFcXtUfh1V6ipxw7kpIeXojs6lgRlJugOT4yfK48qC0WlIQUvhzjg5npwDbtywP0mFrnYILtMiWRAKZgun3examyEkWKFrBpoKRbt3jfK0clZhB8EM/VwcwYzRCzRUc9kuE9640= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2016 18:41:55.5201 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1318 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 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 Acked-by: Tejun Heo --- 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); }