diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2006-06-23 13:05:09 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 18:43:02 +0400 |
commit | 0d9a490abe1f69fda220f7866f6f23af41daa128 (patch) | |
tree | 499b7f9c44bb5a079f8ba303fefba402e603c314 /fs/hppfs | |
parent | 090d2b185d8680fc26a2eaf4245d4171dcf4baf1 (diff) | |
download | linux-0d9a490abe1f69fda220f7866f6f23af41daa128.tar.xz |
[PATCH] locks: don't unnecessarily fail posix lock operations
posix_lock_file() was too cautious, failing operations on OOM, even if they
didn't actually require an allocation.
This has the disadvantage, that a failing unlock on process exit could lead to
a memory leak. There are two possibilites for this:
- filesystem implements .lock() and calls back to posix_lock_file(). On
cleanup of files_struct locks_remove_posix() is called which should remove all
locks belonging to files_struct. However if filesystem calls
posix_lock_file() which fails, then those locks will never be freed.
- if a file is closed while a lock is blocked, then after acquiring
fcntl_setlk() will undo the lock. But this unlock itself might fail on OOM,
again possibly leaking the lock.
The solution is to move the checking of the allocations until after it is sure
that they will be needed. This will solve the above problem since unlock will
always succeed unless it splits an existing region.
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/hppfs')
0 files changed, 0 insertions, 0 deletions