From 4709c9e6a19f46bbd085199607438b5ec9f0b0f6 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 25 Sep 2012 16:47:18 +0200 Subject: libmount: optimize mtab and utab parsing in umount create 8000 NFS mountpoints: #!/bin/bash mount=/tmp/mount if [ ! -d $mount ]; then mkdir -p $mount fi for dir in {1..8000}; do if [ ! -d $mount/$dir ]; then mkdir -p $mount/$dir fi echo mount $dir mount -t nfs 127.0.0.1:/ $mount/$dir done old version: time ./umount /tmp/mount/2255 real 0m1.254s user 0m1.002s sys 0m0.238s new version: time ./umount /tmp/mount/2244 real 0m0.332s user 0m0.111s sys 0m0.218s Reported-by: chenditang Signed-off-by: Karel Zak --- libmount/src/mountP.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libmount/src/mountP.h') diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index 0ef073a69..bbaa2c6c4 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -148,6 +148,10 @@ extern int mnt_get_filesystems(char ***filesystems, const char *pattern); extern void mnt_free_filesystems(char **filesystems); /* tab.c */ +extern int mnt_table_set_parser_fltrcb( struct libmnt_table *tb, + int (*cb)(struct libmnt_fs *, void *), + void *data); + extern struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb, struct libmnt_fs *fs, unsigned long mountflags, @@ -248,6 +252,10 @@ struct libmnt_table { int (*errcb)(struct libmnt_table *tb, const char *filename, int line); + int (*fltrcb)(struct libmnt_fs *fs, void *data); + void *fltrcb_data; + + struct list_head ents; /* list of entries (libmnt_fs) */ }; @@ -285,6 +293,9 @@ struct libmnt_context int (*table_errcb)(struct libmnt_table *tb, /* callback for libmnt_table structs */ const char *filename, int line); + int (*table_fltrcb)(struct libmnt_fs *fs, void *data); /* callback for libmnt_table structs */ + void *table_fltrcb_data; + char *(*pwd_get_cb)(struct libmnt_context *); /* get encryption password */ void (*pwd_release_cb)(struct libmnt_context *, char *); /* release password */ @@ -395,6 +406,10 @@ extern int mnt_context_clear_loopdev(struct libmnt_context *cxt); extern int mnt_fork_context(struct libmnt_context *cxt); +extern int mnt_context_set_tabfilter(struct libmnt_context *cxt, + int (*fltr)(struct libmnt_fs *, void *), + void *data); + /* tab_update.c */ extern int mnt_update_set_filename(struct libmnt_update *upd, const char *filename, int userspace_only); -- cgit v1.2.3-55-g7522