2022-07-26 14:36:54

by Miaohe Lin

[permalink] [raw]
Subject: [PATCH v2 0/5] 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(-)

--
2.23.0


2022-07-26 14:36:56

by Miaohe Lin

[permalink] [raw]
Subject: [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration

The forward declaration for hugetlbfs_ops is unnecessary. Remove it.

Signed-off-by: Miaohe Lin <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
---
fs/hugetlbfs/inode.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index e998c416b85f..a10156df5726 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -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;
--
2.23.0

2022-07-26 14:36:59

by Miaohe Lin

[permalink] [raw]
Subject: [PATCH v2 3/5] hugetlbfs: remove unneeded header file

The header file signal.h is unneeded now. Remove it.

Signed-off-by: Miaohe Lin <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
---
fs/hugetlbfs/inode.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a10156df5726..aa7a5b8fc724 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -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>
--
2.23.0

2022-07-26 14:37:04

by Miaohe Lin

[permalink] [raw]
Subject: [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()

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.

Signed-off-by: Miaohe Lin <[email protected]>
---
fs/hugetlbfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 96c60aa3ab47..fe0e374b02a3 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -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;
--
2.23.0

2022-07-26 15:04:25

by Miaohe Lin

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

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.

Signed-off-by: Miaohe Lin <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
---
fs/hugetlbfs/inode.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index aa7a5b8fc724..96c60aa3ab47 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -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,
--
2.23.0

2022-07-26 21:57:19

by Mike Kravetz

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

On 07/26/22 22:29, Miaohe Lin wrote:
> 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.
>
> Signed-off-by: Miaohe Lin <[email protected]>
> ---
> fs/hugetlbfs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,

Reviewed-by: Mike Kravetz <[email protected]>

--
Mike Kravetz

>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 96c60aa3ab47..fe0e374b02a3 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -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;
> --
> 2.23.0
>

2022-07-27 06:47:07

by Muchun Song

[permalink] [raw]
Subject: Re: [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration

On Tue, Jul 26, 2022 at 10:29:15PM +0800, Miaohe Lin wrote:
> The forward declaration for hugetlbfs_ops is unnecessary. Remove it.
>
> Signed-off-by: Miaohe Lin <[email protected]>
> Reviewed-by: Mike Kravetz <[email protected]>

Reviewed-by: Muchun Song <[email protected]>

Thanks.

2022-07-27 06:48:57

by Muchun Song

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] hugetlbfs: remove unneeded header file

On Tue, Jul 26, 2022 at 10:29:16PM +0800, Miaohe Lin wrote:
> The header file signal.h is unneeded now. Remove it.
>
> Signed-off-by: Miaohe Lin <[email protected]>
> Reviewed-by: Mike Kravetz <[email protected]>

Reviewed-by: Muchun Song <[email protected]>

Thanks.

2022-07-27 06:49:21

by Muchun Song

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

On Tue, Jul 26, 2022 at 10:29:17PM +0800, Miaohe Lin wrote:
> 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.
>
> Signed-off-by: Miaohe Lin <[email protected]>
> Reviewed-by: Mike Kravetz <[email protected]>

Reviewed-by: Muchun Song <[email protected]>

Thanks.

2022-07-27 07:00:13

by Muchun Song

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

On Tue, Jul 26, 2022 at 10:29:18PM +0800, Miaohe Lin wrote:
> 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.
>
> Signed-off-by: Miaohe Lin <[email protected]>

Reviewed-by: Muchun Song <[email protected]>

Thanks.