public inbox for linux-bcachefs@vger.kernel.org
 help / color / mirror / Atom feed
* bcachefs CLI: question on use of mlockall()
@ 2023-12-19  4:07 Thomas Bertschinger
  2023-12-19  4:17 ` Kent Overstreet
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Bertschinger @ 2023-12-19  4:07 UTC (permalink / raw)
  To: linux-bcachefs

The mlockall(MCL_FUTURE) call at the beginning of the bcachefs CLI
tool seems problematic in some cases. When running commands as an
unprivileged user with the default mlock limit (8 MiB), it can cause
ENOMEM failures, for example:

$ ulimit -l
8192
$ fallocate -l $((1024 ** 3)) test-image
$ bcachefs format test-image
...
error opening test-img: ENOMEM_fs_other_alloc


While this can be worked around by running the bcachefs utility as
root, or by raising the default limit, I think commands like this
should work for unprivileged users under a common default configuration.

I wonder if the mlockall() can be targeted to the scenarios where it's
really needed, instead of applying to every bcachefs command? Some
ideas on how to target it: 
- only call it if running as root
- check that getrlimit(RLIMIT_MEMLOCK, ...) is at a "high enough" value
first
- or, only call it for subcommands that actually need it

Any thoughts / comments? Would a better, or complementary approach, be
to reduce the amount of memory mapped for operations like 'format'?

Thanks!

- Thomas Bertschinger

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-19  4:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19  4:07 bcachefs CLI: question on use of mlockall() Thomas Bertschinger
2023-12-19  4:17 ` Kent Overstreet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox