lkml.org 
[lkml]   [2022]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [RESEND PATCH v7 1/8] kernfs: Introduce interface to access global kernfs_open_file_mutex.
Imran Khan <imran.f.khan@oracle.com> writes:

> This allows to change underlying mutex locking, without needing to change
> the users of the lock. For example next patch modifies this interface to
> use hashed mutexes in place of a single global kernfs_open_file_mutex.
>
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
> ---
> fs/kernfs/file.c | 26 +++++++++++++++-----------
> fs/kernfs/kernfs-internal.h | 18 ++++++++++++++++++
> 2 files changed, 33 insertions(+), 11 deletions(-)
>
> diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
> index 7aefaca876a0..99793c32abc3 100644
> --- a/fs/kernfs/file.c
> +++ b/fs/kernfs/file.c
> @@ -30,7 +30,7 @@
> * kernfs_open_node->files, which is protected by kernfs_open_file_mutex.
> */
> static DEFINE_SPINLOCK(kernfs_open_node_lock);
> -static DEFINE_MUTEX(kernfs_open_file_mutex);
> +DEFINE_MUTEX(kernfs_open_file_mutex);
^^^^^????

Why when you want things more localized are you making a lock more
global?
> diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
> index eeaa779b929c..df00a5f5a367 100644
> --- a/fs/kernfs/kernfs-internal.h
> +++ b/fs/kernfs/kernfs-internal.h
> @@ -164,4 +164,22 @@ void kernfs_drain_open_files(struct kernfs_node *kn);
> */
> extern const struct inode_operations kernfs_symlink_iops;
>
> +extern struct mutex kernfs_open_file_mutex;
> +
> +static inline struct mutex *kernfs_open_file_mutex_ptr(struct kernfs_node *kn)
> +{
> + return &kernfs_open_file_mutex;
> +}
> +
> +static inline struct mutex *kernfs_open_file_mutex_lock(struct kernfs_node *kn)
> +{
> + struct mutex *lock;
> +
> + lock = kernfs_open_file_mutex_ptr(kn);
> +
> + mutex_lock(lock);
> +
> + return lock;
> +}

Why don't these functions live in fs/kern/fs/file.c

Eric

\
 
 \ /
  Last update: 2022-03-18 18:11    [W:0.256 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site