A few cleanup and fixup patches for hugetlbfs
Subsystems (2)
v2 cover A few cleanup and fixup patches for hugetlbfs
Hi everyone,
This series contains a few cleaup patches to remove unneeded forward declaration, use helper macro and so on. More details can be found in the respective changelogs.
Thanks!
---
v2:
collect Reviewed-by tag per Mike.
reshape the comment of 4/5 per Mike.
drop code change in 5/5 and change to correct the comment per Mike. Many thanks Mike for review.
---
Miaohe Lin (5):
hugetlbfs: use helper macro SZ_1{K,M}
hugetlbfs: remove unneeded hugetlbfs_ops forward declaration
hugetlbfs: remove unneeded header file
hugetlbfs: cleanup some comments in inode.c
hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()
fs/hugetlbfs/inode.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
Signature · 1 line
2.23.0
PATCH v2 1/5 hugetlbfs: use helper macro SZ_1{K,M}
Use helper macro SZ_1K and SZ_1M to do the size conversion. Minor readability improvement.
--- fs/hugetlbfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/hugetlbfs/inode.c +2 -2
@@ -1309,7 +1309,7 @@ static int hugetlbfs_parse_param(struct fs_context *fc, struct fs_parameter *par ps =memparse (param->string, &rest); ctx->hstate =size_to_hstate (ps);if (!ctx->hstate) { -pr_err ("Unsupported page size %lu MB\n" , ps >>20 ); +pr_err ("Unsupported page size %lu MB\n" , ps /SZ_1M );return -EINVAL ; }return 0 ;
@@ -1555,7 +1555,7 @@ static struct vfsmount *__init mount_one_hugetlbfs(struct hstate *h) }if (IS_ERR (mnt))pr_err ("Cannot mount internal hugetlbfs for page size %luK" , -huge_page_size (h) >>10 ); +huge_page_size (h) /SZ_1K );return mnt; }
Signature · 1 line
2.23.0
Re: [PATCH v2 1/5] hugetlbfs: use helper macro SZ_1{K,M}
Quoted 5 lines · Miaohe Lin
Use helper macro
SZ_1KandSZ_1Mto do the size conversion. Minor readability improvement.Signed-off-by Miaohe Lin <[email protected]>Reviewed-by Mike Kravetz <[email protected]>
Thanks.
PATCH v2 2/5 hugetlbfs: remove unneeded hugetlbfs_ops forward declaration
In reply to Miaohe LinThe forward declaration for hugetlbfs_ops is unnecessary. Remove it.
--- fs/hugetlbfs/inode.c | 1 - 1 file changed, 1 deletion(-)
fs/hugetlbfs/inode.c +0 -1
@@ -40,7 +40,6 @@#include <linux/uaccess.h> #include <linux/sched/mm.h> -static const struct super_operations hugetlbfs_ops;static const struct address_space_operations hugetlbfs_aops;const struct file_operations hugetlbfs_file_operations;static const struct inode_operations hugetlbfs_dir_inode_operations;
Signature · 1 line
2.23.0
Re: [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration
Quoted 4 lines · Miaohe Lin
The forward declaration for
hugetlbfs_opsis unnecessary. Remove it.Signed-off-by Miaohe Lin <[email protected]>Reviewed-by Mike Kravetz <[email protected]>
Thanks.
PATCH v2 3/5 hugetlbfs: remove unneeded header file
In reply to Miaohe LinThe header file signal.h is unneeded now. Remove it.
--- fs/hugetlbfs/inode.c | 1 - 1 file changed, 1 deletion(-)
fs/hugetlbfs/inode.c +0 -1
@@ -11,7 +11,6 @@#include <linux/thread_info.h> #include <asm/current.h> -#include <linux/sched/signal.h> /* remove ASAP */ #include <linux/falloc.h> #include <linux/fs.h> #include <linux/mount.h>
Signature · 1 line
2.23.0
Re: [PATCH v2 3/5] hugetlbfs: remove unneeded header file
Quoted 4 lines · Miaohe Lin
The header file
signal.his unneeded now. Remove it.Signed-off-by Miaohe Lin <[email protected]>Reviewed-by Mike Kravetz <[email protected]>
Thanks.
PATCH v2 4/5 hugetlbfs: cleanup some comments in inode.c
In reply to Miaohe LinThe function generic_file_buffered_read has been renamed to filemap_read since commit 87fa0f3eb267 ("mm/filemap: rename generic_file_buffered_read to filemap_read"). Update the corresponding comment. And duplicated taken in hugetlbfs_fill_super is removed.
--- fs/hugetlbfs/inode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/hugetlbfs/inode.c +2 -3
@@ -313,8 +313,7 @@ hugetlbfs_read_actor(struct page *page, unsigned long offset,/* * Support for read() - Find the page attached to f_mapping and copy out the -* data. Its *very* similar to generic_file_buffered_read(), we can't use that -* since it has PAGE_SIZE assumptions. +* data. This provides functionality similar to filemap_read(). */ static ssize_t hugetlbfs_read_iter (struct kiocb *iocb,struct iov_iter *to) {
@@ -1383,7 +1382,7 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc)/* * Allocate and initialize subpool if maximum or minimum size is * specified. Any needed reservations (for minimum size) are taken -* taken when the subpool is created. +* when the subpool is created. */ if (ctx->max_hpages !=-1 || ctx->min_hpages !=-1 ) { sbinfo->spool = hugepage_new_subpool(ctx->hstate,
Signature · 1 line
2.23.0
Re: [PATCH v2 4/5] hugetlbfs: cleanup some comments in inode.c
Quoted 7 lines · Miaohe Lin
The function
generic_file_buffered_readhas been renamed tofilemap_readsince commit87fa0f3eb267("mm/filemap: renamegeneric_file_buffered_readtofilemap_read"). Update the corresponding comment. And duplicated taken inhugetlbfs_fill_superis removed.Signed-off-by Miaohe Lin <[email protected]>Reviewed-by Mike Kravetz <[email protected]>
Thanks.
PATCH v2 5/5 hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()
In reply to Miaohe LinIn some cases, e.g. when size option is not specified, f_blocks, f_bavail and f_bfree will be set to -1 instead of 0. Likewise, when nr_inodes isn't specified, f_files and f_ffree will be set to -1 too. Update the comment to make this clear.
--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/hugetlbfs/inode.c +1 -1
@@ -1079,7 +1079,7 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_bsize =huge_page_size (h);if (sbinfo) {spin_lock (&sbinfo->stat_lock); -/* If no limits set, just report 0 for max/free/used +/* If no limits set, just report 0 or -1 for max/free/used * blocks, like simple_statfs() */ if (sbinfo->spool) {long free_pages;
Signature · 1 line
2.23.0
Re: [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()
Quoted 9 lines · Miaohe Lin
In some cases, e.g. when size option is not specified,
f_blocks,f_bavailandf_bfreewill be set to -1 instead of 0. Likewise, whennr_inodesisn't specified,f_filesandf_ffreewill be set to -1 too. Update the comment to make this clear.Signed-off-by Miaohe Lin <[email protected]>--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks,
Signature · 1 line
Mike Kravetz
Quoted 17 lines
fs/hugetlbfs/inode.c +1
-1@@ -1079,7 +1079,7 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_bsize =huge_page_size (h);if (sbinfo) {spin_lock (&sbinfo->stat_lock); -/* If no limits set, just report 0 for max/free/used +/* If no limits set, just report 0 or -1 for max/free/used * blocks, like simple_statfs() */ if (sbinfo->spool) {long free_pages;Signature · 1 line
2.23.0
Re: [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()
In reply to Miaohe LinQuoted 6 lines · Miaohe Lin
In some cases, e.g. when size option is not specified,
f_blocks,f_bavailandf_bfreewill be set to -1 instead of 0. Likewise, whennr_inodesisn't specified,f_filesandf_ffreewill be set to -1 too. Update the comment to make this clear.Signed-off-by Miaohe Lin <[email protected]>
Thanks.