History

vfs, writeback: replace FS_CGROUP_WRITEBACK with SB_I_CGROUPWB

FS_CGROUP_WRITEBACK indicates whether a file_system_type supports cgroup writeback; however, different super_blocks of the same file_system_type may or may not support cgroup writeback depending on filesystem options. This patch replaces FS_CGROUP_WRITEBACK with a per-super_block flag. super_block->s_flags carries some internal flags in the high bits but it's exposd to userland through uapi header and running out of space anyway. This patch adds a new field super_block->s_iflags to carry kernel-internal flags. It is currently only used by the new SB_I_CGROUPWB flag whose concatenated and abbreviated name is for consistency with other super_block flags. ext2_fill_super() is updated to set SB_I_CGROUPWB. v2: Added super_block->s_iflags instead of stealing another high bit from sb->s_flags as suggested by Christoph and Jan.

Tejun Heo committed 11 years ago

Commit 46b15ca1 parent dd73e4b3 files · +6 −3Browse files

Unified · Split

3 files
  1. fs/ext2/super.c +2 −1
  2. include/linux/backing-dev.h +1 −1
  3. include/linux/fs.h +3 −1
fs/ext2/super.c+2−1
@@ -882,6 +882,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) · 881 unmodified lines
882 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |882 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
883 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?883 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
884 MS_POSIXACL : 0);884 MS_POSIXACL : 0);
885 sb->s_iflags |= SB_I_CGROUPWB;
885 886
886 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&887 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&
887 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||888 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
@@ -1543,7 +1544,7 @@ static struct file_system_type ext2_fs_type = { · 655 unmodified lines
1543 .name = "ext2",1544 .name = "ext2",
1544 .mount = ext2_mount,1545 .mount = ext2_mount,
1545 .kill_sb = kill_block_super,1546 .kill_sb = kill_block_super,
1546 .fs_flags = FS_REQUIRES_DEV | FS_CGROUP_WRITEBACK,1547 .fs_flags = FS_REQUIRES_DEV,
1547};1548};
1548MODULE_ALIAS_FS("ext2");1549MODULE_ALIAS_FS("ext2");
1549 1550
include/linux/backing-dev.h+1−1
@@ -260,7 +260,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode) · 259 unmodified lines
260 260
261 return bdi_cap_account_dirty(bdi) &&261 return bdi_cap_account_dirty(bdi) &&
262 (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) &&262 (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) &&
263 (inode->i_sb->s_type->fs_flags & FS_CGROUP_WRITEBACK);263 (inode->i_sb->s_iflags & SB_I_CGROUPWB);
264}264}
265 265
266/**266/**
include/linux/fs.h+3−1
@@ -1241,6 +1241,8 @@ struct mm_struct; · 1240 unmodified lines
1241#define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */1241#define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */
1242#define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */1242#define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */
1243 1243
1244/* sb->s_iflags */
1245#define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */
1244 1246
1245/* Possible states of 'frozen' field */1247/* Possible states of 'frozen' field */
1246enum {1248enum {
@@ -1279,6 +1281,7 @@ struct super_block { · 32 unmodified lines
1279 const struct quotactl_ops *s_qcop;1281 const struct quotactl_ops *s_qcop;
1280 const struct export_operations *s_export_op;1282 const struct export_operations *s_export_op;
1281 unsigned long s_flags;1283 unsigned long s_flags;
1284 unsigned long s_iflags; /* internal SB_I_* flags */
1282 unsigned long s_magic;1285 unsigned long s_magic;
1283 struct dentry *s_root;1286 struct dentry *s_root;
1284 struct rw_semaphore s_umount;1287 struct rw_semaphore s_umount;
@@ -1912,7 +1915,6 @@ struct file_system_type { · 627 unmodified lines
1912#define FS_HAS_SUBTYPE 41915#define FS_HAS_SUBTYPE 4
1913#define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */1916#define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */
1914#define FS_USERNS_DEV_MOUNT 16 /* A userns mount does not imply MNT_NODEV */1917#define FS_USERNS_DEV_MOUNT 16 /* A userns mount does not imply MNT_NODEV */
1915#define FS_CGROUP_WRITEBACK 32 /* Supports cgroup-aware writeback */
1916#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */1918#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
1917 struct dentry *(*mount) (struct file_system_type *, int,1919 struct dentry *(*mount) (struct file_system_type *, int,
1918 const char *, void *);1920 const char *, void *);