diff mbox series

fuse: set limit size

Message ID 20210615064155.911-1-jzp0409@163.com (mailing list archive)
State New
Headers show
Series fuse: set limit size | expand

Commit Message

jzp0409 June 15, 2021, 6:41 a.m. UTC
From: "edison.jiang" <jiangzhipeng@yulong.com>

Android-R /sdcard mount FUSE filesystem type,
use "dd" command to filli up /sdcard dir,
Android will not boot normal,
becase this system need at least 128M userspace.

Test: open adb port,
      adb shell "dd if=dev/zero of=sdcard/ae bs=1024000 count=xxx"

Result: if not limit size,Android system  can not boot normal.

Signed-off-by: edison.jiang <jiangzhipeng@yulong.com>
---
 fs/fuse/inode.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Miklos Szeredi June 18, 2021, 7:10 a.m. UTC | #1
On Tue, 15 Jun 2021 at 08:41, jzp0409 <jzp0409@163.com> wrote:
>
> From: "edison.jiang" <jiangzhipeng@yulong.com>
>
> Android-R /sdcard mount FUSE filesystem type,
> use "dd" command to filli up /sdcard dir,
> Android will not boot normal,
> becase this system need at least 128M userspace.
>
> Test: open adb port,
>       adb shell "dd if=dev/zero of=sdcard/ae bs=1024000 count=xxx"
>
> Result: if not limit size,Android system  can not boot normal.

Without understanding the specifics, this does not look like a kernel
issue at all.

Why can't the fuse server do the limiting?

Thanks,
Miklos
Miklos Szeredi June 18, 2021, 9:55 a.m. UTC | #2
On Fri, 18 Jun 2021 at 11:51, 蒋志鹏 <jzp0409@163.com> wrote:
>
> At 2021-06-18 15:10:27, "Miklos Szeredi" <miklos@szeredi.hu> wrote:
>
> >On Tue, 15 Jun 2021 at 08:41, jzp0409 <jzp0409@163.com> wrote:
> >>
> >> From: "edison.jiang" <jiangzhipeng@yulong.com>
> >>
> >> Android-R /sdcard mount FUSE filesystem type,
> >> use "dd" command to filli up /sdcard dir,
> >> Android will not boot normal,
> >> becase this system need at least 128M userspace.
> >>
> >> Test: open adb port,
> >>       adb shell "dd if=dev/zero of=sdcard/ae bs=1024000 count=xxx"
> >>
> >> Result: if not limit size,Android system  can not boot normal.
> >
> >Without understanding the specifics, this does not look like a kernel
> >issue at all.
> >
> >Why can't the fuse server do the limiting?
> >
> >Thanks,
> >Miklos
>
> Upstream nevert do the limiting,This leads to the problems I mentioned above。
> That's why I want to solve it from kernel.

Upstream of what?

Thanks,
Miklos
diff mbox series

Patch

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index b0e18b4..f4e54505 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -477,6 +477,21 @@  static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr
 	stbuf->f_files   = attr->files;
 	stbuf->f_ffree   = attr->ffree;
 	stbuf->f_namelen = attr->namelen;
+#ifdef LIMIT_SDCARD_SIZE
+	u32 data_free_size_th = 128*1024*1024;
+
+	stbuf->f_blocks -= (u32)data_free_size_th/attr->bsize;
+
+	if (stbuf->f_bfree < ((u32)data_free_size_th/attr->bsize))
+		stbuf->f_bfree = 0;
+	else
+		stbuf->f_bfree -= (u32)data_free_size_th/attr->bsize;
+
+	if (stbuf->f_bavail < ((u32)data_free_size_th/attr->bsize))
+		stbuf->f_bavail = 0;
+	else
+		stbuf->f_bavail -= (u32)data_free_size_th/attr->bsize;
+#endif
 	/* fsid is left zero */
 }