From patchwork Mon Oct 9 21:29:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 9994367 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 EA63460230 for ; Mon, 9 Oct 2017 21:29:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC8D52882D for ; Mon, 9 Oct 2017 21:29:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D172828830; Mon, 9 Oct 2017 21:29:50 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 25A022882D for ; Mon, 9 Oct 2017 21:29:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755419AbdJIV32 (ORCPT ); Mon, 9 Oct 2017 17:29:28 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:43265 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754404AbdJIV3X (ORCPT ); Mon, 9 Oct 2017 17:29:23 -0400 Received: by mail-qt0-f195.google.com with SMTP id a43so39875868qta.0; Mon, 09 Oct 2017 14:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GH2ueAbkhhrT5OSE8XwFfXEGNI8RF8YZpSus1nFx50w=; b=KG3+c0jxYxVcktUqvLIuSokJfzwcgFu+ZH24pQKqe8ebXqv0h/rVva7ZlsKzd24wlr RFM9TLmcOz6J8YfF/Ro/uUoyem2oHWcQxcGJ5FQU9FOSkAzT8OYgApDedm6tjL9enABj +Sm/Xo5CtGV5XJblNWyQYNa7MX1H0soxUFo4wckMo+jbNB08E1YabJZnGv5cXFr7XSPA M3g62y/GTwpZYxyYDzppRBEtrK5jG/spK6hGs/H6VP57h3tfk3l0me3AzlJ/dj68n9tH jz2RVVv3WtuNTVjzsg4HnGMuLT9s/eqJjDbJpOppu2B/N2oAiYs7oW5v/G6YIdFtzm6m Ww8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=GH2ueAbkhhrT5OSE8XwFfXEGNI8RF8YZpSus1nFx50w=; b=DNT/zsQ5eXNRvpw+vT9zjUXHwtssbCq7YVxRdeW6OCqYmiCmyDT7TltKfH1ydtOyM6 bnTsbmfcHp0WOvjGMZG/bAs2IvYagGyGMManEijojT51sAsbqcfkCrEmY0FVz3tEsiIZ n9pCK2vbChshn8NrQ3/kLcz178Q7rDhA4QLmgGu0hCXTCr5rtCmv8M4yzz8dtVWi0Drv tFBbR5Scg895cjF133qBijOZi3whQZQdkQKnPKsEVLb8gN/Z+6Mseml2ltztiN+XjUzc Wk81OrrUFIG3D6Bsa6vgqz4/i90fA9yglbyWJ60AH8zJy/Co3ZVMec1WB6xDylO5E0Tg ZWFA== X-Gm-Message-State: AMCzsaXYlEr8opCGZykNmKNAACGGpN9qPOBf7ANrML2GXgYhLkmHo1/i Pc0fm3DTvSEbi2GzWtwLFXU= X-Google-Smtp-Source: AOwi7QA5WzcpiApff8+HlqsZe48zISe0b9QNLmbWsKKAC7krisZhXWQGRf6f6ZmZ8pQDNZf+6IoH5Q== X-Received: by 10.200.42.11 with SMTP id k11mr3153846qtk.273.1507584561954; Mon, 09 Oct 2017 14:29:21 -0700 (PDT) Received: from localhost (dhcp-ec-8-6b-ed-7a-cf.cpe.echoes.net. [72.28.5.223]) by smtp.gmail.com with ESMTPSA id r16sm2183530qtc.4.2017.10.09.14.29.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 14:29:21 -0700 (PDT) From: Tejun Heo To: jack@suse.cz, axboe@kernel.dk, clm@fb.com, jbacik@fb.com Cc: kernel-team@fb.com, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, Tejun Heo , "Theodore Ts'o" , Andreas Dilger , linux-ext4@vger.kernel.org Subject: [PATCH 1/3] cgroup, writeback: replace SB_I_CGROUPWB with per-inode S_CGROUPWB Date: Mon, 9 Oct 2017 14:29:09 -0700 Message-Id: <20171009212911.473208-2-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171009212911.473208-1-tj@kernel.org> References: <20171009212911.473208-1-tj@kernel.org> 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 Currently, filesystem can indiate cgroup writeback support per superblock; however, depending on the filesystem, especially if inodes are used to carry metadata, it can be useful to indicate cgroup writeback support per inode. This patch replaces the superblock flag SB_I_CGROUPWB with per-inode S_CGROUPWB, so that cgroup writeback can be enabled selectively. * block_dev sets the new flag in bdget() when initializing new inode. * ext2/4 set the new flag in ext?_set_inode_flags() function. * btrfs sets the new flag in btrfs_update_iflags() function. Note that this automatically excludes btree_inode which doesn't use btrfs_update_iflags() during initialization. This is an intended behavior change. Signed-off-by: Tejun Heo Cc: Jan Kara Cc: Jens Axboe Cc: Chris Mason Cc: Josef Bacik Cc: linux-btrfs@vger.kernel.org Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: linux-ext4@vger.kernel.org Reviewed-by: Jan Kara --- fs/block_dev.c | 3 +-- fs/btrfs/ioctl.c | 4 +++- fs/btrfs/super.c | 1 - fs/ext2/inode.c | 3 ++- fs/ext2/super.c | 1 - fs/ext4/inode.c | 5 ++++- fs/ext4/super.c | 2 -- include/linux/backing-dev.h | 2 +- include/linux/fs.h | 3 ++- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 93d088f..ff9c282 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -800,8 +800,6 @@ static struct dentry *bd_mount(struct file_system_type *fs_type, { struct dentry *dent; dent = mount_pseudo(fs_type, "bdev:", &bdev_sops, NULL, BDEVFS_MAGIC); - if (!IS_ERR(dent)) - dent->d_sb->s_iflags |= SB_I_CGROUPWB; return dent; } @@ -893,6 +891,7 @@ struct block_device *bdget(dev_t dev) inode->i_mode = S_IFBLK; inode->i_rdev = dev; inode->i_bdev = bdev; + inode->i_flags |= S_CGROUPWB; inode->i_data.a_ops = &def_blk_aops; mapping_set_gfp_mask(&inode->i_data, GFP_USER); spin_lock(&bdev_lock); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 6c7a49f..117cc63 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -150,9 +150,11 @@ void btrfs_update_iflags(struct inode *inode) new_fl |= S_NOATIME; if (ip->flags & BTRFS_INODE_DIRSYNC) new_fl |= S_DIRSYNC; + new_fl |= S_CGROUPWB; set_mask_bits(&inode->i_flags, - S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | S_DIRSYNC, + S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | S_DIRSYNC | + S_CGROUPWB, new_fl); } diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 35a128a..46a1488 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1136,7 +1136,6 @@ static int btrfs_fill_super(struct super_block *sb, sb->s_flags |= MS_POSIXACL; #endif sb->s_flags |= MS_I_VERSION; - sb->s_iflags |= SB_I_CGROUPWB; err = super_setup_bdi(sb); if (err) { diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 4dca6f3..3c5d822 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1372,7 +1372,7 @@ void ext2_set_inode_flags(struct inode *inode) unsigned int flags = EXT2_I(inode)->i_flags; inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | - S_DIRSYNC | S_DAX); + S_DIRSYNC | S_DAX | S_CGROUPWB); if (flags & EXT2_SYNC_FL) inode->i_flags |= S_SYNC; if (flags & EXT2_APPEND_FL) @@ -1385,6 +1385,7 @@ void ext2_set_inode_flags(struct inode *inode) inode->i_flags |= S_DIRSYNC; if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode)) inode->i_flags |= S_DAX; + inode->i_flags |= S_CGROUPWB; } struct inode *ext2_iget (struct super_block *sb, unsigned long ino) diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 1458706..e6ba669e 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -922,7 +922,6 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); - sb->s_iflags |= SB_I_CGROUPWB; if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 31db875..344f12b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4591,8 +4591,11 @@ void ext4_set_inode_flags(struct inode *inode) !ext4_should_journal_data(inode) && !ext4_has_inline_data(inode) && !ext4_encrypted_inode(inode)) new_fl |= S_DAX; + if (test_opt(inode->i_sb, DATA_FLAGS) != EXT4_MOUNT_JOURNAL_DATA) + new_fl |= S_CGROUPWB; inode_set_flags(inode, new_fl, - S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX); + S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX| + S_CGROUPWB); } static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode, diff --git a/fs/ext4/super.c b/fs/ext4/super.c index b104096..44ddf1d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3620,8 +3620,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) } if (test_opt(sb, DELALLOC)) clear_opt(sb, DELALLOC); - } else { - sb->s_iflags |= SB_I_CGROUPWB; } sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 854e1bd..7274de0 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -246,7 +246,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode) 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); + IS_CGROUPWB(inode); } /** diff --git a/include/linux/fs.h b/include/linux/fs.h index 13dab19..be2d8a6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1308,7 +1308,6 @@ extern int send_sigurg(struct fown_struct *fown); #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ /* sb->s_iflags */ -#define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */ #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */ #define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */ @@ -1853,6 +1852,7 @@ struct super_operations { #else #define S_DAX 0 /* Make all the DAX code disappear */ #endif +#define S_CGROUPWB 16384 /* Enable cgroup writeback for this inode */ /* * Note that nosuid etc flags are inode-specific: setting some file-system @@ -1892,6 +1892,7 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) #define IS_DAX(inode) ((inode)->i_flags & S_DAX) +#define IS_CGROUPWB(inode) ((inode)->i_flags & S_CGROUPWB) #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV)