Skip to content

Commit

Permalink
proclikefs: use per_cpu super_block.s_files
Browse files Browse the repository at this point in the history
Use per_cpu super_blocks.s_files.
Detect and use lg_local_lock(files_lglock), file_list_lock() is removed.
Also use kzalloc to zero initialize newfs.
Recent linux calls file_system_type.mount if it's not null.

Signed-off-by: Eddie Kohler <[email protected]>
  • Loading branch information
joonwpark authored and kohler committed Jun 12, 2011
1 parent b615c26 commit 440457f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config-linuxmodule.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
/* Define if your Linux kernel has files_lock. */
#undef HAVE_LINUX_FILES_LOCK

/* Define if your Linux kernel has files_lglock. */
#undef HAVE_LINUX_FILES_LGLOCK

/* Define if your Linux kernel has dev_ioctl. */
#undef HAVE_LINUX_DEV_IOCTL

Expand Down
16 changes: 16 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -8999,6 +8999,22 @@ if test $ac_cv_linux_files_lock = yes; then

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for files_lglock kernel symbol" >&5
$as_echo_n "checking for files_lglock kernel symbol... " >&6; }
if test "${ac_cv_linux_files_lglock+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if grep "__ksymtab_files_lglock" $linux_system_map >/dev/null 2>&1; then
ac_cv_linux_files_lglock=yes
else ac_cv_linux_files_lglock=no; fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_linux_files_lglock" >&5
$as_echo "$ac_cv_linux_files_lglock" >&6; }
if test $ac_cv_linux_files_lglock = yes; then
$as_echo "#define HAVE_LINUX_FILES_LGLOCK 1" >>confdefs.h

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sb_lock kernel symbol" >&5
$as_echo_n "checking for sb_lock kernel symbol... " >&6; }
if ${ac_cv_linux_sb_lock+:} false; then :
Expand Down
8 changes: 8 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,14 @@ if test $ac_cv_linux_files_lock = yes; then
AC_DEFINE(HAVE_LINUX_FILES_LOCK)
fi

AC_CACHE_CHECK(for files_lglock kernel symbol, ac_cv_linux_files_lglock,
[if grep "__ksymtab_files_lglock" $linux_system_map >/dev/null 2>&1; then
ac_cv_linux_files_lglock=yes
else ac_cv_linux_files_lglock=no; fi])
if test $ac_cv_linux_files_lglock = yes; then
AC_DEFINE(HAVE_LINUX_FILES_LGLOCK)
fi

AC_CACHE_CHECK(for sb_lock kernel symbol, ac_cv_linux_sb_lock,
[if grep "__ksymtab_sb_lock" $linux_system_map >/dev/null 2>&1; then
ac_cv_linux_sb_lock=yes
Expand Down
28 changes: 27 additions & 1 deletion linuxmodule/proclikefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
#ifndef HAVE_LINUX_FILES_LOCK
# define HAVE_LINUX_FILES_LOCK 0
#endif
#ifndef HAVE_LINUX_FILES_LGLOCK
# define HAVE_LINUX_FILES_LGLOCK 0
#endif

#if HAVE_LINUX_FILES_LGLOCK
# include <linux/lglock.h>
#endif

#ifndef MOD_DEC_USE_COUNT
# define MOD_DEC_USE_COUNT module_put(THIS_MODULE)
Expand Down Expand Up @@ -167,7 +174,7 @@ proclikefs_register_filesystem(const char *name, int fs_flags,
}

if (!newfs) {
newfs = kmalloc(sizeof(struct proclikefs_file_system) + strlen(name), GFP_ATOMIC);
newfs = kzalloc(sizeof(struct proclikefs_file_system) + strlen(name), GFP_ATOMIC);
if (!newfs) { /* out of memory */
spin_unlock(&fslist_lock);
MOD_DEC_USE_COUNT;
Expand Down Expand Up @@ -248,18 +255,37 @@ proclikefs_kill_super(struct super_block *sb, struct file_operations *dummy)
{
struct dentry *dentry_tree;
struct list_head *p;
#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) && (CONFIG_SMP))
int cpu;
#endif
#if HAVE_LINUX_FILES_LGLOCK
DECLARE_LGLOCK(files_lglock);
#endif

DEBUG("killing files");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
# if HAVE_LINUX_FILES_LOCK
file_list_lock();
# elif HAVE_LINUX_FILES_LGLOCK
lg_local_lock(files_lglock);
# endif
# if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) && (CONFIG_SMP))
for_each_possible_cpu(cpu) {
list_for_each(p, per_cpu_ptr(sb->s_files, cpu)) {
struct file *filp = list_entry(p, struct file, f_u.fu_list);
filp->f_op = dummy;
}
}
# else
list_for_each(p, &sb->s_files) {
struct file *filp = list_entry(p, struct file, f_u.fu_list);
filp->f_op = dummy;
}
# endif
# if HAVE_LINUX_FILES_LOCK
file_list_unlock();
# elif HAVE_LINUX_FILES_LGLOCK
lg_local_unlock(files_lglock);
# endif
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
# if HAVE_LINUX_FILES_LOCK
Expand Down

0 comments on commit 440457f

Please sign in to comment.