Skip to content

Commit

Permalink
vfs: improve comment describing fget_light()
Browse files Browse the repository at this point in the history
Improve the description of fget_light(), which is currently incorrect
about needing a prior refcnt (judging by the way it is actually used).

Signed-off-by: Tony Battersby <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
abattersby authored and torvalds committed Aug 11, 2010
1 parent 5a19ae4 commit 5893947
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,20 @@ struct file *fget(unsigned int fd)
EXPORT_SYMBOL(fget);

/*
* Lightweight file lookup - no refcnt increment if fd table isn't shared.
* You can use this only if it is guranteed that the current task already
* holds a refcnt to that file. That check has to be done at fget() only
* and a flag is returned to be passed to the corresponding fput_light().
* There must not be a cloning between an fget_light/fput_light pair.
* Lightweight file lookup - no refcnt increment if fd table isn't shared.
*
* You can use this instead of fget if you satisfy all of the following
* conditions:
* 1) You must call fput_light before exiting the syscall and returning control
* to userspace (i.e. you cannot remember the returned struct file * after
* returning to userspace).
* 2) You must not call filp_close on the returned struct file * in between
* calls to fget_light and fput_light.
* 3) You must not clone the current task in between the calls to fget_light
* and fput_light.
*
* The fput_needed flag returned by fget_light should be passed to the
* corresponding fput_light.
*/
struct file *fget_light(unsigned int fd, int *fput_needed)
{
Expand Down

0 comments on commit 5893947

Please sign in to comment.