Messages in this thread |  | | Date | Mon, 21 Mar 2022 11:10:09 +1100 | Subject | Re: [RESEND PATCH v7 1/8] kernfs: Introduce interface to access global kernfs_open_file_mutex. | From | Imran Khan <> |
| |
Hello Eric,
Thanks for reviewing this.
On 19/3/22 4:10 am, Eric W. Biederman wrote: > Imran Khan <imran.f.khan@oracle.com> writes: > [...] >> 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?
The idea was to keep the interface in kernfs-internal.h. But since this mutex is used only in kernfs/file.c, I can keep the mutex static and bring interfaces that access this mutex in kernfs/file.c. This will cover your other query as well.
>> 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 >
I can put these in kernfs/file.c. Please see earlier comment.
Thanks, -- Imran
|  |