Commit 088f5d72 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] add steal_locks helper

From: Chris Wright <chrisw@osdl.org>

Add steal_locks helper for use in conjunction with unshare_files to make
sure POSIX file lock semantics aren't broken due to unshare_files.
parent 04e9bcb4
...@@ -1983,6 +1983,24 @@ int lock_may_write(struct inode *inode, loff_t start, unsigned long len) ...@@ -1983,6 +1983,24 @@ int lock_may_write(struct inode *inode, loff_t start, unsigned long len)
EXPORT_SYMBOL(lock_may_write); EXPORT_SYMBOL(lock_may_write);
void steal_locks(fl_owner_t from)
{
struct list_head *tmp;
if (from == current->files)
return;
lock_kernel();
list_for_each(tmp, &file_lock_list) {
struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
if (fl->fl_owner == from)
fl->fl_owner = current->files;
}
unlock_kernel();
}
EXPORT_SYMBOL(steal_locks);
static int __init filelock_init(void) static int __init filelock_init(void)
{ {
filelock_cache = kmem_cache_create("file_lock_cache", filelock_cache = kmem_cache_create("file_lock_cache",
......
...@@ -630,6 +630,7 @@ extern int __break_lease(struct inode *inode, unsigned int flags); ...@@ -630,6 +630,7 @@ extern int __break_lease(struct inode *inode, unsigned int flags);
extern void lease_get_mtime(struct inode *, struct timespec *time); extern void lease_get_mtime(struct inode *, struct timespec *time);
extern int lock_may_read(struct inode *, loff_t start, unsigned long count); extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
extern int lock_may_write(struct inode *, loff_t start, unsigned long count); extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
extern void steal_locks(fl_owner_t from);
struct fasync_struct { struct fasync_struct {
int magic; int magic;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment