* [PATCH] proc: introduce proc_statfs()
@ 2023-01-10 15:20 Chao Yu
2023-01-10 17:58 ` Alexey Dobriyan
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2023-01-10 15:20 UTC (permalink / raw)
To: akpm, adobriyan; +Cc: viro, linux-kernel, linux-fsdevel, Chao Yu
Introduce proc_statfs() to replace simple_statfs(), so that
f_bsize queried from statfs() can be consistent w/ the value we
set in s_blocksize.
stat -f /proc/
Before:
ID: 0 Namelen: 255 Type: proc
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 0 Free: 0 Available: 0
Inodes: Total: 0 Free: 0
After:
ID: 0 Namelen: 255 Type: proc
Block size: 1024 Fundamental block size: 1024
Blocks: Total: 0 Free: 0 Available: 0
Inodes: Total: 0 Free: 0
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/proc/inode.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index f495fdb39151..d39e3b9b3135 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -25,6 +25,7 @@
#include <linux/slab.h>
#include <linux/mount.h>
#include <linux/bug.h>
+#include <linux/statfs.h>
#include "internal.h"
@@ -176,6 +177,14 @@ static inline const char *hidepid2str(enum proc_hidepid v)
return "unknown";
}
+static int proc_statfs(struct dentry *dentry, struct kstatfs *buf)
+{
+ buf->f_type = dentry->d_sb->s_magic;
+ buf->f_bsize = dentry->d_sb->s_blocksize;
+ buf->f_namelen = PROC_NAME_LEN;
+ return 0;
+}
+
static int proc_show_options(struct seq_file *seq, struct dentry *root)
{
struct proc_fs_info *fs_info = proc_sb_info(root->d_sb);
@@ -195,7 +204,7 @@ const struct super_operations proc_sops = {
.free_inode = proc_free_inode,
.drop_inode = generic_delete_inode,
.evict_inode = proc_evict_inode,
- .statfs = simple_statfs,
+ .statfs = proc_statfs,
.show_options = proc_show_options,
};
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] proc: introduce proc_statfs()
2023-01-10 15:20 [PATCH] proc: introduce proc_statfs() Chao Yu
@ 2023-01-10 17:58 ` Alexey Dobriyan
2023-01-11 9:20 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2023-01-10 17:58 UTC (permalink / raw)
To: Chao Yu; +Cc: akpm, viro, linux-kernel, linux-fsdevel
On Tue, Jan 10, 2023 at 11:20:03PM +0800, Chao Yu wrote:
> Introduce proc_statfs() to replace simple_statfs(), so that
> f_bsize queried from statfs() can be consistent w/ the value we
> set in s_blocksize.
>
> stat -f /proc/
>
> Before:
> ID: 0 Namelen: 255 Type: proc
> Block size: 4096 Fundamental block size: 4096
> Blocks: Total: 0 Free: 0 Available: 0
> Inodes: Total: 0 Free: 0
>
> After:
> ID: 0 Namelen: 255 Type: proc
> Block size: 1024 Fundamental block size: 1024
> Blocks: Total: 0 Free: 0 Available: 0
> Inodes: Total: 0 Free: 0
4096 is better value is in fact.
seq_files allocate 1 page and fill it, therefore reading less than
PAGE_SIZE from /proc is mostly waste of syscalls.
I doubt anything uses f_bsize.
BTW this patch is not self contained.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] proc: introduce proc_statfs()
2023-01-10 17:58 ` Alexey Dobriyan
@ 2023-01-11 9:20 ` Chao Yu
0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2023-01-11 9:20 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: akpm, viro, linux-kernel, linux-fsdevel
On 2023/1/11 1:58, Alexey Dobriyan wrote:
> On Tue, Jan 10, 2023 at 11:20:03PM +0800, Chao Yu wrote:
>> Introduce proc_statfs() to replace simple_statfs(), so that
>> f_bsize queried from statfs() can be consistent w/ the value we
>> set in s_blocksize.
>>
>> stat -f /proc/
>>
>> Before:
>> ID: 0 Namelen: 255 Type: proc
>> Block size: 4096 Fundamental block size: 4096
>> Blocks: Total: 0 Free: 0 Available: 0
>> Inodes: Total: 0 Free: 0
>>
>> After:
>> ID: 0 Namelen: 255 Type: proc
>> Block size: 1024 Fundamental block size: 1024
>> Blocks: Total: 0 Free: 0 Available: 0
>> Inodes: Total: 0 Free: 0
>
> 4096 is better value is in fact.
>
> seq_files allocate 1 page and fill it, therefore reading less than
> PAGE_SIZE from /proc is mostly waste of syscalls.
Ah, thanks for correcting me, so, how about updating .s_blocksize and
.s_blocksize_bits to PAGE_SIZE and PAGE_SHIFT?
>
> I doubt anything uses f_bsize.
>
> BTW this patch is not self contained.
Oh, yes, my bad.
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-11 9:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-10 15:20 [PATCH] proc: introduce proc_statfs() Chao Yu
2023-01-10 17:58 ` Alexey Dobriyan
2023-01-11 9:20 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).