Skip to contentSkip to conversation

A few cleanup and fixup patches for hugetlbfs

PATCH In review Miaohe Lin 3 participants 12 messages Jul 26, 2022 – Jul 27, 2022

Subsystems (2)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

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
author
#1 lore raw

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
index 20336cb3c040..e998c416b85f 100644
@@ -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
author
#3 lore raw

PATCH v2 2/5 hugetlbfs: remove unneeded hugetlbfs_ops forward declaration

In reply to Miaohe Lin

The 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
index e998c416b85f..a10156df5726 100644
@@ -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
author
#5 lore raw

PATCH v2 3/5 hugetlbfs: remove unneeded header file

In reply to Miaohe Lin

The 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
index a10156df5726..aa7a5b8fc724 100644
@@ -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
author
#7 lore raw

PATCH v2 4/5 hugetlbfs: cleanup some comments in inode.c

In reply to Miaohe Lin

The 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
index aa7a5b8fc724..96c60aa3ab47 100644
@@ -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
Reviewed-by on v2 4/5
#8 lore raw

Re: [PATCH v2 4/5] hugetlbfs: cleanup some comments in inode.c

Quoted 7 lines · Miaohe Lin

The 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.

Thanks.

author
#9 lore raw

PATCH v2 5/5 hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()

In reply to Miaohe Lin

In 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
index 96c60aa3ab47..fe0e374b02a3 100644
@@ -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
Reviewed-by on v2 5/5
#10 lore raw

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_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(-)

Thanks,

Signature · 1 line
Mike Kravetz
Quoted 17 lines
fs/hugetlbfs/inode.c +1 -1
index 96c60aa3ab47..fe0e374b02a3 100644
@@ -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
Reviewed-by on v2 5/5
#11 lore raw

Re: [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()

In reply to Miaohe Lin
Quoted 6 lines · Miaohe Lin

In 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.

Thanks.