summaryrefslogtreecommitdiffstats
path: root/fs/hugetlbfs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-15 15:00:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-15 15:00:42 -0400
commit78dcf73421a879d22319d3889119945b85954a68 (patch)
tree26e76f3e9fdc6b40133f2158de23cfe74af9feac /fs/hugetlbfs
parent93ff81859733d9697a5a0cc4707e52fb17056abb (diff)
parentfdb254db21bb4aed44a0bc7fe993e58d3848c926 (diff)
Merge branch 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull ->s_options removal from Al Viro: "Preparations for fsmount/fsopen stuff (coming next cycle). Everything gets moved to explicit ->show_options(), killing ->s_options off + some cosmetic bits around fs/namespace.c and friends. Basically, the stuff needed to work with fsmount series with minimum of conflicts with other work. It's not strictly required for this merge window, but it would reduce the PITA during the coming cycle, so it would be nice to have those bits and pieces out of the way" * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: isofs: Fix isofs_show_options() VFS: Kill off s_options and helpers orangefs: Implement show_options 9p: Implement show_options isofs: Implement show_options afs: Implement show_options affs: Implement show_options befs: Implement show_options spufs: Implement show_options bpf: Implement show_options ramfs: Implement show_options pstore: Implement show_options omfs: Implement show_options hugetlbfs: Implement show_options VFS: Don't use save/replace_mount_options if not using generic_show_options VFS: Provide empty name qstr VFS: Make get_filesystem() return the affected filesystem VFS: Clean up whitespace in fs/namespace.c and fs/super.c Provide a function to create a NUL-terminated string from unterminated data
Diffstat (limited to 'fs/hugetlbfs')
-rw-r--r--fs/hugetlbfs/inode.c70
1 files changed, 56 insertions, 14 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 52388611635e..28d2753be094 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -46,13 +46,13 @@ static const struct inode_operations hugetlbfs_dir_inode_operations;
46static const struct inode_operations hugetlbfs_inode_operations; 46static const struct inode_operations hugetlbfs_inode_operations;
47 47
48struct hugetlbfs_config { 48struct hugetlbfs_config {
49 kuid_t uid; 49 struct hstate *hstate;
50 kgid_t gid; 50 long max_hpages;
51 umode_t mode; 51 long nr_inodes;
52 long max_hpages; 52 long min_hpages;
53 long nr_inodes; 53 kuid_t uid;
54 struct hstate *hstate; 54 kgid_t gid;
55 long min_hpages; 55 umode_t mode;
56}; 56};
57 57
58struct hugetlbfs_inode_info { 58struct hugetlbfs_inode_info {
@@ -861,6 +861,46 @@ static int hugetlbfs_error_remove_page(struct address_space *mapping,
861 return 0; 861 return 0;
862} 862}
863 863
864/*
865 * Display the mount options in /proc/mounts.
866 */
867static int hugetlbfs_show_options(struct seq_file *m, struct dentry *root)
868{
869 struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(root->d_sb);
870 struct hugepage_subpool *spool = sbinfo->spool;
871 unsigned long hpage_size = huge_page_size(sbinfo->hstate);
872 unsigned hpage_shift = huge_page_shift(sbinfo->hstate);
873 char mod;
874
875 if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID))
876 seq_printf(m, ",uid=%u",
877 from_kuid_munged(&init_user_ns, sbinfo->uid));
878 if (!gid_eq(sbinfo->gid, GLOBAL_ROOT_GID))
879 seq_printf(m, ",gid=%u",
880 from_kgid_munged(&init_user_ns, sbinfo->gid));
881 if (sbinfo->mode != 0755)
882 seq_printf(m, ",mode=%o", sbinfo->mode);
883 if (sbinfo->max_inodes != -1)
884 seq_printf(m, ",nr_inodes=%lu", sbinfo->max_inodes);
885
886 hpage_size /= 1024;
887 mod = 'K';
888 if (hpage_size >= 1024) {
889 hpage_size /= 1024;
890 mod = 'M';
891 }
892 seq_printf(m, ",pagesize=%lu%c", hpage_size, mod);
893 if (spool) {
894 if (spool->max_hpages != -1)
895 seq_printf(m, ",size=%llu",
896 (unsigned long long)spool->max_hpages << hpage_shift);
897 if (spool->min_hpages != -1)
898 seq_printf(m, ",min_size=%llu",
899 (unsigned long long)spool->min_hpages << hpage_shift);
900 }
901 return 0;
902}
903
864static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf) 904static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)
865{ 905{
866 struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry->d_sb); 906 struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry->d_sb);
@@ -1019,19 +1059,19 @@ static const struct super_operations hugetlbfs_ops = {
1019 .evict_inode = hugetlbfs_evict_inode, 1059 .evict_inode = hugetlbfs_evict_inode,
1020 .statfs = hugetlbfs_statfs, 1060 .statfs = hugetlbfs_statfs,
1021 .put_super = hugetlbfs_put_super, 1061 .put_super = hugetlbfs_put_super,
1022 .show_options = generic_show_options, 1062 .show_options = hugetlbfs_show_options,
1023}; 1063};
1024 1064
1025enum { NO_SIZE, SIZE_STD, SIZE_PERCENT }; 1065enum hugetlbfs_size_type { NO_SIZE, SIZE_STD, SIZE_PERCENT };
1026 1066
1027/* 1067/*
1028 * Convert size option passed from command line to number of huge pages 1068 * Convert size option passed from command line to number of huge pages
1029 * in the pool specified by hstate. Size option could be in bytes 1069 * in the pool specified by hstate. Size option could be in bytes
1030 * (val_type == SIZE_STD) or percentage of the pool (val_type == SIZE_PERCENT). 1070 * (val_type == SIZE_STD) or percentage of the pool (val_type == SIZE_PERCENT).
1031 */ 1071 */
1032static long long 1072static long
1033hugetlbfs_size_to_hpages(struct hstate *h, unsigned long long size_opt, 1073hugetlbfs_size_to_hpages(struct hstate *h, unsigned long long size_opt,
1034 int val_type) 1074 enum hugetlbfs_size_type val_type)
1035{ 1075{
1036 if (val_type == NO_SIZE) 1076 if (val_type == NO_SIZE)
1037 return -1; 1077 return -1;
@@ -1053,7 +1093,7 @@ hugetlbfs_parse_options(char *options, struct hugetlbfs_config *pconfig)
1053 substring_t args[MAX_OPT_ARGS]; 1093 substring_t args[MAX_OPT_ARGS];
1054 int option; 1094 int option;
1055 unsigned long long max_size_opt = 0, min_size_opt = 0; 1095 unsigned long long max_size_opt = 0, min_size_opt = 0;
1056 int max_val_type = NO_SIZE, min_val_type = NO_SIZE; 1096 enum hugetlbfs_size_type max_val_type = NO_SIZE, min_val_type = NO_SIZE;
1057 1097
1058 if (!options) 1098 if (!options)
1059 return 0; 1099 return 0;
@@ -1167,8 +1207,6 @@ hugetlbfs_fill_super(struct super_block *sb, void *data, int silent)
1167 struct hugetlbfs_config config; 1207 struct hugetlbfs_config config;
1168 struct hugetlbfs_sb_info *sbinfo; 1208 struct hugetlbfs_sb_info *sbinfo;
1169 1209
1170 save_mount_options(sb, data);
1171
1172 config.max_hpages = -1; /* No limit on size by default */ 1210 config.max_hpages = -1; /* No limit on size by default */
1173 config.nr_inodes = -1; /* No limit on number of inodes by default */ 1211 config.nr_inodes = -1; /* No limit on number of inodes by default */
1174 config.uid = current_fsuid(); 1212 config.uid = current_fsuid();
@@ -1189,6 +1227,10 @@ hugetlbfs_fill_super(struct super_block *sb, void *data, int silent)
1189 sbinfo->max_inodes = config.nr_inodes; 1227 sbinfo->max_inodes = config.nr_inodes;
1190 sbinfo->free_inodes = config.nr_inodes; 1228 sbinfo->free_inodes = config.nr_inodes;
1191 sbinfo->spool = NULL; 1229 sbinfo->spool = NULL;
1230 sbinfo->uid = config.uid;
1231 sbinfo->gid = config.gid;
1232 sbinfo->mode = config.mode;
1233
1192 /* 1234 /*
1193 * Allocate and initialize subpool if maximum or minimum size is 1235 * Allocate and initialize subpool if maximum or minimum size is
1194 * specified. Any needed reservations (for minimim size) are taken 1236 * specified. Any needed reservations (for minimim size) are taken